Browse Source

filter_seccomp: simplify check_seccomp_filter_properties

* filter_seccomp.c (check_seccomp_filter_properties): Simplify slightly
by removing a redundant "if" expression.
Dmitry V. Levin 1 month ago
parent
commit
e5ab8be28b
1 changed files with 21 additions and 21 deletions
  1. 21
    21
      filter_seccomp.c

+ 21
- 21
filter_seccomp.c View File

@@ -601,31 +601,31 @@ check_seccomp_filter_properties(void)
601 601
 {
602 602
 	int rc = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
603 603
 	seccomp_filtering = rc < 0 && errno != EINVAL;
604
-	if (!seccomp_filtering)
604
+	if (!seccomp_filtering) {
605 605
 		debug_func_perror_msg("prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER)");
606
+		return;
607
+	}
606 608
 
607
-	if (seccomp_filtering) {
608
-		for (unsigned int i = 0; i < ARRAY_SIZE(filter_generators);
609
-		     ++i) {
610
-			bool overflow = false;
611
-			unsigned short len = filter_generators[i](filters[i],
612
-								  &overflow);
613
-			if (len < bpf_prog.len && !overflow) {
614
-				bpf_prog.len = len;
615
-				bpf_prog.filter = filters[i];
616
-			}
617
-		}
618
-		if (bpf_prog.len == USHRT_MAX) {
619
-			debug_msg("seccomp filter disabled due to jump offset "
620
-				  "overflow");
621
-			seccomp_filtering = false;
622
-		} else if (bpf_prog.len > BPF_MAXINSNS) {
623
-			debug_msg("seccomp filter disabled due to BPF program "
624
-				  "being oversized (%u > %d)", bpf_prog.len,
625
-				  BPF_MAXINSNS);
626
-			seccomp_filtering = false;
609
+	for (unsigned int i = 0; i < ARRAY_SIZE(filter_generators); ++i) {
610
+		bool overflow = false;
611
+		unsigned short len = filter_generators[i](filters[i],
612
+							  &overflow);
613
+		if (len < bpf_prog.len && !overflow) {
614
+			bpf_prog.len = len;
615
+			bpf_prog.filter = filters[i];
627 616
 		}
628 617
 	}
618
+	if (bpf_prog.len == USHRT_MAX) {
619
+		debug_msg("seccomp filter disabled due to jump offset "
620
+			  "overflow");
621
+		seccomp_filtering = false;
622
+	} else if (bpf_prog.len > BPF_MAXINSNS) {
623
+		debug_msg("seccomp filter disabled due to BPF program "
624
+			  "being oversized (%u > %d)", bpf_prog.len,
625
+			  BPF_MAXINSNS);
626
+		seccomp_filtering = false;
627
+	}
628
+
629 629
 	if (seccomp_filtering)
630 630
 		check_seccomp_order();
631 631
 }

Loading…
Cancel
Save