Re: [PATCH] ext2/e2fsprogs: fix cppcheck warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 15, 2018 at 01:56:42PM +0000, ykp@xxxxxxxxxxxxx wrote:
>
> gcc-wall generate a lot of noice, for example 45 such warnings in /debugfs/debugfs.c:
> 
> > ../../debugfs/debugfs.c:221:49: warning: declaration of ‘sci_idx’ shadows a global declaration [-Wshadow]
> > void do_open_filesys(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
> > ../../debugfs/debugfs.h:28:12: note: shadowed declaration is here
> > extern int sci_idx;
> > ^~~~~~~

Yeah, that's something which I had thought I had fixed, but I forgot a
rename in debugfs.h.  I'll fix it upstream:

diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index 449740be8..d1d13b455 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -25,7 +25,7 @@
 extern ext2_filsys current_fs;
 extern quota_ctx_t current_qctx;
 extern ext2_ino_t	root, cwd;
-extern int sci_idx;
+extern int ss_sci_idx;
 extern ss_request_table debug_cmds, extent_cmds;
 
 extern void reset_getopt(void);

Yes, even with the above fix, gcc-wall is a bit noise.  I don't always
fix all gcc warnings....

> I've tried clang as you suggested.
> I've replaced "CC = gcc" by "CC = clang" or even "CC = clang -Weverything -pedantic",
> but output remains the same as if I just normally compile the project with make and gcc.
> What is wrong?

Here's an example:

<tytso@cwcc> {/tmp/e2fsprogs}  
1070% CC=clang /usr/projects/e2fsprogs/e2fsprogs/configure
      ...
<tytso@cwcc> {/tmp/e2fsprogs}  
1070% grep clang MCONFIG 
CC = clang
BUILD_CC = clang
LD = $(PURE) clang

You can verify what C compiler and cc flags are in use by using V=1
(this a convention from Kernel builds):

<tytso@cwcc> {/tmp/e2fsprogs}  
1071% cd util ; make V=1
echo "/* fake dirpaths.h for config.h */" > dirpaths.h
clang -c -g -flto -ffat-lto-objects    -g -O2  -I. -I../lib -I/usr/projects/e2fsprogs/e2fsprogs/lib -DHAVE_CONFIG_H /usr/projects/e2fsprogs/e2fsprogs/util/subst.c -o subst.o
clang: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
clang -g -flto -ffat-lto-objects     -o subst subst.o
clang -c -g -flto -ffat-lto-objects    -g -O2  -I. -I../lib -I/usr/projects/e2fsprogs/e2fsprogs/lib -DHAVE_CONFIG_H /usr/projects/e2fsprogs/e2fsprogs/util/symlinks.c -o symlinks.o
clang: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
clang -g -flto -ffat-lto-objects     -o symlinks symlinks.o

(The complaint about -ffat-lto-objects is recent, since we only
recently added LTO support --- the next/master branch is our
development branch and so will often be new gcc warnings that pop up.
LTO support is pretty new, and doesn't work the same across gcc/clang
or different versions of gcc for that matter.  I'm going to change the
autoconf file to not enable LTO by default, since it our current LTO
is clearly broken for clang.)

To learn more about the build system, look at MCONFIG.in in the source
directory, MCONFIG in the build directory, and look first dozen lines
or so of e2fsck/Makefile.in, libext2fs/Makefile.in, etc.

						- Ted



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux