summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bin/gfxx.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/bin/gfxx.c b/bin/gfxx.c
index 0d0b9c79..b1d642bf 100644
--- a/bin/gfxx.c
+++ b/bin/gfxx.c
@@ -79,12 +79,11 @@ extern int init(int argc, char *argv[]) {
                 default: return EX_USAGE;
             } break;
             case 'b': {
-                size_t len = strlen(optarg);
-                if (len < 3 || len > 4) return EX_USAGE;
-                bits[0] = (len > 3) ? optarg[0] - '0' : 0;
-                bits[1] = optarg[len-3] - '0';
-                bits[2] = optarg[len-2] - '0';
-                bits[3] = optarg[len-1] - '0';
+                if (strlen(optarg) < 4) return EX_USAGE;
+                bits[0] = optarg[0] - '0';
+                bits[1] = optarg[1] - '0';
+                bits[2] = optarg[2] - '0';
+                bits[3] = optarg[3] - '0';
             } break;
             case 'n': offset  = strtoul(optarg, NULL, 0); break;
             case 'f': flip   ^= true; break;