LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0002-fix-the-compile-error-for-GCC-8.1.patch of Package nextepc (Project home:mnhauke:nextepc)

From 8f9219bef0d43ebe13f0c56115377ed40233d772 Mon Sep 17 00:00:00 2001
From: Sukchan Lee <acetcom@gmail.com>
Date: Sat, 23 Jun 2018 12:59:40 +0000
Subject: [PATCH 2/3] fix the compile error for GCC 8.1

---
 lib/core/src/debug.c      | 10 ++++++----
 lib/core/src/unix/tun.c   |  4 ++--
 lib/core/test/Makefile.am |  2 +-
 lib/core/test/testtime.c  |  2 +-
 lib/ipfw/dummynet.c       |  4 ++++
 test/volte/testutil.c     |  2 +-
 6 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/lib/core/src/debug.c b/lib/core/src/debug.c
index 657fe6c0..7656a86d 100644
--- a/lib/core/src/debug.c
+++ b/lib/core/src/debug.c
@@ -472,7 +472,7 @@ void d_trace_off(int *mod_name)
 
 int d_msg(int tp, int lv, c_time_t t, char *fn, int ln, char *fmt, ...)
 {
-    char str[HUGE_STRING_LEN] = {0}, fstr[HUGE_STRING_LEN] = {0}, *ac_str;
+    char str[HUGE_STRING_LEN+1] = {0}, fstr[HUGE_STRING_LEN+1] = {0}, *ac_str;
     time_exp_t te;
     size_t n;
     char *lv_str[5] = {"NONE", "FATL", "ERRR", "WARN", "INFO"};
@@ -525,7 +525,7 @@ int d_msg(int tp, int lv, c_time_t t, char *fn, int ln, char *fmt, ...)
         {
             vsprintf(str, fmt, args);
 
-            n = sprintf(fstr, "["TIME_FMT_STR"] %s",
+            n = snprintf(fstr, HUGE_STRING_LEN, "["TIME_FMT_STR"] %s",
                     te.tm_mon + 1, te.tm_mday, te.tm_hour,
                     te.tm_min, te.tm_sec, te.tm_usec/1000, str);
 
@@ -570,7 +570,8 @@ int d_msg(int tp, int lv, c_time_t t, char *fn, int ln, char *fmt, ...)
 
             vsprintf(str, fmt, args);
 
-            n = sprintf(fstr, "["TIME_FMT_STR"] %s: %s (%s:%d)",
+            n = snprintf(fstr, HUGE_STRING_LEN,
+                    "["TIME_FMT_STR"] %s: %s (%s:%d)",
                     te.tm_mon + 1, te.tm_mday, te.tm_hour,
                     te.tm_min, te.tm_sec, te.tm_usec/1000,
                     lv_str[lv], str, fn, ln);
@@ -612,7 +613,8 @@ int d_msg(int tp, int lv, c_time_t t, char *fn, int ln, char *fmt, ...)
         {
             vsprintf(str, fmt, args);
 
-            n = sprintf(fstr, "[" TIME_FMT_STR "] ASSERT: %s (%s:%d)",
+            n = snprintf(fstr, HUGE_STRING_LEN,
+                    "[" TIME_FMT_STR "] ASSERT: %s (%s:%d)",
                     te.tm_mon + 1, te.tm_mday, te.tm_hour,
                     te.tm_min, te.tm_sec, te.tm_usec/1000, str, fn, ln);
 
diff --git a/lib/core/src/unix/tun.c b/lib/core/src/unix/tun.c
index 371e1051..1577b646 100644
--- a/lib/core/src/unix/tun.c
+++ b/lib/core/src/unix/tun.c
@@ -57,13 +57,13 @@ status_t tun_open(sock_id *new, char *ifname, int is_tap)
     /* Save socket descriptor */
     sock->fd = fd;
     /* Save the interface name */
-    strncpy(sock->ifname, ifname, IFNAMSIZ);
+    strncpy(sock->ifname, ifname, IFNAMSIZ-1);
 
 #if LINUX == 1
     memset(&ifr, 0, sizeof(ifr));
 
     ifr.ifr_flags = (is_tap ? (flags | IFF_TAP) : (flags | IFF_TUN));
-    strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+    strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
 
     rc = ioctl(sock->fd, TUNSETIFF, (void *)&ifr);
     if (rc < 0)
diff --git a/lib/core/test/Makefile.am b/lib/core/test/Makefile.am
index 2becf890..8bf48ec8 100644
--- a/lib/core/test/Makefile.am
+++ b/lib/core/test/Makefile.am
@@ -21,7 +21,7 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = \
 	-Wall -Werror @OSCPPFLAGS@ \
-	-Wno-unused-function -Wno-unused-variable
+	-Wno-unused-function -Wno-unused-variable -Wno-restrict
 
 TESTS = testcore
 
diff --git a/lib/core/test/testtime.c b/lib/core/test/testtime.c
index 46bbf490..d5049c04 100644
--- a/lib/core/test/testtime.c
+++ b/lib/core/test/testtime.c
@@ -1,7 +1,7 @@
 #include "core_time.h"
 #include "testutil.h"
 
-#define STR_SIZE 45
+#define STR_SIZE 100
 
 /* The time value is used throughout the tests, so just make this a global.
  * Also, we need a single value that we can test for the positive tests, so
diff --git a/lib/ipfw/dummynet.c b/lib/ipfw/dummynet.c
index 19383079..f3136750 100644
--- a/lib/ipfw/dummynet.c
+++ b/lib/ipfw/dummynet.c
@@ -245,7 +245,11 @@ print_flowset_parms(struct dn_fs *fs, char *prefix)
 		    fs->max_th,
 		    1.0 * fs->max_p / (double)(1 << SCALE_RED));
 		if (fs->flags & DN_IS_ECN)
+#if 0 /* modifed by acetcom */
 			strncat(red, " (ecn)", 6);
+#else
+			strcat(red, " (ecn)");
+#endif
 	} else
 		sprintf(red, "droptail");
 
diff --git a/test/volte/testutil.c b/test/volte/testutil.c
index c8ad9776..230320c1 100644
--- a/test/volte/testutil.c
+++ b/test/volte/testutil.c
@@ -60,7 +60,7 @@ void test_terminate(void)
 status_t test_initialize(int argc, const char *const argv[], char *config_path)
 {
     status_t rv;
-    char dir[C_PATH_MAX];
+    char dir[C_PATH_MAX/2];
     char conf[C_PATH_MAX];
 
     if (config_path)
-- 
2.13.7