[Spice-devel] [server patch v2] test-loop: increment a variable outside of spice_assert
Victor Toso
victortoso at redhat.com
Fri Aug 23 06:59:01 UTC 2019
Hi,
On Thu, Aug 22, 2019 at 06:53:12PM +0300, Uri Lublin wrote:
> spice_assert is a macro and covscan reports that:
> Argument "++twice_remove_called" of spice_assert() has a side effect.
>
> Doesn't matter if there is a side effects or not,
> it's a good practice and it makes covscan happy, so
> increment the variable one line above.
>
> Signed-off-by: Uri Lublin <uril at redhat.com>
> ---
>
> v1->v2: change commit log (Frediano)
>
> ---
> server/tests/test-loop.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/server/tests/test-loop.c b/server/tests/test-loop.c
> index 82af80ab3..4df3a7d20 100644
> --- a/server/tests/test-loop.c
> +++ b/server/tests/test-loop.c
> @@ -78,7 +78,8 @@ static SpiceTimer *twice_timers_remove[2] = { NULL, NULL };
> static int twice_remove_called = 0;
> static void timer_not_twice_remove(void *opaque)
> {
> - spice_assert(++twice_remove_called == 1);
> + ++twice_remove_called;
Silly question here but is there a reason why pre-increment would
be preferred in this case?
> + spice_assert(twice_remove_called == 1);
>
> /* delete timers, should not have another call */
> core->timer_remove(twice_timers_remove[0]);
> --
> 2.21.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190823/84a12cf8/attachment-0001.sig>
More information about the Spice-devel
mailing list