Skip to content

Commit 86fcc75

Browse files
committed
examples/mi-mctp: fix warning for possibly uninitialised variable
gcc-12 with -Wuninitialized-var reports a warning for mi-mctp: examples/mi-mctp.c: In function ‘do_action_endpoint’: examples/mi-mctp.c:665:16: warning: ‘rc’ may be used uninitialized [-Wmaybe-uninitialized] 665 | return rc; | ^~ examples/mi-mctp.c:637:13: note: ‘rc’ was declared here 637 | int rc; | ^~ We shouldn't be able to hit this path, but explicitly set rc to an error if we miss an enum case. Fixes: #467 Signed-off-by: Jeremy Kerr <[email protected]>
1 parent bd08e22 commit 86fcc75

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

examples/mi-mctp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ static int do_action_endpoint(enum action action, nvme_mi_ep_t ep, int argc, cha
661661
case ACTION_CONFIG_SET:
662662
rc = do_config_set(ep, argc, argv);
663663
break;
664+
default:
665+
/* This shouldn't be possible, as we should be covering all
666+
* of the enum action options above. Hoever, keep the compilers
667+
* happy and fail gracefully. */
668+
fprintf(stderr, "invalid action %d?\n", action);
669+
rc = -1;
664670
}
665671
return rc;
666672
}

0 commit comments

Comments
 (0)