aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorcrasm <crasm@git.1.email.vczf.io>2016-12-28 01:38:05 -0500
committercrasm <crasm@git.1.email.vczf.io>2016-12-28 01:38:05 -0500
commit7b050c0184feb59baac7d9aa093c2e6f2d2fc7f4 (patch)
treee6bbda5fd0d294507f537b77d0e13a087ed502c3 /src/main.c
parent01466cc8405a673b8c3c43f0ac2cedb6b1251ad6 (diff)
downloadimv-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
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index e73b205..fefd1ff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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) {