teamd: fix build error in expansion of macro teamd_log_dbgx
diff mbox series

Message ID 20191212062221.14632-1-liuhangbin@gmail.com
State New
Headers show
Series
  • teamd: fix build error in expansion of macro teamd_log_dbgx
Related show

Commit Message

Hangbin Liu Dec. 12, 2019, 6:22 a.m. UTC
With gcc 8.3 I got the following build error:

In file included from teamd_dbus.c:33:
teamd_dbus.c: In function 'teamd_dbus_init':
teamd.h:54:2: error: expected expression before 'if'
  if (val <= ctx->debug)   \
  ^~
teamd.h:57:37: note: in expansion of macro 'teamd_log_dbgx'
 #define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)
                                     ^~~~~~~~~~~~~~
teamd_dbus.c:507:2: note: in expansion of macro 'teamd_log_dbg'
  teamd_log_dbg(ctx, "dbus: connected to %s with name %s", id,
  ^~~~~~~~~~~~~

Fix it by adding parentheses and braces around the content.

Fixes: f32310b9a5cc ("libteam: wapper teamd_log_dbg with teamd_log_dbgx")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 teamd/teamd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jiri Pirko Jan. 9, 2020, 2:26 p.m. UTC | #1
Thu, Dec 12, 2019 at 07:22:21AM CET, liuhangbin@gmail.com wrote:
>With gcc 8.3 I got the following build error:
>
>In file included from teamd_dbus.c:33:
>teamd_dbus.c: In function 'teamd_dbus_init':
>teamd.h:54:2: error: expected expression before 'if'
>  if (val <= ctx->debug)   \
>  ^~
>teamd.h:57:37: note: in expansion of macro 'teamd_log_dbgx'
> #define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)
>                                     ^~~~~~~~~~~~~~
>teamd_dbus.c:507:2: note: in expansion of macro 'teamd_log_dbg'
>  teamd_log_dbg(ctx, "dbus: connected to %s with name %s", id,
>  ^~~~~~~~~~~~~
>
>Fix it by adding parentheses and braces around the content.
>
>Fixes: f32310b9a5cc ("libteam: wapper teamd_log_dbg with teamd_log_dbgx")
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

applied, thanks.

Patch
diff mbox series

diff --git a/teamd/teamd.h b/teamd/teamd.h
index 469b769..fb2872e 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -51,8 +51,7 @@ 
 #define teamd_log_info(args...) daemon_log(LOG_INFO, ##args)
 
 #define teamd_log_dbgx(ctx, val, args...)	\
-	if (val <= ctx->debug)			\
-		daemon_log(LOG_DEBUG, ##args)
+	({ if (val <= ctx->debug) daemon_log(LOG_DEBUG, ##args); })
 
 #define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)