Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

change getopt return from char to int #193

Merged
merged 1 commit into from

3 participants

@MaZderMind

according to man 3 getopt getopt returns an int which gets -1 when no more options are available. You used to store the return value of getopt in a char, which is a unsigned 8 bit integer. As such it can actually never get -1.

So on my RasPi gcc version 4.6.3 (Debian 4.6.3-14+rpi1) did not leave the while loop correctly, even when no option was specified.

@qnology

Thanks for catching this.

@abrasive
Owner

char is signed on x86 and amd64, I never realised it wasn't on arm with gcc! Thank you for the patch!

@abrasive abrasive merged commit 9d3009e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2013
  1. @MaZderMind
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +2 −1  audio_ao.c
  2. +1 −1  shairport.c
View
3  audio_ao.c
@@ -49,7 +49,8 @@ static int init(int argc, char **argv) {
optind = 0;
// some platforms apparently require optreset = 1; - which?
- char opt, *mid;
+ int opt;
+ char *mid;
while ((opt = getopt(argc, argv, "d:i:n:o:")) > 0) {
switch (opt) {
case 'd':
View
2  shairport.c
@@ -73,7 +73,7 @@ void usage(char *progname) {
}
int parse_options(int argc, char **argv) {
- char opt;
+ int opt;
while ((opt = getopt(argc, argv, "+hvp:a:o:b:")) > 0) {
switch (opt) {
default:
Something went wrong with that request. Please try again.