[parted-devel] [PATCH 06/11] libparted: Fix syntax-check sc_avoid_if_before_free error
Brian C. Lane
bcl at redhat.com
Tue Mar 29 00:29:17 BST 2022
It is safe to free even if they are NULL.
---
libparted/arch/linux.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 9b61e32..f3bf14d 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1404,17 +1404,12 @@ init_sdmmc (PedDevice* dev)
if (sdmmc_get_product_info (dev, &type, &name)) {
snprintf (id, sizeof(id) - 1, "%s %s", type, name);
- free (type);
- free (name);
} else {
- // One or the other may have been allocated, free it
- if (type)
- free(type);
- if (name)
- free(name);
snprintf (id, sizeof(id) - 1, "%s",
_("Generic SD/MMC Storage Card"));
}
+ free (type);
+ free (name);
return init_generic(dev, id);
}
--
2.34.1
More information about the parted-devel
mailing list