Whamcloud - gitweb
LU-17000 libcfs: quiet Coverity LIBCFS_ALLOC warning 08/57408/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 12 Dec 2024 23:14:36 +0000 (16:14 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:53:09 +0000 (20:53 +0000)
commit3a663e37c2944b24fa643764d8d9811af0d2453c
treecf2fcf03ad00fe05fed42dabf155622e1372b700
parenta2b5118f2a6fa17aaeb3ec0554b6ea8a3ad62ddd
LU-17000 libcfs: quiet Coverity LIBCFS_ALLOC warning

Coverity has a frequent but harmeless warning in LIBCFS_ALLOC_PRE():

    logical_vs_bitwise: The expression
        cptab->ctb_nparts * 4UL /* sizeof (*part->cpt_distance) */ <=
(8192UL /* 2 << 12 */) && 1
  /* ((gfp_t)(0x200000U | 0x400000U) | (gfp_t)64U) &
     (((gfp_t)32U | (gfp_t)524288U) | (gfp_t)4194304U) */
    is suspicious because it performs a Boolean operation on a
    constant other than 0 or 1.

Fix by comparing GFP mask to zero, rather than the whole expression.

There are many similar CIDs, only listing a couple for reference.

Add a Git commit-msg hook check for CoverityID: in commit messages,
and test cases for the same.

Test-Parameters: trivial
CoverityID: 397137 ("Logical vs. bitwise operator")
CoverityID: 397837 ("Logical vs. bitwise operator")
Fixes: 3a92c850b0 ("LU-56 libcfs: NUMA allocator and code cleanup")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I4691d9611f752b8a58f3ed1d5e0830b24da39648
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57408
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
contrib/git-hooks/commit-msg
contrib/git-hooks/tests/commit.badcoverityid [new file with mode: 0644]
contrib/git-hooks/tests/commit.badcoveritytype [new file with mode: 0644]
contrib/git-hooks/tests/commit.ok_coverity [new file with mode: 0644]
libcfs/include/libcfs/libcfs_private.h