Whamcloud - gitweb
LU-18141 mdt: don't check for NULL before free'ing 45/56045/2
authorTimothy Day <timday@amazon.com>
Wed, 14 Aug 2024 04:58:56 +0000 (00:58 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 22:08:05 +0000 (22:08 +0000)
The common free'ing macros already check for NULL,
so we don't need to explicitly check this beforehand.

The patch has been generated with the coccinelle script below.

@@
expression E;
@@
- if (E != NULL)
(
  OBD_FREE_PTR(E);
|
  OBD_FREE(E, ...);
|
  LIBCFS_FREE(E, ...);
|
  CFS_FREE_PTR(E);
|
  CFS_FREE_PTR_ARRAY(E, ...);
)

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Id08fd059dbc4fcb3508497bdd04c6b00035ff91e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56045
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_batch.c
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_hsm_cdt_actions.c
lustre/mdt/mdt_hsm_cdt_agent.c
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_lvb.c

index 27b17ef..b7c1dc9 100644 (file)
@@ -371,8 +371,7 @@ out_free:
                OBD_FREE_PTR_ARRAY(update_bufs, update_buf_count);
        }
 
-       if (trd)
-               OBD_FREE_PTR(trd);
+       OBD_FREE_PTR(trd);
 
        if (desc != NULL)
                ptlrpc_free_bulk(desc);
index b7bf445..5794e95 100644 (file)
@@ -1960,8 +1960,7 @@ static int hsm_cancel_all_actions(struct mdt_device *mdt)
        }
        up_read(&cdt->cdt_request_lock);
 
-       if (hal != NULL)
-               OBD_FREE(hal, hal_sz);
+       OBD_FREE(hal, hal_sz);
 
        /* cancel all on-disk records */
        rc = cdt_llog_process(mti->mti_env, mti->mti_mdt, mdt_cancel_all_cb,
index 0e7b51b..5a1d40b 100644 (file)
@@ -476,8 +476,7 @@ static int mdt_get_root(struct tgt_session_info *tsi)
        EXIT;
 out:
        mdt_thread_info_fini(info);
-       if (buffer)
-               OBD_FREE(buffer, PATH_MAX+1);
+       OBD_FREE(buffer, PATH_MAX+1);
        return rc;
 }
 
@@ -5500,8 +5499,7 @@ static int mdt_register_seq_exp(struct mdt_device *mdt)
                GOTO(out_free, rc);
        }
 out_free:
-       if (lwp_name != NULL)
-               OBD_FREE(lwp_name, MAX_OBD_NAME);
+       OBD_FREE(lwp_name, MAX_OBD_NAME);
 
        return rc;
 }
@@ -5750,8 +5748,7 @@ static int mdt_connect_to_next(const struct lu_env *env, struct mdt_device *m,
        }
 
 out:
-       if (data)
-               OBD_FREE_PTR(data);
+       OBD_FREE_PTR(data);
        RETURN(rc);
 }
 
@@ -5897,10 +5894,8 @@ put_profile:
 free_bufs:
        OBD_FREE_PTR(bufs);
 cleanup_mem:
-       if (name)
-               OBD_FREE(name, name_size);
-       if (uuid)
-               OBD_FREE(uuid, uuid_size);
+       OBD_FREE(name, name_size);
+       OBD_FREE(uuid, uuid_size);
        RETURN(rc);
 }
 
@@ -6037,14 +6032,10 @@ lcfg_cleanup:
 put_profile:
        class_put_profile(lprof);
 cleanup_mem:
-       if (bufs)
-               OBD_FREE_PTR(bufs);
-       if (qmtname)
-               OBD_FREE(qmtname, MAX_OBD_NAME);
-       if (uuid)
-               OBD_FREE(uuid, UUID_MAX);
-       if (data)
-               OBD_FREE_PTR(data);
+       OBD_FREE_PTR(bufs);
+       OBD_FREE(qmtname, MAX_OBD_NAME);
+       OBD_FREE(uuid, UUID_MAX);
+       OBD_FREE_PTR(data);
        return rc;
 }
 
@@ -7400,9 +7391,8 @@ static int mdt_destroy_export(struct obd_export *exp)
        ENTRY;
 
        target_destroy_export(exp);
-       if (exp->exp_used_slots)
-               OBD_FREE(exp->exp_used_slots,
-                        BITS_TO_LONGS(OBD_MAX_RIF_MAX) * sizeof(long));
+       OBD_FREE(exp->exp_used_slots,
+                BITS_TO_LONGS(OBD_MAX_RIF_MAX) * sizeof(long));
 
        /* destroy can be called from failed obd_setup, so
         * checking uuid is safer than obd_self_export
index c50ccee..44f6cb7 100644 (file)
@@ -690,8 +690,7 @@ err:
        seq_release(inode, file);
        if (aai && aai->aai_env.le_ses)
                OBD_FREE_PTR(aai->aai_env.le_ses);
-       if (aai)
-               OBD_FREE_PTR(aai);
+       OBD_FREE_PTR(aai);
 out:
        return rc;
 }
index 379730b..d70e5ea 100644 (file)
@@ -137,8 +137,7 @@ out_free:
 
        if (ha != NULL && ha->ha_archive_id != NULL)
                OBD_FREE_PTR_ARRAY(ha->ha_archive_id, ha->ha_archive_cnt);
-       if (ha != NULL)
-               OBD_FREE_PTR(ha);
+       OBD_FREE_PTR(ha);
 out:
        /* wake the coordinator to potentially schedule requests */
        if (rc == -EEXIST || rc == 0)
index e848540..f94fd4c 100644 (file)
@@ -400,8 +400,7 @@ again:
                                   param->idd_uid, param);
 
 out:
-       if (param != NULL)
-               OBD_FREE(param, size);
+       OBD_FREE(param, size);
 
        return rc ? rc : count;
 }
index 729cb8e..cf5e6a9 100644 (file)
@@ -456,8 +456,7 @@ static int mdt_lvbo_free(struct ldlm_resource *res)
        }
 
        /* Data-on-MDT lvbo free */
-       if (res->lr_lvb_data != NULL)
-               OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
+       OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
        return 0;
 }