[master] a5810d25d Coverity: Explain vtc_logfail()

Dridi Boukelmoune dridi at varni.sh
Mon Sep 16 16:44:11 UTC 2024


On Thu, Sep 12, 2024 at 9:50 AM Nils Goroll <nils.goroll at uplex.de> wrote:
>
>
> commit a5810d25d00eaaa97f551a52bb03139c4d610cc8
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date:   Thu Sep 12 11:37:55 2024 +0200
>
>     Coverity: Explain vtc_logfail()
>
>     It seems coverity does not grok vtc_logfail() via vtc_fatal() as panic-ish,
>     because it complains about a possible overflow for l in
>
>             if (signed <= 0)
>                     vtc_fatal(...)
>             l -= signed;
>
>     Ref CID 1605325
>
> diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
> index 5fa44e7be..26bb7302e 100644
> --- a/bin/varnishtest/vtc_log.c
> +++ b/bin/varnishtest/vtc_log.c
> @@ -109,6 +109,13 @@ vtc_logclose(void *arg)
>         FREE_OBJ(vl);
>  }
>
> +#ifdef __COVERITY__
> +static void v_noreturn_
> +vtc_logfail(void)
> +{
> +       __coverity_panic__();
> +}
> +#else
>  static void v_noreturn_
>  vtc_logfail(void)
>  {
> @@ -119,6 +126,7 @@ vtc_logfail(void)
>         else
>                 exit(fail_out());
>  }
> +#endif

Out of curiosity, are you against this instead?

--->8---
static void v_noreturn_
vtc_logfail(void)
{

        vtc_error = 2;
        if (!pthread_equal(pthread_self(), vtc_thread))
                pthread_exit(NULL);
        else
                exit(fail_out());

#ifdef __COVERITY__
        __coverity_panic__();
#endif
}
---8<---

Alternatively, why not a simple `WRONG("unreachable");` statement
instead of a coverity gadget?

>  static const char * const lead[] = {
>         "----",
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit


More information about the varnish-commit mailing list