https://bugs.kde.org/show_bug.cgi?id=358697

            Bug ID: 358697
           Summary: valgrind.h: Some code remains even when defining
                    NVALGRIND
           Product: valgrind
           Version: 3.12 SVN
          Platform: Compiled Sources
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: z...@gentoo.org

Since revision r15762 the function VALGRIND_PRINTF will create some code, even
when NVALGRIND is defined.

This is caused by using code with volatile to silence variable unused warning.
VALGRIND_PRINTF(const char *format, ...)
{
#if defined(NVALGRIND)
   if (format) *(volatile const char *)format;   /* avoid compiler warning */
    return 0;
#else /* NVALGRIND */
...

I suggest to use either simpler code to silence the variable unused warning.
E.g. (void)format;

But as Florian wrote, this could trigger some static analyzers.

Alternatively use the gcc construct __attribute__((__unused__)) and only use
the simple version if this is not supported by the compiler.
One possibility is to conditionally define __attribute__ for all other
compilers, so its usage is without conditionals.
If you do not want to define __attribute__ for namespace pollution, there could
be a valgrind specific name, maybe __vg__attribute__ that is defined the same
way, and for gcc equals to __attribute__.


Reproducible: Always

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to