diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2015-08-17 09:30:49 +0200 |
---|---|---|
committer | Markus Elfring <elfring@users.sourceforge.net> | 2015-08-17 09:30:49 +0200 |
commit | dc4ebc0787a299f064553e6d28a7f35574ce1c2a (patch) | |
tree | 1b939ceaa089de170270b26982088515fbade6d5 /src | |
parent | f00ef7f5d43980e82ed7caa1ac3530b3713cbd76 (diff) |
Bug #944: Deletion of unnecessary checks before calls of the function "free"
The function "free" is documented in the way that no action shall occur for
a passed null pointer. It is therefore not needed that a function caller
repeats a corresponding check.
http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first
This issue was fixed by using the software Coccinelle 1.0.1.
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/journal-file.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-path_id.c | 12 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index f7815b2796..4f94799ce7 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -169,7 +169,7 @@ void journal_file_close(JournalFile *f) { #ifdef HAVE_GCRYPT if (f->fss_file) munmap(f->fss_file, PAGE_ALIGN(f->fss_file_size)); - else if (f->fsprg_state) + else free(f->fsprg_state); free(f->fsprg_seed); diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index aa5cda6fe7..f529ffcf25 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -117,8 +117,7 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, format_lun_number(parent, &lun); path_prepend(path, "fc-%s-%s", port, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(fcdev); return parent; @@ -156,8 +155,7 @@ static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent, format_lun_number(parent, &lun); path_prepend(path, "sas-%s-%s", sas_address, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(sasdev); return parent; @@ -251,8 +249,7 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa else path_prepend(path, "sas-phy%s-%s", phy_id, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(target_sasdev); udev_device_unref(expander_sasdev); @@ -313,8 +310,7 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char ** format_lun_number(parent, &lun); path_prepend(path, "ip-%s:%s-iscsi-%s-%s", addr, port, target, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(sessiondev); udev_device_unref(conndev); |