public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] log.h: Avoid unnecessary GNU extension for token pasting
@ 2022-10-12 15:45 Stefano Brivio
  2022-10-13  1:13 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2022-10-12 15:45 UTC (permalink / raw)
  To: passt-dev

clang says:

  ./log.h:23:18: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

...but we don't actually need token pasting there.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 log.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/log.h b/log.h
index f92394c..5abbfc5 100644
--- a/log.h
+++ b/log.h
@@ -20,7 +20,7 @@ void trace_init(int enable);
 #define trace(format, ...)						\
 	do {								\
 		if (log_trace)						\
-			debug(format, ##__VA_ARGS__);			\
+			debug(format, __VA_ARGS__);			\
 	} while (0)
 
 void __openlog(const char *ident, int option, int facility);
-- 
@@ -20,7 +20,7 @@ void trace_init(int enable);
 #define trace(format, ...)						\
 	do {								\
 		if (log_trace)						\
-			debug(format, ##__VA_ARGS__);			\
+			debug(format, __VA_ARGS__);			\
 	} while (0)
 
 void __openlog(const char *ident, int option, int facility);
-- 
2.35.1


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

* Re: [PATCH] log.h: Avoid unnecessary GNU extension for token pasting
  2022-10-12 15:45 [PATCH] log.h: Avoid unnecessary GNU extension for token pasting Stefano Brivio
@ 2022-10-13  1:13 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2022-10-13  1:13 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]

On Wed, Oct 12, 2022 at 05:45:36PM +0200, Stefano Brivio wrote:
> clang says:
> 
>   ./log.h:23:18: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
> 
> ...but we don't actually need token pasting there.

Actually, we kinda do.  Without token pasting this would be incorrect
if there were any calls to trace() with just a string and no further
parameters.

We could, however, avoid the need by making it simply trace(...),
rather than trace(format, ...).

> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>  log.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/log.h b/log.h
> index f92394c..5abbfc5 100644
> --- a/log.h
> +++ b/log.h
> @@ -20,7 +20,7 @@ void trace_init(int enable);
>  #define trace(format, ...)						\
>  	do {								\
>  		if (log_trace)						\
> -			debug(format, ##__VA_ARGS__);			\
> +			debug(format, __VA_ARGS__);			\
>  	} while (0)
>  
>  void __openlog(const char *ident, int option, int facility);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-10-13  4:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 15:45 [PATCH] log.h: Avoid unnecessary GNU extension for token pasting Stefano Brivio
2022-10-13  1:13 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).