Cleanup struct zed_conf vars in zed_conf_destroy
Reset struct zed_conf file descriptors to -1 after close(), and pointers to NULL after free(). Signed-off-by: Chris Dunlap <cdunlap@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #2756
This commit is contained in:
parent
56697c4264
commit
8ac9b5e6b5
|
@ -99,6 +99,7 @@ zed_conf_destroy(struct zed_conf *zcp)
|
||||||
zed_log_msg(LOG_WARNING,
|
zed_log_msg(LOG_WARNING,
|
||||||
"Failed to close state file \"%s\": %s",
|
"Failed to close state file \"%s\": %s",
|
||||||
zcp->state_file, strerror(errno));
|
zcp->state_file, strerror(errno));
|
||||||
|
zcp->state_fd = -1;
|
||||||
}
|
}
|
||||||
if (zcp->pid_file) {
|
if (zcp->pid_file) {
|
||||||
if ((unlink(zcp->pid_file) < 0) && (errno != ENOENT))
|
if ((unlink(zcp->pid_file) < 0) && (errno != ENOENT))
|
||||||
|
@ -113,21 +114,26 @@ zed_conf_destroy(struct zed_conf *zcp)
|
||||||
zcp->pid_file, strerror(errno));
|
zcp->pid_file, strerror(errno));
|
||||||
zcp->pid_fd = -1;
|
zcp->pid_fd = -1;
|
||||||
}
|
}
|
||||||
if (zcp->conf_file)
|
if (zcp->conf_file) {
|
||||||
free(zcp->conf_file);
|
free(zcp->conf_file);
|
||||||
|
zcp->conf_file = NULL;
|
||||||
if (zcp->pid_file)
|
}
|
||||||
|
if (zcp->pid_file) {
|
||||||
free(zcp->pid_file);
|
free(zcp->pid_file);
|
||||||
|
zcp->pid_file = NULL;
|
||||||
if (zcp->zedlet_dir)
|
}
|
||||||
|
if (zcp->zedlet_dir) {
|
||||||
free(zcp->zedlet_dir);
|
free(zcp->zedlet_dir);
|
||||||
|
zcp->zedlet_dir = NULL;
|
||||||
if (zcp->state_file)
|
}
|
||||||
|
if (zcp->state_file) {
|
||||||
free(zcp->state_file);
|
free(zcp->state_file);
|
||||||
|
zcp->state_file = NULL;
|
||||||
if (zcp->zedlets)
|
}
|
||||||
|
if (zcp->zedlets) {
|
||||||
zed_strings_destroy(zcp->zedlets);
|
zed_strings_destroy(zcp->zedlets);
|
||||||
|
zcp->zedlets = NULL;
|
||||||
|
}
|
||||||
free(zcp);
|
free(zcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue