Tracking bug for static code analysis fixes. (LU-2753)

[LU-871] clang: minor code cleanups Created: 21/Nov/11  Updated: 05/Feb/13  Resolved: 05/Feb/13

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.2.0
Fix Version/s: Lustre 2.2.0

Type: Technical task Priority: Minor
Reporter: Andreas Dilger Assignee: Andreas Dilger
Resolution: Fixed Votes: 1
Labels: clang
Environment:

FC13 running clang-analyzer-2.8-10.fc13.x86_64


Attachments: File lustre-2.1.54-scan-build_wo_core.NullDereference_check.tar.bz2    
Issue Links:
Related
is related to LU-2675 clang: code cleanups for sparse stati... Resolved
Rank (Obsolete): 4812

 Description   

Tracking bug for warnings produced by the clang-analyzer static code analysis tool.

The first one is a trivial printk() format warning due to the use of "%Lu" for LPU64, and other places in the code. The "%L" format specifier is a GCCism that is deprecated in favor of "%ll" from C99.



 Comments   
Comment by Andreas Dilger [ 23/Nov/11 ]

build: change %L printk format to %ll: http://review.whamcloud.com/1734

Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,client,sles11,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/utils/gss/lgss_keyring.c
  • lustre/tests/checkstat.c
  • lustre/llite/rw.c
  • lustre/fid/lproc_fid.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/include/lustre_debug.h
  • lnet/utils/routerstat.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/file.c
  • lustre/tests/truncate.c
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/linux/kp30.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,client,el6,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • libcfs/include/libcfs/linux/kp30.h
  • lustre/tests/checkstat.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/tests/truncate.c
  • lustre/llite/file.c
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/include/lustre_debug.h
  • lustre/llite/rw.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/fid/lproc_fid.c
  • lnet/utils/routerstat.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,server,el6,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/utils/gss/lgss_utils.c
  • lustre/include/lustre_debug.h
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/fid/lproc_fid.c
  • lustre/utils/gss/lgss_keyring.c
  • lnet/utils/routerstat.c
  • lustre/tests/truncate.c
  • lustre/llite/file.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/llite/rw.c
  • lustre/tests/checkstat.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,client,el5,ofa #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/liblustre/super.c
  • lustre/tests/truncate.c
  • lustre/llite/rw.c
  • lustre/fid/lproc_fid.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/tests/checkstat.c
  • lnet/utils/routerstat.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/llite/file.c
  • lustre/include/lustre_debug.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,client,el6,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/tests/checkstat.c
  • lustre/tests/truncate.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/utils/gss/lgss_utils.c
  • lustre/fid/lproc_fid.c
  • lustre/llite/rw.c
  • lustre/llite/file.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/include/lustre_debug.h
  • lnet/utils/routerstat.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,client,el5,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lnet/utils/routerstat.c
  • lustre/tests/truncate.c
  • lustre/fid/lproc_fid.c
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/tests/checkstat.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/include/lustre_debug.h
  • lustre/llite/rw.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/file.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,client,ubuntu1004,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/liblustre/super.c
  • lnet/utils/routerstat.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/tests/checkstat.c
  • lustre/llite/rw.c
  • lustre/tests/truncate.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/include/lustre_debug.h
  • lustre/llite/file.c
  • lustre/fid/lproc_fid.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/utils/gss/lgss_keyring.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,server,el5,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/tests/truncate.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/file.c
  • lustre/llite/rw.c
  • lustre/include/lustre_debug.h
  • lustre/fid/lproc_fid.c
  • lustre/utils/gss/lgss_keyring.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/tests/checkstat.c
  • lustre/liblustre/super.c
  • lnet/utils/routerstat.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,client,el5,ofa #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lnet/utils/routerstat.c
  • libcfs/include/libcfs/linux/kp30.h
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/llite/file.c
  • lustre/llite/rw.c
  • lustre/liblustre/super.c
  • lustre/tests/checkstat.c
  • lustre/include/lustre_debug.h
  • lustre/utils/gss/lgss_utils.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/tests/truncate.c
  • lustre/fid/lproc_fid.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,client,el5,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/tests/truncate.c
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/tests/checkstat.c
  • lnet/utils/routerstat.c
  • lustre/include/lustre_debug.h
  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/file.c
  • lustre/utils/gss/lgss_keyring.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/fid/lproc_fid.c
  • lustre/llite/rw.c
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » x86_64,server,el5,ofa #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = FAILURE
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • libcfs/include/libcfs/linux/kp30.h
  • lustre/llite/file.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/tests/truncate.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/llite/rw.c
  • lnet/utils/routerstat.c
  • lustre/tests/checkstat.c
  • lustre/fid/lproc_fid.c
  • lustre/liblustre/super.c
  • lustre/include/lustre_debug.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,server,el5,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/utils/gss/lgss_keyring.c
  • lustre/liblustre/super.c
  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/rw.c
  • lustre/tests/checkstat.c
  • lustre/llite/file.c
  • lnet/utils/routerstat.c
  • lustre/tests/truncate.c
  • lustre/fid/lproc_fid.c
  • lustre/include/lustre_debug.h
  • libcfs/include/libcfs/linux/kp30.h
  • libcfs/include/libcfs/posix/posix-wordsize.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,server,el6,inkernel #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/llite/rw.c
  • libcfs/include/libcfs/linux/kp30.h
  • lustre/utils/gss/lgss_utils.c
  • lustre/fid/lproc_fid.c
  • lustre/tests/checkstat.c
  • lustre/liblustre/super.c
  • lustre/tests/truncate.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/llite/file.c
  • lustre/include/lustre_debug.h
  • lnet/utils/routerstat.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
Comment by Build Master (Inactive) [ 12/Dec/11 ]

Integrated in lustre-master » i686,server,el5,ofa #378
LU-871 build: change %L printk format to %ll (Revision 3684de257a7e8932936a27d0fdb3ecb39653e624)

Result = SUCCESS
Oleg Drokin : 3684de257a7e8932936a27d0fdb3ecb39653e624
Files :

  • lustre/utils/gss/lgss_utils.c
  • lustre/llite/file.c
  • lustre/utils/gss/lgss_keyring.c
  • lustre/tests/checkstat.c
  • lustre/fid/lproc_fid.c
  • lustre/liblustre/super.c
  • libcfs/include/libcfs/posix/posix-wordsize.h
  • lustre/tests/truncate.c
  • lnet/utils/routerstat.c
  • lustre/llite/rw.c
  • lustre/include/lustre_debug.h
  • libcfs/include/libcfs/linux/kp30.h
Comment by Karsten Weiss [ 12/Jan/12 ]

FWIW I've compiled Lustre 2.1.54 patchless client on CentOS 6.2 with Clang's static analyzer (LLVM 3.0).

I decided to disable the static analyzer check "core.NullDereference" because it detects lots of bugs (521). However, based on a first short glance most of them are dubious because the analyzer seems to get confused by Lustre's LASSERT(). (And including all of these 521 bugs would make the tarball larger than the Jira upload file limit.)

Here's the bug summary:

Bug Type Quantity
All Bugs 270
API  
Argument with 'nonnull' attribute passed null 16
Dead code  
Idempotent operation 30
Dead store  
Dead assignment 120
Dead increment 6
Dead initialization 20
Logic error  
Assigned value is garbage or undefined 12
Called function pointer is null (null dereference) 31
Division by zero 4
Function call argument is an uninitialized value 14
Garbage return value 6
Result of operation is garbage or undefined 8
Unix API  
Undefined allocation of 0 bytes 3

Check out the annotated source in the attached tarball with a web browser.

This is how the source was compiled:

touch META
sh autogen.sh
scan-build ./configure --disable-server \
--with-linux=/usr/src/kernels/2.6.32-220.2.1.el6.x86_64 \
--with-linux-obj=/lib/modules/2.6.32-220.2.1.el6.x86_64/build/ \
--with-downstream-release=wc1
mkdir ./lustre-2.1.54-scan-build
scan-build -o ./lustre-2.1.54-scan-build/ \
-disable-checker core.NullDereference \
make -j 24

Comment by Andreas Dilger [ 26/Apr/12 ]

Karsten, thanks for submitting these patches. Sorry I didn't reply to this when it was first posted, as it slipped off my radar. Could you please submit these patches to our Gerrit (code review) git repository? Please see http://wiki.whamcloud.com/display/PUB/Using+Gerrit for details.

This will allow us to review, test, and land the patches to Lustre, and not have them sitting in an attachment here.

Generated at Sat Feb 10 01:11:11 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.