diff mbox series

[1/2] useful: Move close cleanup into ell/util.h

Message ID 20240201151751.880279-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/2] useful: Move close cleanup into ell/util.h | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Denis Kenzior Feb. 1, 2024, 3:17 p.m. UTC
---
 ell/useful.h | 14 --------------
 ell/util.h   | 11 +++++++++++
 2 files changed, 11 insertions(+), 14 deletions(-)

Comments

Denis Kenzior Feb. 1, 2024, 4:07 p.m. UTC | #1
On 2/1/24 09:17, Denis Kenzior wrote:
> ---
>   ell/useful.h | 14 --------------
>   ell/util.h   | 11 +++++++++++
>   2 files changed, 11 insertions(+), 14 deletions(-)
> 

Both applied.
diff mbox series

Patch

diff --git a/ell/useful.h b/ell/useful.h
index 5a4a5eba091c..8a4bf2ce70c9 100644
--- a/ell/useful.h
+++ b/ell/useful.h
@@ -5,11 +5,6 @@ 
  * SPDX-License-Identifier: LGPL-2.1-or-later
  */
 
-#include <unistd.h>
-#include <errno.h>
-
-#include <ell/util.h>
-
 #define align_len(len, boundary) (((len)+(boundary)-1) & ~((boundary)-1))
 
 #define likely(x)   __builtin_expect(!!(x), 1)
@@ -70,15 +65,6 @@  static inline unsigned char bit_field(const unsigned char oct,
 #define _auto_(func)					\
 	__AUTODESTRUCT(func)
 
-/* Enables declaring _auto_(close) int fd = <-1 or L_TFR(open(...))>; */
-inline __attribute__((always_inline)) void close_cleanup(void *p)
-{
-	int fd = *(int *) p;
-
-	if (fd >= 0)
-		L_TFR(close(fd));
-}
-
 /*
  * Trick the compiler into thinking that var might be changed somehow by
  * the asm
diff --git a/ell/util.h b/ell/util.h
index 5dfc35c89ea6..db86bfe278ea 100644
--- a/ell/util.h
+++ b/ell/util.h
@@ -14,6 +14,8 @@ 
 #include <inttypes.h>
 #include <endian.h>
 #include <byteswap.h>
+#include <unistd.h>
+#include <errno.h>
 #include <sys/uio.h>
 #include <ell/cleanup.h>
 
@@ -314,6 +316,15 @@  const char *l_util_get_debugfs_path(void);
        while (__result == -1L && errno == EINTR);  \
        __result; }))
 
+/* Enables declaring _auto_(close) int fd = <-1 or L_TFR(open(...))>; */
+inline __attribute__((always_inline)) void close_cleanup(void *p)
+{
+	int fd = *(int *) p;
+
+	if (fd >= 0)
+		L_TFR(close(fd));
+}
+
 #define _L_IN_SET_CMP(val, type, cmp, ...) __extension__ ({		\
 		const type __v = (val);					\
 		const typeof(__v) __elems[] = {__VA_ARGS__};		\