Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fzenity: fix dead store #5134

Merged
merged 1 commit into from
May 10, 2022
Merged

fzenity: fix dead store #5134

merged 1 commit into from
May 10, 2022

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented May 7, 2022

As caught by the Clang Static Analyzer:

$ make clean && NO_EXTRA_CFLAGS="yes" scan-build --status-bugs make -C src/fzenity
[...]
main.c:77:10: warning: Value stored to 'ptr' is never read [deadcode.DeadStores]
                return ptr++;
                       ^~~~~
1 warning generated.
[...]
scan-build: Analysis run complete.
scan-build: 1 bug found.

The above increment is a no-op, as it is equivalent to
return ptr; ptr++;.

For it to make any difference, the prefix increment operator would have
to be used in place of the postfix one:

return ++ptr;

Which would be equivalent to ++ptr; return ptr;.

But in order to fix the warning (and CI) while avoiding to change the
current behavior, just remove the operator instead.

Added on commit 1cdfa6f ("more on firecfg --guide: fzenity",
2022-04-25).

@kmk3 kmk3 requested a review from netblue30 May 7, 2022 22:28
As caught by the Clang Static Analyzer:

    $ make clean && NO_EXTRA_CFLAGS="yes" scan-build --status-bugs make -C src/fzenity
    [...]
    main.c:77:10: warning: Value stored to 'ptr' is never read [deadcode.DeadStores]
                    return ptr++;
                           ^~~~~
    1 warning generated.
    [...]
    scan-build: Analysis run complete.
    scan-build: 1 bug found.

The above increment is a no-op, as it is equivalent to
`return ptr; ptr++;`.

For it to make any difference, the prefix increment operator would have
to be used in place of the postfix one:

    return ++ptr;

Which would be equivalent to `++ptr; return ptr;`.

But in order to fix the warning (and CI) while avoiding to change the
current behavior, just remove the operator instead.

Added on commit 1cdfa6f ("more on firecfg --guide: fzenity",
2022-04-25).
@kmk3 kmk3 force-pushed the fix-fzenity-deadstore branch from 677ed74 to bba57f4 Compare May 7, 2022 22:36
@kmk3 kmk3 merged commit a33d7eb into netblue30:master May 10, 2022
@kmk3 kmk3 deleted the fix-fzenity-deadstore branch May 10, 2022 12:02
@kmk3
Copy link
Collaborator Author

kmk3 commented May 10, 2022

CI checks should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (RELNOTES N/A)
Development

Successfully merging this pull request may close these issues.

1 participant