Parcourir la source

[1954] Do not suppress errors, suppress warnings for perfdhcp.cc

Marcin Siodelski il y a 13 ans
Parent
commit
190b91b070
2 fichiers modifiés avec 17 ajouts et 7 suppressions
  1. 8 2
      tests/tools/perfdhcp/Makefile.am
  2. 9 5
      tests/tools/perfdhcp/perfdhcp.cc

+ 8 - 2
tests/tools/perfdhcp/Makefile.am

@@ -12,10 +12,16 @@ if USE_STATIC_LINK
 AM_LDFLAGS += -static
 endif
 
-# We have to suppress errors because we are compiling C code with CXX
+# We have to suppress warnings because we are compiling C code with CXX
 # We have to do this to link with new C++ pieces of code
 perfdhcp_CXXFLAGS = $(AM_CXXFLAGS)
-perfdhcp_CXXFLAGS += -Wno-error -Wno-writestrings
+if USE_CLANGPP
+perfdhcp_CXXFLAGS += -Wno-deprecated-writable-strings
+else
+if USE_GXX
+perfdhcp_CXXFLAGS += -Wno-write-strings
+endif
+endif
 
 pkglibexec_PROGRAMS  = perfdhcp
 perfdhcp_SOURCES  = perfdhcp.cc

+ 9 - 5
tests/tools/perfdhcp/perfdhcp.cc

@@ -42,8 +42,10 @@ main(const int argc, char* const argv[])
 #define __STDC_LIMIT_MACROS
 
 #ifdef __linux__
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#endif
 
 #include <sys/types.h>
 #include <sys/select.h>
@@ -1959,7 +1961,7 @@ decodebase(void)
 	fprintf(stderr, "not yet supported base '%s'\n", b0);
 	exit(2);
 }
-			   
+
 /*
  * get the server socket address from the command line:
  *  - flags: inherited from main, 0 or AI_NUMERICHOST (for literals)
@@ -2219,8 +2221,8 @@ void
 reapchild(int sig)
 {
 	int status;
-
-	sig = sig;
+	int s = sig;
+    s = 1;
 	while (wait3(&status, WNOHANG, NULL) > 0)
 		/* continue */;
 }
@@ -2232,8 +2234,10 @@ reapchild(int sig)
 void
 interrupt(int sig)
 {
-	sig = sig;
-	interrupted = 1;
+    // Do something to avoid unused-variable warning
+	int s = sig;
+    s = 1;
+	interrupted = s;
 }
 
 /*