change getopt return from char to int #193

merged 1 commit into from Apr 2, 2013


None yet
3 participants

MaZderMind commented Apr 2, 2013

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 commented Apr 2, 2013

Thanks for catching this.


abrasive commented Apr 2, 2013

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

@abrasive abrasive added a commit that referenced this pull request Apr 2, 2013

@abrasive abrasive Merge pull request #193 from MaZderMind/getoptint
change getopt return storage from char to int

@abrasive abrasive merged commit 9d3009e into abrasive:1.0-dev Apr 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment