Skip to content

examples/mi-mctp: fix warning for possibly uninitialised variable#469

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
CodeConstruct:action-warn-fix
Sep 9, 2022
Merged

examples/mi-mctp: fix warning for possibly uninitialised variable#469
igaw merged 1 commit intolinux-nvme:masterfrom
CodeConstruct:action-warn-fix

Conversation

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

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 jk@codeconstruct.com.au

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: linux-nvme#467

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
@igaw igaw merged commit e88d210 into linux-nvme:master Sep 9, 2022
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Sep 9, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile warning in mi-mctp.c

2 participants