Fossil User Forum

nRows unused warning in forum.c
Login

nRows unused warning in forum.c

nRows unused warning in forum.c

(1) By Andy Bradford (andybradford) on 2024-12-19 17:07:38 [source]

../src/forum.c:1835:9: warning: variable 'nRows' set but not used [-Wunused-but-set-variable]
    int nRows = 0;
        ^
1 warning generated.

Technically,  it's not  really used  for anything.  Does it  need to  be
there? Was it forgotten? I'm inclined to  remove it but I don't know the
intention.

Andy

(2) By Daniel Dumitriu (danield) on 2024-12-19 17:33:37 in reply to 1 [link] [source]

Clang does not yell. Is post-incrementing it on line 1846 technically not counting as "usage"?

(3) By Andy Bradford (andybradford) on 2024-12-19 17:49:56 in reply to 2 [link] [source]

> Is  post-incrementing it  on  line 1846  technically  not counting  as
> "usage"?

I'm  actually  impressed  that  the  compiler  flags  this  as  non-use.
Obviously a human brain can look at those lines of code and realize that
it is not really being used, but the fact that there is a post-increment
is debatably "usage". I don't really count post-incrementing as "usage".
Maybe  someone intended  to leave  it there  so when  they run  it in  a
debugger they can view the value of nRows, but no other part of the code
is actually "using" it.

Andy

(4) By Andy Bradford (andybradford) on 2024-12-19 17:51:13 in reply to 2 [link] [source]

> Clang does not yell.

Well, this is what I'm running here:

$ cc --version
OpenBSD clang version 16.0.6
Target: amd64-unknown-openbsd7.5
Thread model: posix
InstalledDir: /usr/bin

Andy

(5) By Daniel Dumitriu (danield) on 2024-12-19 17:58:49 in reply to 3 [link] [source]

On second thought, I don't see it as usage.

Unless we want to display the number of "non-supervisor moderators" (which could be saved before the if), I would/will remove it.

(6) By Andy Bradford (andybradford) on 2024-12-19 18:09:50 in reply to 5 [link] [source]

I have been intending to remove it  for a while now, I just keep getting
distracted with other projects. Before I did, however, I wanted to bring
it up just in case there were some plans for it of which I was unaware.

Andy