Whamcloud - gitweb
LU-17000 misc: fix strscpy() Coverity warnings 65/54865/6
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Mon, 22 Apr 2024 09:25:50 +0000 (14:55 +0530)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 May 2024 18:40:22 +0000 (18:40 +0000)
Fix warning reported for use of uninitialized vairable

CoverityID: 425254 ("Uninitialized scalar variable")

Fix warning reported when changing call from strlcpy()
to strscpy()

CoverityID: 425253 ("Unsigned compared against 0")
CoverityID: 425262 ("Unsigned compared against 0")
Fixes: 7a0517fa2 ("LU-17592 build: kernel 6.8 removed strlcpy()")

Test-Parameters: trivial
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Id3804c77a105e4776a0242db787dc1ca2528d9ca
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54865
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/kunit/llog_test.c
lustre/lod/lod_lov.c
lustre/lov/lov_ea.c

index 9936924..5603cfa 100644 (file)
@@ -754,7 +754,7 @@ static int llog_cancel_rec_cb(const struct lu_env *env,
 static int llog_test_5(const struct lu_env *env, struct obd_device *obd)
 {
        struct llog_handle *llh = NULL;
-       char name[10];
+       char name[10] = "";
        int rc, rc2;
        struct llog_mini_rec lmr;
        struct llog_ctxt *ctxt;
index fd0163b..b68f5b2 100644 (file)
@@ -781,9 +781,10 @@ static int lod_gen_component_ea(const struct lu_env *env,
                objs = &lmm->lmm_objects[0];
        } else {
                struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *)lmm;
-               size_t cplen = strscpy(v3->lmm_pool_name,
+               ssize_t cplen = strscpy(v3->lmm_pool_name,
                                       lod_comp->llc_pool ? : "\0",
                                       sizeof(v3->lmm_pool_name));
+
                if (cplen < 0)
                        RETURN(cplen);
                objs = &v3->lmm_objects[0];
index d572e47..44dad1d 100644 (file)
@@ -239,7 +239,7 @@ lsme_unpack(struct lov_obd *lov, struct lov_mds_md *lmm, size_t buf_size,
        lsme->lsme_layout_gen = le16_to_cpu(lmm->lmm_layout_gen);
 
        if (pool_name) {
-               size_t pool_name_len;
+               ssize_t pool_name_len;
 
                pool_name_len = strscpy(lsme->lsme_pool_name, pool_name,
                                        sizeof(lsme->lsme_pool_name));