Re: [chrony-dev] [PATCH] sourcestats.c: Only assign values when needed for `TRACEON` to address warnings |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
On Thu, Oct 03, 2013 at 02:49:43PM +0200, Paul Menzel wrote:
> Date: Thu, 3 Oct 2013 14:22:37 +0200
>
> The Clang static analyzer scan-build from Debian clang version 3.4-1
> currently issues the following two warnings.
>
> /usr/share/clang/scan-build/ccc-analyzer -O2 -g -c sourcestats.c
> sourcestats.c:625:5: warning: Value stored to 'prev' is never read
> prev = *sample;
> ^ ~~~~~~~
> sourcestats.c:640:3: warning: Value stored to 'prev_offset' is never read
> prev_offset = inst->estimated_offset;
> ^ ~~~~~~~~~~~~~~~~~~~~~~
> 2 warnings generated.
>
> In both cases, the variables are only read, when `TRACEON` is defined.
> So only assign them in that case. The warning is gone now.
>
> The compiler probably got rid of the variables already.
> ---
> Should the declaration of the variables also be included into an if
> statement?
I've fixed this by casting to void, similarly to the previous report.
It seems more readable to me than adding more #ifdefs to the function.
Thanks for the report.
--
Miroslav Lichvar
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.