lkml.org 
[lkml]   [2012]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Fix build failures from audit macros when following coding style
Date
Recently I was cleaning up some code and hit build failures when following
the kernel coding style / checkpatch.pl recommendations. In both cases
the code had the form of

if (X)
Y;
else
Z;

where Y or Z were either the macros audit_log_string or COMMON_AUDIT_DATA_INIT

and the failure was
error: 'else' without a previous 'if'

Signed-off-by: John Johansen <john.johansen@canonical.com>
---
include/linux/audit.h | 2 +-
include/linux/lsm_audit.h | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 9ff7a2c..583010f 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -676,7 +676,7 @@ extern void audit_log_n_hex(struct audit_buffer *ab,
extern void audit_log_n_string(struct audit_buffer *ab,
const char *buf,
size_t n);
-#define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b));
+#define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b))
extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
const char *string,
size_t n);
diff --git a/include/linux/lsm_audit.h b/include/linux/lsm_audit.h
index 88e78de..7a0841c 100644
--- a/include/linux/lsm_audit.h
+++ b/include/linux/lsm_audit.h
@@ -143,9 +143,11 @@ int ipv6_skb_to_auditdata(struct sk_buff *skb,
struct common_audit_data *ad, u8 *proto);

/* Initialize an LSM audit data structure. */
-#define COMMON_AUDIT_DATA_INIT(_d, _t) \
- { memset((_d), 0, sizeof(struct common_audit_data)); \
- (_d)->type = LSM_AUDIT_DATA_##_t; }
+#define COMMON_AUDIT_DATA_INIT(_d, _t) \
+do { \
+ memset((_d), 0, sizeof(struct common_audit_data)); \
+ (_d)->type = LSM_AUDIT_DATA_##_t; \
+} while (0)

void common_lsm_audit(struct common_audit_data *a);

--
1.7.9


\
 
 \ /
  Last update: 2012-02-27 20:45    [W:0.028 / U:4.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site