Skip to contentSkip to conversation

syscall/prctl.c: Fix unused variable build error with USE_SECCOMP=0.

PATCH In review Vinson Lee 2 participants 3 messages Dec 4, 2013

lore
Share & tools
lore

Vinson Lee

author
#0 lore raw

PATCH 1/1 syscall/prctl.c: Fix unused variable build error with USE_SECCOMP=0.

From: Vinson Lee <[email protected]>

This patch fixes this build error on CentOS 6.

CC syscalls/prctl.o
cc1: warnings being treated as errors syscalls/prctl.c: In function ‘sanitise_prctl’:
syscalls/prctl.c:36: error: unused variable ‘saddr’

---
 syscalls/prctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
syscalls/prctl.c +2 -0
index acca027..bde76aa 100644
@@ -33,7 +33,9 @@ static int prctl_opts[NR_PRCTL_OPTS] = {
 void sanitise_prctl(int childno)
 {
 	int option = prctl_opts[rand() % NR_PRCTL_OPTS];
+#ifdef USE_SECCOMP
 	struct sockaddr *saddr = NULL;
+#endif
 
 // For now, just do SECCOMP, the other options need some attention.
 option = PR_SET_SECCOMP;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 10 lines · Vinson Lee

From: Vinson Lee <[email protected]>

This patch fixes this build error on CentOS 6.

CC syscalls/prctl.o
cc1: warnings being treated as errors syscalls/prctl.c: In function ‘sanitise_prctl’:
syscalls/prctl.c:36: error: unused variable ‘saddr’

bigger diff, but I think this looks cleaner..
Can you test ?

syscalls/prctl.c +23 -14
index acca0279acab..09364df6a37a 100644
@@ -17,6 +17,7 @@
 #include "maps.h"
 #include "shm.h"
 #include "compat.h"
+#include "trinity.h"
 
 #define NR_PRCTL_OPTS 28
 static int prctl_opts[NR_PRCTL_OPTS] = {
@@ -29,31 +30,39 @@ static int prctl_opts[NR_PRCTL_OPTS] = {
 	PR_MCE_KILL, PR_MCE_KILL_GET,
 };
 
+
+#ifdef USE_SECCOMP
+static void do_set_seccomp(int childno)
+{
+	struct sockaddr *saddr = NULL;
+
+//	if (rand() % 3 == SECCOMP_MODE_FILTER) {
+
+// FIXME: This leaks memory, but needs to be cleared after the syscall is done.
+		gen_seccomp_bpf((unsigned long **) &saddr, NULL);
+		shm->a2[childno] = SECCOMP_MODE_FILTER;
+		shm->a3[childno] = (unsigned long) saddr;
+//	}
+}
+#else
+static void do_set_seccomp(__unused__ int childno) { }
+#endif
+
 /* We already got a generic_sanitise at this point */
 void sanitise_prctl(int childno)
 {
 	int option = prctl_opts[rand() % NR_PRCTL_OPTS];
-	struct sockaddr *saddr = NULL;
 
 // For now, just do SECCOMP, the other options need some attention.
-option = PR_SET_SECCOMP;
+	option = PR_SET_SECCOMP;
 
-	/* Also allow crap by small chance */
-	if (rand() % 100 != 0)
-		shm->a1[childno] = option;
+	shm->a1[childno] = option;
 
 	switch (option) {
 	case PR_SET_SECCOMP:
-#ifdef USE_SECCOMP
-//		if (rand() % 3 == SECCOMP_MODE_FILTER) {
-// FIXME: This leaks memory, but needs to be cleared
-// after the syscall is done.
-			gen_seccomp_bpf((unsigned long **) &saddr, NULL);
-			shm->a2[childno] = SECCOMP_MODE_FILTER;
-			shm->a3[childno] = (unsigned long) saddr;
-//		}
-#endif
+		do_set_seccomp(childno);
 		break;
+
 	default:
 		break;
 	}
author Tested-by
#2 lore raw
Quoted 72 lines · Dave Jones
Quoted 10 lines · Vinson Lee

From: Vinson Lee <[email protected]>

This patch fixes this build error on CentOS 6.

CC syscalls/prctl.o
cc1: warnings being treated as errors syscalls/prctl.c: In function ‘sanitise_prctl’:
syscalls/prctl.c:36: error: unused variable ‘saddr’

bigger diff, but I think this looks cleaner..
Can you test ?

syscalls/prctl.c +21 -10
index acca0279acab..09364df6a37a 100644
@@ -17,6 +17,7 @@
 #include "maps.h"
 #include "shm.h"
 #include "compat.h"
+#include "trinity.h"
 
 #define NR_PRCTL_OPTS 28
 static int prctl_opts[NR_PRCTL_OPTS] = {
@@ -29,31 +30,39 @@ static int prctl_opts[NR_PRCTL_OPTS] = {
        PR_MCE_KILL, PR_MCE_KILL_GET,
 };
 
+
+#ifdef USE_SECCOMP
+static void do_set_seccomp(int childno)
+{
+       struct sockaddr *saddr = NULL;
+
+//     if (rand() % 3 == SECCOMP_MODE_FILTER) {
+
+// FIXME: This leaks memory, but needs to be cleared after the syscall is done.
+               gen_seccomp_bpf((unsigned long **) &saddr, NULL);
+               shm->a2[childno] = SECCOMP_MODE_FILTER;
+               shm->a3[childno] = (unsigned long) saddr;
+//     }
+}
+#else
+static void do_set_seccomp(__unused__ int childno) { }
+#endif
+
 /* We already got a generic_sanitise at this point */
 void sanitise_prctl(int childno)
 {
        int option = prctl_opts[rand() % NR_PRCTL_OPTS];
-       struct sockaddr *saddr = NULL;
 
 // For now, just do SECCOMP, the other options need some attention.
-option = PR_SET_SECCOMP;
+       option = PR_SET_SECCOMP;
 
-       /* Also allow crap by small chance */
-       if (rand() % 100 != 0)
-               shm->a1[childno] = option;
+       shm->a1[childno] = option;
 
        switch (option) {
        case PR_SET_SECCOMP:
-#ifdef USE_SECCOMP
-//             if (rand() % 3 == SECCOMP_MODE_FILTER) {
-// FIXME: This leaks memory, but needs to be cleared
-// after the syscall is done.
-                       gen_seccomp_bpf((unsigned long **) &saddr, NULL);

syscalls/prctl.c static int prctl_opts[NR_PRCTL_OPTS] = { · line 68

Quoted 10 lines
syscalls/prctl.c +2 -4
-                       shm->a2[childno] = SECCOMP_MODE_FILTER;
-                       shm->a3[childno] = (unsigned long) saddr;
-//             }
-#endif
+               do_set_seccomp(childno);
                break;
+
        default:
                break;
        }

I confirm that this diff also fixes the CentOS 6 build error.