Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes based on gcc 6.x warnings #4632

Closed
wants to merge 2 commits into from
Closed

fixes based on gcc 6.x warnings #4632

wants to merge 2 commits into from

Conversation

marcelhuberfoo
Copy link
Contributor

The changes in the files should be self explanatory.

But there's another warning I was not able to fix due to fairly complicated indirections and bit manipulations. Here is the compiler output:

In file included from ../../include/sys/spa.h:588:0,
                 from zdb.c:34:
zdb.c: In function ‘dump_object’:
../../include/sys/dmu.h:130:8: warning: array subscript is outside array bounds [-Warray-bounds]
  dmu_ot[(int)(ot)].ot_byteswap)
  ~~~~~~^~~~~~~~~~~
zdb.c:72:18: note: in expansion of macro ‘DMU_OT_BYTESWAP’
  dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
                  ^~~~~~~~~~~~~~~
zdb.c:1931:26: note: in expansion of macro ‘ZDB_OT_NAME’
      asize, lsize, fill, ZDB_OT_NAME(doi.doi_type), aux);
                          ^~~~~~~~~~~
../../include/sys/dmu.h:130:8: warning: array subscript is outside array bounds [-Warray-bounds]
  dmu_ot[(int)(ot)].ot_byteswap)
  ~~~~~~^~~~~~~~~~~
zdb.c:72:18: note: in expansion of macro ‘DMU_OT_BYTESWAP’
  dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
                  ^~~~~~~~~~~~~~~
zdb.c:1936:7: note: in expansion of macro ‘ZDB_OT_NAME’
       ZDB_OT_NAME(doi.doi_bonus_type));
       ^~~~~~~~~~~

hinted by gcc:

../../module/zfs/zio_inject.c: In function ‘zio_handle_io_delay’:
../../module/zfs/zio_inject.c:382:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   if (handler->zi_record.zi_freq != 0 &&
      ^~
      ../../module/zfs/zio_inject.c:384:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
          continue;
	      ^~~~~~~~
hinted by gcc:

libzfs_import.c: In function ‘fix_paths’:
libzfs_import.c:602:28: warning: self-comparison always evaluates to true [-Wtautological-compare]
    if (best->ne_num_labels == best->ne_num_labels &&
                                ^~
@behlendorf
Copy link
Contributor

Nice finds! Thanks for opening the PR, both of these LGTM. As for the zdb issue that's going to take more investigation.

I regularly build under CentOS 6.x and have never noticed these warnings. What additional flags are you including? We may want to add them them to debug builds.

@tuxoko
Copy link
Contributor

tuxoko commented May 11, 2016

Wow, it use indent has a hint to find if without curly braces, that's a nice feature. It makes me want to go back to Arch to get the latest GCC.

@marcelhuberfoo
Copy link
Contributor Author

@tuxoko yes, Arch is quite nice to having (bleeding) edge tools available 👍
@behlendorf I am using gcc 6.1.1-1 as packaged in ArchLinux. Here is the verbose output of the zio_inject.c compilation where you might find the built in settings of the compiler in use:

  CC       zio_inject.lo
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.1.1 20160501 (GCC) 
COLLECT_GCC_OPTIONS='-D' 'HAVE_CONFIG_H' '-include' '../../zfs_config.h' '-I' '../../include' '-I' '../../lib/libspl/include' '-D' '_GNU_SOURCE' '-D' '__EXTENSIONS__' '-D' '_REENTRANT' '-D' '_POSIX_PTHREAD_SEMANTICS' '-D' '_FILE_OFFSET_BITS=64' '-D' '_LARGEFILE64_SOURCE' '-D' 'HAVE_LARGE_STACKS=1' '-D' 'TEXT_DOMAIN="zfs-linux-user"' '-D' 'LIBEXECDIR="/usr/lib/zfs-0.6.5.247.g04bc461"' '-D' 'RUNSTATEDIR="/usr/var/run"' '-D' 'SBINDIR="/usr/bin"' '-D' 'SYSCONFDIR="/etc"' '-D' '_FORTIFY_SOURCE=2' '-D' 'NDEBUG' '-Wall' '-Wstrict-prototypes' '-Wno-unused-but-set-variable' '-Wno-bool-compare' '-fno-strict-aliasing' '-Wframe-larger-than=1024' '-v' '-march=x86-64' '-mtune=generic' '-O2' '-pipe' '-fstack-protector-strong' '-MT' 'zio_inject.lo' '-MD' '-MP' '-MF' '.deps/zio_inject.Tpo' '-c' '-fPIC' '-D' 'PIC' '-o' '.libs/zio_inject.o'
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/cc1 -quiet -v -I ../../include -I ../../lib/libspl/include -MD .libs/zio_inject.d -MF .deps/zio_inject.Tpo -MP -MT zio_inject.lo -D HAVE_CONFIG_H -D _GNU_SOURCE -D __EXTENSIONS__ -D _REENTRANT -D _POSIX_PTHREAD_SEMANTICS -D _FILE_OFFSET_BITS=64 -D _LARGEFILE64_SOURCE -D HAVE_LARGE_STACKS=1 -D TEXT_DOMAIN="zfs-linux-user" -D LIBEXECDIR="/usr/lib/zfs-0.6.5.247.g04bc461" -D RUNSTATEDIR="/usr/var/run" -D SBINDIR="/usr/bin" -D SYSCONFDIR="/etc" -D _FORTIFY_SOURCE=2 -D NDEBUG -D PIC -include ../../zfs_config.h ../../module/zfs/zio_inject.c -quiet -dumpbase zio_inject.c -march=x86-64 -mtune=generic -auxbase-strip .libs/zio_inject.o -O2 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-bool-compare -Wframe-larger-than=1024 -version -fno-strict-aliasing -fstack-protector-strong -fPIC -o - |
 as -v -I ../../include -I ../../lib/libspl/include --64 -o .libs/zio_inject.o
GNU assembler version 2.26.0 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.26.0.20160501
GNU C11 (GCC) version 6.1.1 20160501 (x86_64-pc-linux-gnu)
    compiled by GNU C version 6.1.1 20160501, GMP version 6.1.0, MPFR version 3.1.4-p1, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 ../../include
 ../../lib/libspl/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include-fixed
 /usr/include
End of search list.
GNU C11 (GCC) version 6.1.1 20160501 (x86_64-pc-linux-gnu)
    compiled by GNU C version 6.1.1 20160501, GMP version 6.1.0, MPFR version 3.1.4-p1, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2b52ee45146df7b1f5b2606d8e51eb15
../../module/zfs/zio_inject.c: In function ‘zio_handle_io_delay’:
../../module/zfs/zio_inject.c:382:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   if (handler->zi_record.zi_freq != 0 &&
   ^~
../../module/zfs/zio_inject.c:384:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
    continue;
    ^~~~~~~~
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-D' 'HAVE_CONFIG_H' '-include' '../../zfs_config.h' '-I' '../../include' '-I' '../../lib/libspl/include' '-D' '_GNU_SOURCE' '-D' '__EXTENSIONS__' '-D' '_REENTRANT' '-D' '_POSIX_PTHREAD_SEMANTICS' '-D' '_FILE_OFFSET_BITS=64' '-D' '_LARGEFILE64_SOURCE' '-D' 'HAVE_LARGE_STACKS=1' '-D' 'TEXT_DOMAIN="zfs-linux-user"' '-D' 'LIBEXECDIR="/usr/lib/zfs-0.6.5.247.g04bc461"' '-D' 'RUNSTATEDIR="/usr/var/run"' '-D' 'SBINDIR="/usr/bin"' '-D' 'SYSCONFDIR="/etc"' '-D' '_FORTIFY_SOURCE=2' '-D' 'NDEBUG' '-Wall' '-Wstrict-prototypes' '-Wno-unused-but-set-variable' '-Wno-bool-compare' '-fno-strict-aliasing' '-Wframe-larger-than=1024' '-v' '-march=x86-64' '-mtune=generic' '-O2' '-pipe' '-fstack-protector-strong' '-MT' 'zio_inject.lo' '-MD' '-MP' '-MF' '.deps/zio_inject.Tpo' '-c' '-fPIC' '-D' 'PIC' '-o' '.libs/zio_inject.o'

Arch specific options in use are:

CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"

@behlendorf
Copy link
Contributor

behlendorf commented May 12, 2016

I'd like to apply 6028dcd now but defer 7f231f0. This code will be replaced entirely when openzfs/openzfs@97e8130 is ported which @tonyhutter is working on at the moment. @tuxoko can I added your signed off to 6028dcd?

@tuxoko
Copy link
Contributor

tuxoko commented May 12, 2016

Go ahead
On May 12, 2016 12:30 PM, "Brian Behlendorf" notifications@github.com
wrote:

I'd like to apply 6028dcd
6028dcd
now but defer 7f231f0
7f231f0.
This code will be replaced entirely when openzfs/master@97e8130
https://github.com/openzfs/master/commit/97e8130 is ported with
@tonyhutter https://github.com/tonyhutter is working on at the moment.
@tuxoko https://github.com/tuxoko can I added your signed off to 6028dcd
6028dcd
?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4632 (comment)

behlendorf pushed a commit to behlendorf/zfs that referenced this pull request May 12, 2016
Fixes bug introduced in commit 7d90f569a.  Hinted by gcc:

libzfs_import.c: In function ‘fix_paths’:
libzfs_import.c:602:28: warning: self-comparison always evaluates to true [-Wtautological-compare]
    if (best->ne_num_labels == best->ne_num_labels &&

Signed-off-by: Marcel Huber <marcelhuberfoo@gmail.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#4632
@behlendorf
Copy link
Contributor

OK, I've merged both fixed from this PR rather than wait for the openzfs/openzfs@97e8130 port.

ryao pushed a commit to ClusterHQ/zfs that referenced this pull request Jun 7, 2016
Fixes bug introduced in commit 7d90f569a.  Hinted by gcc:

libzfs_import.c: In function ‘fix_paths’:
libzfs_import.c:602:28: warning: self-comparison always evaluates to true [-Wtautological-compare]
    if (best->ne_num_labels == best->ne_num_labels &&

Signed-off-by: Marcel Huber <marcelhuberfoo@gmail.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#4632
ryao pushed a commit to ClusterHQ/zfs that referenced this pull request Jun 7, 2016
Fixed bug introduced in commit #c35b1882.  Hinted by gcc:

zio_inject.c: In function ‘zio_handle_io_delay’:
zio_inject.c:382:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   if (handler->zi_record.zi_freq != 0 &&
      ^~
      zio_inject.c:384:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
          continue;
	      ^~~~~~~~

Signed-off-by: Marcel Huber <marcelhuberfoo@gmail.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#4632
nedbass pushed a commit to nedbass/zfs that referenced this pull request Sep 5, 2016
Fixes bug introduced in commit 7d90f569a.  Hinted by gcc:

libzfs_import.c: In function ‘fix_paths’:
libzfs_import.c:602:28: warning: self-comparison always evaluates to true [-Wtautological-compare]
    if (best->ne_num_labels == best->ne_num_labels &&

Signed-off-by: Marcel Huber <marcelhuberfoo@gmail.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#4632
tuxoko pushed a commit to tuxoko/zfs that referenced this pull request Sep 8, 2016
Fixes bug introduced in commit 7d90f569a.  Hinted by gcc:

libzfs_import.c: In function ‘fix_paths’:
libzfs_import.c:602:28: warning: self-comparison always evaluates to true [-Wtautological-compare]
    if (best->ne_num_labels == best->ne_num_labels &&

Signed-off-by: Marcel Huber <marcelhuberfoo@gmail.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#4632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants