Linux-audit Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] [v2] audit: avoid -Wempty-body warning
@ 2021-03-22 16:27 Arnd Bergmann
  2021-03-22 18:00 ` Richard Guy Briggs
  2021-03-24 16:14 ` Paul Moore
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-03-22 16:27 UTC (permalink / raw)
  To: Paul Moore, Eric Paris
  Cc: Richard Guy Briggs, Jules Irenge, linux-audit, linux-kernel,
	Arnd Bergmann

From: Arnd Bergmann <arnd@arndb.de>

gcc warns about an empty statement when audit_remove_mark is defined to
nothing:

kernel/auditfilter.c: In function 'audit_data_to_entry':
kernel/auditfilter.c:609:51: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
  609 |                 audit_remove_mark(entry->rule.exe); /* that's the template one */
      |                                                   ^

Change the macros to use the usual "do { } while (0)" instead, and change a
few more that were (void)0, for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: convert two more macros
---
 kernel/audit.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/audit.h b/kernel/audit.h
index 3b9c0945225a..1522e100fd17 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -292,8 +292,8 @@ extern void audit_filter_inodes(struct task_struct *tsk,
 extern struct list_head *audit_killed_trees(void);
 #else /* CONFIG_AUDITSYSCALL */
 #define auditsc_get_stamp(c, t, s) 0
-#define audit_put_watch(w) {}
-#define audit_get_watch(w) {}
+#define audit_put_watch(w) do { } while (0)
+#define audit_get_watch(w) do { } while (0)
 #define audit_to_watch(k, p, l, o) (-EINVAL)
 #define audit_add_watch(k, l) (-EINVAL)
 #define audit_remove_watch_rule(k) BUG()
@@ -302,8 +302,8 @@ extern struct list_head *audit_killed_trees(void);
 
 #define audit_alloc_mark(k, p, l) (ERR_PTR(-EINVAL))
 #define audit_mark_path(m) ""
-#define audit_remove_mark(m)
-#define audit_remove_mark_rule(k)
+#define audit_remove_mark(m) do { } while (0)
+#define audit_remove_mark_rule(k) do { } while (0)
 #define audit_mark_compare(m, i, d) 0
 #define audit_exe_compare(t, m) (-EINVAL)
 #define audit_dupe_exe(n, o) (-EINVAL)
@@ -311,8 +311,8 @@ extern struct list_head *audit_killed_trees(void);
 #define audit_remove_tree_rule(rule) BUG()
 #define audit_add_tree_rule(rule) -EINVAL
 #define audit_make_tree(rule, str, op) -EINVAL
-#define audit_trim_trees() (void)0
-#define audit_put_tree(tree) (void)0
+#define audit_trim_trees() do { } while (0)
+#define audit_put_tree(tree) do { } while (0)
 #define audit_tag_tree(old, new) -EINVAL
 #define audit_tree_path(rule) ""	/* never called */
 #define audit_kill_trees(context) BUG()
-- 
2.29.2


--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] audit: avoid -Wempty-body warning
  2021-03-22 16:27 [PATCH] [v2] audit: avoid -Wempty-body warning Arnd Bergmann
@ 2021-03-22 18:00 ` Richard Guy Briggs
  2021-03-24 16:14 ` Paul Moore
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Guy Briggs @ 2021-03-22 18:00 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Jules Irenge, Arnd Bergmann, linux-kernel, linux-audit

On 2021-03-22 17:27, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> gcc warns about an empty statement when audit_remove_mark is defined to
> nothing:
> 
> kernel/auditfilter.c: In function 'audit_data_to_entry':
> kernel/auditfilter.c:609:51: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
>   609 |                 audit_remove_mark(entry->rule.exe); /* that's the template one */
>       |                                                   ^
> 
> Change the macros to use the usual "do { } while (0)" instead, and change a
> few more that were (void)0, for consistency.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Richard Guy Briggs <rgb@redhat.com>

> ---
> v2: convert two more macros
> ---
>  kernel/audit.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/audit.h b/kernel/audit.h
> index 3b9c0945225a..1522e100fd17 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -292,8 +292,8 @@ extern void audit_filter_inodes(struct task_struct *tsk,
>  extern struct list_head *audit_killed_trees(void);
>  #else /* CONFIG_AUDITSYSCALL */
>  #define auditsc_get_stamp(c, t, s) 0
> -#define audit_put_watch(w) {}
> -#define audit_get_watch(w) {}
> +#define audit_put_watch(w) do { } while (0)
> +#define audit_get_watch(w) do { } while (0)
>  #define audit_to_watch(k, p, l, o) (-EINVAL)
>  #define audit_add_watch(k, l) (-EINVAL)
>  #define audit_remove_watch_rule(k) BUG()
> @@ -302,8 +302,8 @@ extern struct list_head *audit_killed_trees(void);
>  
>  #define audit_alloc_mark(k, p, l) (ERR_PTR(-EINVAL))
>  #define audit_mark_path(m) ""
> -#define audit_remove_mark(m)
> -#define audit_remove_mark_rule(k)
> +#define audit_remove_mark(m) do { } while (0)
> +#define audit_remove_mark_rule(k) do { } while (0)
>  #define audit_mark_compare(m, i, d) 0
>  #define audit_exe_compare(t, m) (-EINVAL)
>  #define audit_dupe_exe(n, o) (-EINVAL)
> @@ -311,8 +311,8 @@ extern struct list_head *audit_killed_trees(void);
>  #define audit_remove_tree_rule(rule) BUG()
>  #define audit_add_tree_rule(rule) -EINVAL
>  #define audit_make_tree(rule, str, op) -EINVAL
> -#define audit_trim_trees() (void)0
> -#define audit_put_tree(tree) (void)0
> +#define audit_trim_trees() do { } while (0)
> +#define audit_put_tree(tree) do { } while (0)
>  #define audit_tag_tree(old, new) -EINVAL
>  #define audit_tree_path(rule) ""	/* never called */
>  #define audit_kill_trees(context) BUG()
> -- 
> 2.29.2
> 

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] audit: avoid -Wempty-body warning
  2021-03-22 16:27 [PATCH] [v2] audit: avoid -Wempty-body warning Arnd Bergmann
  2021-03-22 18:00 ` Richard Guy Briggs
@ 2021-03-24 16:14 ` Paul Moore
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Moore @ 2021-03-24 16:14 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jules Irenge, Arnd Bergmann, Richard Guy Briggs, linux-kernel,
	linux-audit

On Mon, Mar 22, 2021 at 12:28 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> gcc warns about an empty statement when audit_remove_mark is defined to
> nothing:
>
> kernel/auditfilter.c: In function 'audit_data_to_entry':
> kernel/auditfilter.c:609:51: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
>   609 |                 audit_remove_mark(entry->rule.exe); /* that's the template one */
>       |                                                   ^
>
> Change the macros to use the usual "do { } while (0)" instead, and change a
> few more that were (void)0, for consistency.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: convert two more macros
> ---
>  kernel/audit.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Merged into audit/next, thanks.

-- 
paul moore
www.paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 16:27 [PATCH] [v2] audit: avoid -Wempty-body warning Arnd Bergmann
2021-03-22 18:00 ` Richard Guy Briggs
2021-03-24 16:14 ` Paul Moore

Linux-audit Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-audit/0 linux-audit/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-audit linux-audit/ https://lore.kernel.org/linux-audit \
		linux-audit@redhat.com
	public-inbox-index linux-audit

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.redhat.linux-audit


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git