From e0cd3345a442700676bcae204c03ff6740541982 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 16 Dec 2022 15:06:54 +0100 Subject: [PATCH] core: don't check if the pointer about to be freed is NULL Unless we dereference it before passing it to free(), we don't need to care whether the pointer is NULL - free() can handle it. Signed-off-by: Bartosz Golaszewski --- lib/chip-info.c | 3 --- lib/edge-event.c | 3 --- lib/line-info.c | 3 --- lib/request-config.c | 3 --- 4 files changed, 12 deletions(-) diff --git a/lib/chip-info.c b/lib/chip-info.c index 584c9d4..ab1512b 100644 --- a/lib/chip-info.c +++ b/lib/chip-info.c @@ -15,9 +15,6 @@ struct gpiod_chip_info { GPIOD_API void gpiod_chip_info_free(struct gpiod_chip_info *info) { - if (!info) - return; - free(info); } diff --git a/lib/edge-event.c b/lib/edge-event.c index fbbe4a8..9d8ae2b 100644 --- a/lib/edge-event.c +++ b/lib/edge-event.c @@ -29,9 +29,6 @@ struct gpiod_edge_event_buffer { GPIOD_API void gpiod_edge_event_free(struct gpiod_edge_event *event) { - if (!event) - return; - free(event); } diff --git a/lib/line-info.c b/lib/line-info.c index 6c2c9ce..620893e 100644 --- a/lib/line-info.c +++ b/lib/line-info.c @@ -24,9 +24,6 @@ struct gpiod_line_info { GPIOD_API void gpiod_line_info_free(struct gpiod_line_info *info) { - if (!info) - return; - free(info); } diff --git a/lib/request-config.c b/lib/request-config.c index 22106e8..62568bb 100644 --- a/lib/request-config.c +++ b/lib/request-config.c @@ -28,9 +28,6 @@ GPIOD_API struct gpiod_request_config *gpiod_request_config_new(void) GPIOD_API void gpiod_request_config_free(struct gpiod_request_config *config) { - if (!config) - return; - free(config); } -- 2.30.2