Do not check `NULL` to call free(): free() accepts `NULL`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 12 Jul 2019 04:05:47 +0000 (00:05 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 12 Jul 2019 18:29:24 +0000 (14:29 -0400)
Semantic patch:

    @@
    expression e;
    @@

    - if (e) { free(e); }
    + free(e);

    @@
    expression e;
    @@

    - if (e != NULL) { free(e); }
    + free(e);

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I4d2d79a8beda4ca1ec7bacd5424c3c8e19d158f0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1698
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/common/common.c
src/plugins/ctf/common/metadata/decoder.c
src/plugins/ctf/fs-src/metadata.c
tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c

index beedec66919b917b5696168cd39dc7632f12472b..d092768a147cf9a18bcabd001229d5966ff5fdfa 100644 (file)
@@ -1115,9 +1115,7 @@ error:
                norm_path = NULL;
        }
 end:
-       if (tmp) {
-               free(tmp);
-       }
+       free(tmp);
        return norm_path;
 }
 #else
index 6215403ca1041dfa5945a09e6d64a75815055e6d..4f4092de55f278bb47ebc654de543c1a541a3c97 100644 (file)
@@ -290,9 +290,7 @@ end:
                }
        }
 
-       if (buf) {
-               free(buf);
-       }
+       free(buf);
 
        return status;
 }
index 63b7f0ed417564b267e724001386b63e10cfd0d0..8a1d98284525358dafbda9afa9b8747d452d1b9a 100644 (file)
@@ -151,9 +151,7 @@ int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata)
 BT_HIDDEN
 void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata)
 {
-       if (metadata->text) {
-               free(metadata->text);
-       }
+       free(metadata->text);
 
        if (metadata->trace_class) {
                BT_TRACE_CLASS_PUT_REF_AND_RESET(metadata->trace_class);
index 38848f2163bbc80fb8bf79a017eadcaea8b83e85..6d29322498fa308114e240c87c2f7c6657df0464 100644 (file)
@@ -167,9 +167,7 @@ void subtest_lookup_function_name(struct bin_info *bin, uint64_t addr,
        ret = bin_info_lookup_function_name(bin, SO_INV_ADDR, &_func_name);
        ok(ret == -1 && _func_name == NULL,
           "bin_info_lookup_function_name - fail on invalid addr");
-       if (_func_name) {
-               free(_func_name);
-       }
+       free(_func_name);
 }
 
 static
This page took 0.027702 seconds and 4 git commands to generate.