OSDN Git Service

lz4: fix bogus gcc warning
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Aug 2017 07:09:54 +0000 (09:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 Sep 2017 05:07:54 +0000 (07:07 +0200)
commit529ada21ff9e37a14fd02ab1fb9d58d71d7a0d9e
tree4e862d7872cf2f5ae5194996a076101513f662e6
parentc47c52cde806f32c4da1e455874f6aa154c06aca
lz4: fix bogus gcc warning

When building lz4 under gcc-7 we get the following bogus warning:

  CC [M]  lib/lz4/lz4hc_compress.o
lib/lz4/lz4hc_compress.c: In function ‘lz4hc_compress’:
lib/lz4/lz4hc_compress.c:179:42: warning: ‘delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    chaintable[(size_t)(ptr) & MAXD_MASK] = delta;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
lib/lz4/lz4hc_compress.c:134:6: note: ‘delta’ was declared here
  u16 delta;
      ^~~~~

This doesn't show up in the 4.4-stable tree due to us turning off
warnings like this.  It also doesn't show up in newer kernel versions as
this code was totally rewritten.

So for now, to get the 4.9-stable tree to build with 0 warnings on x86
allmodconfig, let's just shut the compiler up by initializing the
variable to 0, despite it not really doing anything.

To be far, this code is crazy complex, so the fact that gcc can't
determine if the variable is really used or not isn't that bad, I'd
blame the code here instead of the compiler.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/lz4/lz4hc_compress.c