From 08348f1b72de27681549894f7a506674fba19ff2 Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Wed, 20 Feb 2019 14:56:37 +0300 Subject: [PATCH] Refactor free_n() function Make the argument to free_n() compatible with any pointers, thus reducing the number of compilation warnings. End-user-impact: None Signed-off-by: Alexander Amelkin --- include/ipmitool/helper.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/ipmitool/helper.h b/include/ipmitool/helper.h index ad746e7..237eb31 100644 --- a/include/ipmitool/helper.h +++ b/include/ipmitool/helper.h @@ -37,6 +37,7 @@ #include #include #include +#include /* For free() */ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -123,10 +124,12 @@ uint16_t ipmi_get_oem_id(struct ipmi_intf *intf); * Free the memory and clear the pointer. * @param[in] ptr - a pointer to your pointer to free. */ -static inline void free_n(void **ptr) { - if (ptr && *ptr) { - free(*ptr); - *ptr = NULL; +static inline void free_n(void *ptr) { + void **pptr = (void **)ptr; + + if (pptr && *pptr) { + free(*pptr); + *pptr = NULL; } }