ubuntu-buildroot/package/liboping/0004-Fix-compile-error-on-G...

33 lines
1.0 KiB
Diff

From 3d685bdb1a6c655bce6d36cfd96e084be07cd2b1 Mon Sep 17 00:00:00 2001
From: Maurice Smulders <Maurice.Smulders@windtalker.com>
Date: Tue, 4 Jan 2022 12:49:36 -0700
Subject: [PATCH] Fix compile error on GCC < 7
[Retrieved from:
https://github.com/octo/liboping/pull/64/commits/3d685bdb1a6c655bce6d36cfd96e084be07cd2b1]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
src/liboping.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/liboping.c b/src/liboping.c
index 9fd8f53..1ccf609 100644
--- a/src/liboping.c
+++ b/src/liboping.c
@@ -203,11 +203,15 @@ static char *sstrerror (int errnum, char *buf, size_t buflen)
static void ping_set_error (pingobj_t *obj, const char *function,
const char *message)
{
+#if __GNUC__ >= 7
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
snprintf (obj->errmsg, sizeof (obj->errmsg),
"%s: %s", function, message);
+#if __GNUC__ >= 7
#pragma GCC diagnostic pop
+#endif
obj->errmsg[sizeof (obj->errmsg) - 1] = 0;
}