Michal Privoznik wrote:
I'm failing to see why this would be a
false positive.
It's a false positive in the sense that there is no bug here. That is, the
Gnulib patch would mean that we would be spending maintenance effort to
complicate code merely to pacify a compiler, not to fix a real problem.
Sometimes this is worth doing, if the compiler's warning is typically a valid
one and is therefore useful to catch bugs. However, this particular case does
not seem to be worth doing, as this particular compiler warning is too often a
false alarm and the bugs it catches are not worth the maintenance effort.
Despite this function being inlined, compiler might
decide to not inline it and thus treat it as any other function in which
case the variable is unused indeed.
I don't see why inlining is relevant. Regardless of whether the compiler decides
to inline at the machine-code level, the extra source-code clutter does not fix
any real bug.
I attempted to reproduce the problem by running these commands on Fedora 27
x86-64:
git clone git://libvirt.org/libvirt.git
cd libvirt
./autogen.sh
make -j5
This worked fine for me, so I can't easily test a fix; however, perhaps the
attached patch to libvirt will fix things for you.
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index f18a08a8f..299d1e3c8 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -55,8 +55,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wunsafe-loop-optimizations"
# Things like virAsprintf mean we can't use this
dontwarn="$dontwarn -Wformat-nonliteral"
- # Gnulib's stat-time.h violates this
+ # Gnulib's stat-time.h violates these
dontwarn="$dontwarn -Waggregate-return"
+ dontwarn="$dontwarn -Wunused-parameter"
# gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall
dontwarn="$dontwarn -Wenum-compare"
# gcc 5.1 -Wformat-signedness mishandles enums, not ready for prime time