[PATCH] Fix build failures from audit macros when following coding style

From: John Johansen
Date: Mon Feb 27 2012 - 14:42:06 EST


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@xxxxxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/