lib, criu: remove unnecessary NULL checks before free()

free(NULL) is a no-op per the C standard (C99 7.20.3.2), so
guarding free() calls with NULL checks is unnecessary.

Assisted-by: Claude Code (claude-opus-4-6)
Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2026-07-10 09:02:26 +00:00 committed by Radostin Stoyanov
parent c4d525b695
commit 74cbf9e2e7
2 changed files with 7 additions and 14 deletions

View file

@ -1758,7 +1758,6 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
}
}
end:
if (fsname)
free(fsname);
if (new)

View file

@ -1100,7 +1100,6 @@ int criu_local_add_irmap_path(criu_opts *opts, const char *path)
return 0;
err:
if (my_path)
free(my_path);
return -ENOMEM;
@ -1250,7 +1249,6 @@ int criu_local_add_external(criu_opts *opts, const char *key)
opts->rpc->n_external = nr;
return 0;
err:
if (e)
free(e);
return -ENOMEM;
}
@ -2037,13 +2035,9 @@ int criu_local_join_ns_add(criu_opts *opts, const char *ns, const char *ns_file,
return 0;
err:
if (_ns)
free(_ns);
if (_ns_file)
free(_ns_file);
if (_extra_opt)
free(_extra_opt);
if (join_ns)
free(join_ns);
return -1;
}