Commit 5678ba9e24c9b59097762e478989248a1da40b42
authorDaniël Geelen <daniel.geelen+github@gmail.com>
Wed, 2 May 2018 16:45:22 +0000 (18:45 +0200)
committerDaniël Geelen <daniel.geelen+github@gmail.com>
Wed, 2 May 2018 16:45:22 +0000 (18:45 +0200)
simavr/sim/run_avr.c

index c3a00c1779b16163301f4ce250df3117162ca3ed..15925cbc54cfa59c8846defd928f5a5c7d6fc8e7 100644 (file)
@@ -140,7 +140,15 @@ main(
                                uint16_t addr;
                                char     name[64];
                        } trace;
-                       if(4 != sscanf(argv[pi], "%63[^=]=%63[^@]@0x%hx/0x%hhx", &trace.name[0], &trace.kind[0], &trace.addr, &trace.mask)) {
+                       const int n_args = sscanf(
+                               argv[pi],
+                               "%63[^=]=%63[^@]@0x%hx/0x%hhx",
+                               &trace.name[0],
+                               &trace.kind[0],
+                               &trace.addr,
+                               &trace.mask
+                       );
+                       if(n_args != 4) {
                                --pi;
                                fprintf(stderr, "%s: format for %s is name=kind@addr/mask.\n", argv[0], argv[pi]);
                                exit(1);
@@ -153,7 +161,12 @@ main(
                        } else if(!strcmp(trace.kind, "trace")) {
                                f.trace[f.tracecount].kind = AVR_MMCU_TAG_VCD_TRACE;
                        } else {
-                               fprintf(stderr, "%s: unknown trace kind '%s', not one of 'portpin', 'irq', or 'trace'.\n", argv[0], trace.kind);
+                               fprintf(
+                                       stderr,
+                                       "%s: unknown trace kind '%s', not one of 'portpin', 'irq', or 'trace'.\n",
+                                       argv[0],
+                                       trace.kind
+                               );
                                exit(1);
                        }
                        f.trace[f.tracecount].mask = trace.mask;