From 19c9d1bafda1ff7eb75a96b4eebc5b8544f06137 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 21 Feb 2017 11:32:47 +0100 Subject: [PATCH] ifcfg: add nm_auto_shvar_file_close cleanup macro --- src/settings/plugins/ifcfg-rh/shvar.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index a6498fcea2..3b35e30d1f 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -87,4 +87,16 @@ void svCloseFile (shvarFile *s); const char *svEscape (const char *s, char **to_free); const char *svUnescape (const char *s, char **to_free); +static inline void +_nm_auto_shvar_file_close (shvarFile **p_s) +{ + if (*p_s) { + int errsv = errno; + + svCloseFile (*p_s); + errno = errsv; + } +} +#define nm_auto_shvar_file_close nm_auto(_nm_auto_shvar_file_close) + #endif /* _SHVAR_H */