Skip to contentSkip to conversation

conntrackd: fix compiler warnings

PATCH Applied Florian Westphal 2 participants 4 messages Jun 3, 2013 – Jun 5, 2013 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/2 conntrackd: fix compiler warnings

main.c:359:6: warning: ignoring return value of 'nice' [..] main.c:395:7: warning: ignoring return value of 'chdir' [..] run.c:43:17: warning: declaration of 'signal' shadows a global declaration

---
 src/main.c |   22 ++++++++++++++++++++--
 src/run.c  |    4 ++--
 2 files changed, 22 insertions(+), 4 deletions(-)
src/main.c +20 -2
index 831a3c2..dafeaee 100644
@@ -23,6 +23,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <sys/utsname.h>
 #include <string.h>
@@ -112,6 +113,23 @@ set_action_by_table(int i, int argc, char *argv[],
 	return i;
 }
 
+static void
+set_nice_value(int nv)
+{
+	errno = 0;
+	if (nice(nv) == -1 && errno) /* warn only */
+		fprintf(stderr, "Cannot set nice level %d: %s\n",
+			nv, strerror(errno));
+}
+
+static void
+do_chdir(const char *d)
+{
+	if (chdir(d))
+		fprintf(stderr, "Cannot change current directory to %s: %s\n",
+			d, strerror(errno));
+}
+
 int main(int argc, char *argv[])
 {
 	int ret, i, action = -1;
@@ -356,7 +374,7 @@ int main(int argc, char *argv[])
 	/*
 	 * Setting process priority and scheduler
 	 */
-	nice(CONFIG(nice));
+	set_nice_value(CONFIG(nice));
 
 	if (CONFIG(sched).type != SCHED_OTHER) {
 		struct sched_param schedparam = {
@@ -382,7 +400,7 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	chdir("/");
+	do_chdir("/");
 	close(STDIN_FILENO);
 
 	/* Daemonize conntrackd */
src/run.c +2 -2
index 44a179f..7fa6889 100644
@@ -40,14 +40,14 @@
 #include <time.h>
 #include <fcntl.h>
 
-void killer(int signal)
+void killer(int signo)
 {
 	/* Signals are re-entrant, disable signal handling to avoid problems
 	 * in case we receive SIGINT and SIGTERM in a row. This function is
 	 * also called via -k from the unix socket context, we already disabled
 	 * signals in that path, so don't do it.
 	 */
-	if (signal)
+	if (signo)
 		sigprocmask(SIG_BLOCK, &STATE(block), NULL);
 
 	local_server_destroy(&STATE(local));
Signature · 1 line
1.7.8.6
author maintainer
#1 lore raw

PATCH 2/2 include: kill unused PLD_* macros

---
 include/network.h |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)
include/network.h +0 -12
index 41c35af..79745f3 100644
@@ -173,18 +173,6 @@ static inline int between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
 	return seq3 - seq2 >= seq1 - seq2;
 }
 
-#define PLD_NETWORK2HOST(x)						 \
-({									 \
-	x->len = ntohs(x->len);						 \
-	x->query = ntohs(x->query);					 \
-})
-
-#define PLD_HOST2NETWORK(x)						 \
-({									 \
-	x->len = htons(x->len);						 \
-	x->query = htons(x->query);					 \
-})
-
 struct netattr {
 	uint16_t nta_len;
 	uint16_t nta_attr;
Signature · 1 line
1.7.8.6
maintainer Applied
#3 lore raw
In reply to Florian Westphal
Quoted 3 lines · Florian Westphal

main.c:359:6: warning: ignoring return value of 'nice' [..] main.c:395:7: warning: ignoring return value of 'chdir' [..] run.c:43:17: warning: declaration of 'signal' shadows a global declaration

Applied, thanks.