* [PATCH v2] apparmor: add braces around optional statement
@ 2017-06-20 20:46 Arnd Bergmann
2017-06-20 20:49 ` Serge E. Hallyn
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-06-20 20:46 UTC (permalink / raw)
To: linux-security-module
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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
--
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(-)
diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
index 436b3a722357..cbfb71c1ec88 100644
--- a/security/apparmor/include/lib.h
+++ b/security/apparmor/include/lib.h
@@ -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...) \
diff --git a/security/apparmor/label.c b/security/apparmor/label.c
index e052eaba1cf6..f8e08d94a8a6 100644
--- a/security/apparmor/label.c
+++ b/security/apparmor/label.c
@@ -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:
--
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] apparmor: add braces around optional statement
2017-06-20 20:46 [PATCH v2] apparmor: add braces around optional statement Arnd Bergmann
@ 2017-06-20 20:49 ` Serge E. Hallyn
2017-06-20 22:28 ` John Johansen
0 siblings, 1 reply; 3+ messages in thread
From: Serge E. Hallyn @ 2017-06-20 20:49 UTC (permalink / raw)
To: linux-security-module
Quoting Arnd Bergmann (arnd at arndb.de):
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Serge Hallyn <serge@hallyn.com>
> --
> 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(-)
>
> diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
> index 436b3a722357..cbfb71c1ec88 100644
> --- a/security/apparmor/include/lib.h
> +++ b/security/apparmor/include/lib.h
> @@ -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...) \
> diff --git a/security/apparmor/label.c b/security/apparmor/label.c
> index e052eaba1cf6..f8e08d94a8a6 100644
> --- a/security/apparmor/label.c
> +++ b/security/apparmor/label.c
> @@ -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:
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] apparmor: add braces around optional statement
2017-06-20 20:49 ` Serge E. Hallyn
@ 2017-06-20 22:28 ` John Johansen
0 siblings, 0 replies; 3+ messages in thread
From: John Johansen @ 2017-06-20 22:28 UTC (permalink / raw)
To: linux-security-module
On 06/20/2017 01:49 PM, Serge E. Hallyn wrote:
> Quoting Arnd Bergmann (arnd at arndb.de):
>> 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")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Acked-by: Serge Hallyn <serge@hallyn.com>
Acked-by: John Johansen <john.johansen@canonical.com>
>
>> --
>> 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(-)
>>
>> diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
>> index 436b3a722357..cbfb71c1ec88 100644
>> --- a/security/apparmor/include/lib.h
>> +++ b/security/apparmor/include/lib.h
>> @@ -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...) \
>> diff --git a/security/apparmor/label.c b/security/apparmor/label.c
>> index e052eaba1cf6..f8e08d94a8a6 100644
>> --- a/security/apparmor/label.c
>> +++ b/security/apparmor/label.c
>> @@ -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:
>> --
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-20 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 20:46 [PATCH v2] apparmor: add braces around optional statement Arnd Bergmann
2017-06-20 20:49 ` Serge E. Hallyn
2017-06-20 22:28 ` John Johansen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).