File 0027-utils-make-N_ELEMENTS-public.patch of Package sssd.30907

From 5c9e60093818d5cdd0720e4286f731c416399be0 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Fri, 15 Feb 2019 09:18:05 +0100
Subject: [PATCH 1/2] utils: make N_ELEMENTS public

The calculation of the size of an array is used in the main code as
well, so it makes sense to move N_ELEMENTS to a common header to use it
more often.

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
(cherry picked from commit e32920a9c7998476b596507762b28fcf81f6a456)
---
 src/tests/common.h | 2 --
 src/util/util.h    | 4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/tests/common.h b/src/tests/common.h
index c06568d38..4fdf44526 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -39,8 +39,6 @@
 #define SSS_ATTRIBUTE_WARN_UNUSED_RESULT
 #endif
 
-#define N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))
-
 extern TALLOC_CTX *global_talloc_context;
 
 void check_leaks_push(TALLOC_CTX *ctx);
diff --git a/src/util/util.h b/src/util/util.h
index 78ab02dce..e1d707304 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -711,4 +711,8 @@ int sss_create_dir(const char *parent_dir_path,
 int selinux_file_context(const char *dst_name);
 int reset_selinux_file_context(void);
 
+#ifndef N_ELEMENTS
+#define N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))
+#endif
+
 #endif /* __SSSD_UTIL_H__ */
-- 
2.22.0

openSUSE Build Service is sponsored by