]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Remove unneeded check
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 16 Aug 2024 21:54:57 +0000 (23:54 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sat, 17 Aug 2024 17:14:16 +0000 (12:14 -0500)
Calling free(NULL) is valid. No need for previous if-check.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/79
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 8ba8ee406778bcac5be4a3178100caa0deb2ddca..03fcff333fdfc2ecf885f1358fa1030eb5779a22 100644 (file)
@@ -2934,8 +2934,7 @@ static int do_depmod(int argc, char *argv[])
                        maybe_all = 1;
                        break;
                case 'b':
-                       if (root)
-                               free(root);
+                       free(root);
                        root = path_make_absolute_cwd(optarg);
                        if (root == NULL) {
                                ERR("invalid image path %s\n", optarg);
@@ -2943,8 +2942,7 @@ static int do_depmod(int argc, char *argv[])
                        }
                        break;
                case 'o':
-                       if (out_root)
-                               free(out_root);
+                       free(out_root);
                        out_root = path_make_absolute_cwd(optarg);
                        if (out_root == NULL) {
                                ERR("invalid output directory %s\n", optarg);