Skip to contentSkip to conversation

apparmor: add braces around optional statement

PATCH In review Arnd Bergmann 3 participants 3 messages Jun 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 apparmor: add braces around optional statement

We get a warning when AA_BUG() compiles to an nothing:

security/apparmor/label.c: In function '__label_update':
security/apparmor/label.c:2055:3: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]

There are two things we can do about this:

- add the missing braces in the call site, which also brings the code in line with the regular Linux coding style

- redefine the macro so it is not empty but instead uses no_printk() in AA_BUG_FMT() to perform format checking.

Both seem like good ideas, so this does both at once.

Fixes f1bd904175e8 ("apparmor: add the base fns() for domain labels")

--
v2: actually include the second part of the patch

---
 security/apparmor/include/lib.h | 2 +-
 security/apparmor/label.c       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
security/apparmor/include/lib.h +1 -1
index 436b3a722357..cbfb71c1ec88 100644
@@ -50,7 +50,7 @@
 #define AA_BUG_FMT(X, fmt, args...)					\
 	WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
 #else
-#define AA_BUG_FMT(X, fmt, args...)
+#define AA_BUG_FMT(X, fmt, args...) no_printk("%s" fmt, __func__, ##args)
 #endif
 
 #define AA_ERROR(fmt, args...)						\
security/apparmor/label.c +2 -1
index e052eaba1cf6..f8e08d94a8a6 100644
@@ -2051,8 +2051,9 @@ static struct aa_label *__label_update(struct aa_label *label)
 			write_lock_irqsave(&ls->lock, flags);
 			goto remove;
 		}
-	} else
+	} else {
 		AA_BUG(labels_ns(label) != labels_ns(new));
+	}
 
 	tmp = __label_insert(labels_set(label), new, true);
 remove:
Signature · 6 lines
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

We get a warning when AA_BUG() compiles to an nothing:

security/apparmor/label.c: In function '__label_update':
security/apparmor/label.c:2055:3: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]

There are two things we can do about this:

- add the missing braces in the call site, which also brings the code in line with the regular Linux coding style

Quoted 7 lines

- redefine the macro so it is not empty but instead uses no_printk() in AA_BUG_FMT() to perform format checking.

Both seem like good ideas, so this does both at once.

Fixes f1bd904175e8 ("apparmor: add the base fns() for domain labels")
Quoted 37 lines

--
v2: actually include the second part of the patch

---
 security/apparmor/include/lib.h | 2 +-
 security/apparmor/label.c       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
security/apparmor/include/lib.h +1 -1
index 436b3a722357..cbfb71c1ec88 100644
@@ -50,7 +50,7 @@
 #define AA_BUG_FMT(X, fmt, args...)					\
 	WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
 #else
-#define AA_BUG_FMT(X, fmt, args...)
+#define AA_BUG_FMT(X, fmt, args...) no_printk("%s" fmt, __func__, ##args)
 #endif
 
 #define AA_ERROR(fmt, args...)						\
security/apparmor/label.c +2 -1
index e052eaba1cf6..f8e08d94a8a6 100644
@@ -2051,8 +2051,9 @@ static struct aa_label *__label_update(struct aa_label *label)
 			write_lock_irqsave(&ls->lock, flags);
 			goto remove;
 		}
-	} else
+	} else {
 		AA_BUG(labels_ns(label) != labels_ns(new));
+	}
 
 	tmp = __label_insert(labels_set(label), new, true);
 remove:
Signature · 1 line
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Acked-by
#2 lore raw
Quoted 14 lines · Serge E. Hallyn
Quoted 13 lines · Arnd Bergmann

We get a warning when AA_BUG() compiles to an nothing:

security/apparmor/label.c: In function '__label_update':
security/apparmor/label.c:2055:3: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]

There are two things we can do about this:

- add the missing braces in the call site, which also brings the code in line with the regular Linux coding style

- redefine the macro so it is not empty but instead uses no_printk() in AA_BUG_FMT() to perform format checking.

Quoted 6 lines
Quoted 4 lines

Both seem like good ideas, so this does both at once.

Fixes f1bd904175e8 ("apparmor: add the base fns() for domain labels")
Quoted 34 lines
Quoted 34 lines

--
v2: actually include the second part of the patch

---
 security/apparmor/include/lib.h | 2 +-
 security/apparmor/label.c       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
security/apparmor/include/lib.h +1 -1
index 436b3a722357..cbfb71c1ec88 100644
@@ -50,7 +50,7 @@
 #define AA_BUG_FMT(X, fmt, args...)					\
 	WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
 #else
-#define AA_BUG_FMT(X, fmt, args...)
+#define AA_BUG_FMT(X, fmt, args...) no_printk("%s" fmt, __func__, ##args)
 #endif
 
 #define AA_ERROR(fmt, args...)						\
security/apparmor/label.c +2 -1
index e052eaba1cf6..f8e08d94a8a6 100644
@@ -2051,8 +2051,9 @@ static struct aa_label *__label_update(struct aa_label *label)
 			write_lock_irqsave(&ls->lock, flags);
 			goto remove;
 		}
-	} else
+	} else {
 		AA_BUG(labels_ns(label) != labels_ns(new));
+	}
 
Quoted 4 lines
Quoted 4 lines
security/apparmor/label.c +0 -0
 	tmp = __label_insert(labels_set(label), new, true);
 remove:
Signature · 1 line
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html