Skip to content

Commit

Permalink
fzenity: fix dead store
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
kmk3 committed May 10, 2022
1 parent a3f00ed commit a33d7eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fzenity/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ char *print_line(char *in, int col) {
if (*ptr == '\n') {
*ptr++ = '\0';
printf("%s\n", in);
return ptr++;
return ptr;
}
else if (i == col) {
while (*ptr != ' ' && ptr != in)
Expand Down

0 comments on commit a33d7eb

Please sign in to comment.