diff options
author | crasm <crasm@git.1.email.vczf.io> | 2016-12-28 01:38:05 -0500 |
---|---|---|
committer | crasm <crasm@git.1.email.vczf.io> | 2016-12-28 01:38:05 -0500 |
commit | 7b050c0184feb59baac7d9aa093c2e6f2d2fc7f4 (patch) | |
tree | e6bbda5fd0d294507f537b77d0e13a087ed502c3 | |
parent | 01466cc8405a673b8c3c43f0ac2cedb6b1251ad6 (diff) | |
download | imv-7b050c0184feb59baac7d9aa093c2e6f2d2fc7f4.tar.gz |
Store getopt() return in a signed variable
On certain platforms [0] a char may be unsigned [1]. The loop for
getopt would loop forever because:
(char)-1 => 255 and 255 != -1
A signed char also worked. I don't know what that would mean for
performance or portability. int feels simpler to me.
[0]: I'm using Arch Linux ARM on the Samsung Chromebook 2, which is
armv7h. Not sure about other ARM platforms. With this fix, imv
appears to work correctly.
details: https://archlinuxarm.org/platforms/armv7/samsung/samsung-chromebook-2
[1]: http://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default#2054941
-rw-r--r-- | src/main.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -103,7 +103,8 @@ static void parse_args(int argc, char** argv) /* Do not print getopt errors */ opterr = 0; - char *argp, *ep = *argv, o; + char *argp, *ep = *argv; + int o; while((o = getopt(argc, argv, "firasSudxhln:b:e:t:")) != -1) { switch(o) { |