[Tarantool-patches] [PATCH] build: suppress the warning for GCC >= 8

Chris Sosnin k.sosnin at tarantool.org
Mon Nov 25 00:12:19 MSK 2019


As it is mentioned in #4515, strncpy() warning needs
to be suppressed so it does not fail the build with
-DENABLE_WERROR=ON.
Closes: #4515
---
src/systemd.c | 2 ++
src/systemd.h | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/src/systemd.c b/src/systemd.c
index 6686c3ce0..8e81b274c 100644
--- a/src/systemd.c
+++ b/src/systemd.c
@@ -117,7 +117,9 @@ int systemd_notify(const char *message) {
.sun_family = AF_UNIX,
};

+ WSTRINGOP_TRUNC_OFF
strncpy(sa.sun_path, sd_unix_path, sizeof(sa.sun_path));
+ WSTRINGOP_TRUNC_ON
if (sa.sun_path[0] == '@')
sa.sun_path[0] = '\0';

diff --git a/src/systemd.h b/src/systemd.h
index 861a9af35..854405847 100644
--- a/src/systemd.h
+++ b/src/systemd.h
@@ -107,4 +107,17 @@ systemd_snotify(const char *format, ...);
} /* extern "C" */
#endif /* defined(__cplusplus) */

+#ifdef __GNUC__
+#if __GNUC__ >= 8
+#define WSTRINGOP_TRUNC_OFF \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wstringop-truncation\"")
+#define WSTRINGOP_TRUNC_ON \
+ _Pragma ("GCC diagnostic pop")
+#endif
+#else
+#define WSTRINGOP_TRUNC_OFF
+#define WSTRINGOP_TRUNC_ON
+#endif
+
#endif /* TARANTOOL_SYSTEMD_H_INCLUDED */
-- 
2.24.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20191125/502d07b8/attachment.html>


More information about the Tarantool-patches mailing list