* [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d
@ 2019-01-10 4:21 Nathan Chancellor
2019-01-10 18:54 ` Nick Desaulniers
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nathan Chancellor @ 2019-01-10 4:21 UTC (permalink / raw)
To: Jeff Kirsher
Cc: David S. Miller, intel-wired-lan, netdev, linux-kernel,
Nick Desaulniers, Nathan Chancellor, Miguel Ojeda
Clang warns:
In file included from drivers/net/ethernet/intel/iavf/iavf_main.c:4:
In file included from drivers/net/ethernet/intel/iavf/iavf.h:37:
In file included from drivers/net/ethernet/intel/iavf/iavf_type.h:8:
drivers/net/ethernet/intel/iavf/iavf_osdep.h:49:18: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
__attribute__ ((format(gnu_printf, 3, 4)));
^
1 warning generated.
We can convert from gnu_printf to printf without any side effects for
two reasons:
1. All iavf_debug instances use standard printf formats, as pointed out
by Miguel Ojeda at the below link, meaning gnu_printf is not strictly
required.
2. However, GCC has aliased printf to gnu_printf on Linux since at least
2010 based on git history.
From gcc/c-family/c-format.c:
/* Attributes such as "printf" are equivalent to those such as
"gnu_printf" unless this is overridden by a target. */
static const target_ovr_attr gnu_target_overrides_format_attributes[] =
{
{ "gnu_printf", "printf" },
{ "gnu_scanf", "scanf" },
{ "gnu_strftime", "strftime" },
{ "gnu_strfmon", "strfmon" },
{ NULL, NULL }
};
The mentioned override only happens on Windows (mingw32). Changing from
gnu_printf to printf is a no-op for GCC and stops Clang from warning.
Link: https://github.com/ClangBuiltLinux/linux/issues/111
Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/ethernet/intel/iavf/iavf_osdep.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_osdep.h b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
index e6e0b0328706..c90cafb526d0 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_osdep.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
@@ -46,7 +46,7 @@ struct iavf_virt_mem {
#define iavf_debug(h, m, s, ...) iavf_debug_d(h, m, s, ##__VA_ARGS__)
extern void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
- __attribute__ ((format(gnu_printf, 3, 4)));
+ __printf(3, 4);
typedef enum iavf_status_code iavf_status;
#endif /* _IAVF_OSDEP_H_ */
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d
2019-01-10 4:21 [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d Nathan Chancellor
@ 2019-01-10 18:54 ` Nick Desaulniers
2019-01-10 19:07 ` Nathan Chancellor
2019-01-16 22:38 ` Miguel Ojeda
2019-01-30 18:20 ` [Intel-wired-lan] " Bowers, AndrewX
2 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2019-01-10 18:54 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Jeff Kirsher, David S. Miller, intel-wired-lan, netdev, LKML,
Miguel Ojeda
On Wed, Jan 9, 2019 at 8:22 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> In file included from drivers/net/ethernet/intel/iavf/iavf_main.c:4:
> In file included from drivers/net/ethernet/intel/iavf/iavf.h:37:
> In file included from drivers/net/ethernet/intel/iavf/iavf_type.h:8:
> drivers/net/ethernet/intel/iavf/iavf_osdep.h:49:18: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
> __attribute__ ((format(gnu_printf, 3, 4)));
> ^
> 1 warning generated.
>
> We can convert from gnu_printf to printf without any side effects for
> two reasons:
>
> 1. All iavf_debug instances use standard printf formats, as pointed out
> by Miguel Ojeda at the below link, meaning gnu_printf is not strictly
> required.
>
> 2. However, GCC has aliased printf to gnu_printf on Linux since at least
> 2010 based on git history.
Thanks for this fix!
FWIW, using godbolt to see which version something was added in is
better than giving a year of the commit. I don't think it matters for
this case, as the kernel already makes use of `printf` as you do in
this change, but food for thought for next time.
>
> From gcc/c-family/c-format.c:
>
> /* Attributes such as "printf" are equivalent to those such as
> "gnu_printf" unless this is overridden by a target. */
> static const target_ovr_attr gnu_target_overrides_format_attributes[] =
> {
> { "gnu_printf", "printf" },
> { "gnu_scanf", "scanf" },
> { "gnu_strftime", "strftime" },
> { "gnu_strfmon", "strfmon" },
> { NULL, NULL }
> };
>
> The mentioned override only happens on Windows (mingw32). Changing from
> gnu_printf to printf is a no-op for GCC and stops Clang from warning.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/111
> Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/net/ethernet/intel/iavf/iavf_osdep.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_osdep.h b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> index e6e0b0328706..c90cafb526d0 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> @@ -46,7 +46,7 @@ struct iavf_virt_mem {
>
> #define iavf_debug(h, m, s, ...) iavf_debug_d(h, m, s, ##__VA_ARGS__)
> extern void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
> - __attribute__ ((format(gnu_printf, 3, 4)));
> + __printf(3, 4);
And you make use of the __attribute__ wrapper from
include/linux/compiler_attributes.h, cool.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d
2019-01-10 18:54 ` Nick Desaulniers
@ 2019-01-10 19:07 ` Nathan Chancellor
0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2019-01-10 19:07 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Jeff Kirsher, David S. Miller, intel-wired-lan, netdev, LKML,
Miguel Ojeda
On Thu, Jan 10, 2019 at 10:54:46AM -0800, Nick Desaulniers wrote:
> On Wed, Jan 9, 2019 at 8:22 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns:
> >
> > In file included from drivers/net/ethernet/intel/iavf/iavf_main.c:4:
> > In file included from drivers/net/ethernet/intel/iavf/iavf.h:37:
> > In file included from drivers/net/ethernet/intel/iavf/iavf_type.h:8:
> > drivers/net/ethernet/intel/iavf/iavf_osdep.h:49:18: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
> > __attribute__ ((format(gnu_printf, 3, 4)));
> > ^
> > 1 warning generated.
> >
> > We can convert from gnu_printf to printf without any side effects for
> > two reasons:
> >
> > 1. All iavf_debug instances use standard printf formats, as pointed out
> > by Miguel Ojeda at the below link, meaning gnu_printf is not strictly
> > required.
> >
> > 2. However, GCC has aliased printf to gnu_printf on Linux since at least
> > 2010 based on git history.
>
> Thanks for this fix!
> FWIW, using godbolt to see which version something was added in is
> better than giving a year of the commit. I don't think it matters for
> this case, as the kernel already makes use of `printf` as you do in
> this change, but food for thought for next time.
>
Yes that is a good point, I need to be taking advantage of that site
more.
Thank you for the review!
Nathan
> >
> > From gcc/c-family/c-format.c:
> >
> > /* Attributes such as "printf" are equivalent to those such as
> > "gnu_printf" unless this is overridden by a target. */
> > static const target_ovr_attr gnu_target_overrides_format_attributes[] =
> > {
> > { "gnu_printf", "printf" },
> > { "gnu_scanf", "scanf" },
> > { "gnu_strftime", "strftime" },
> > { "gnu_strfmon", "strfmon" },
> > { NULL, NULL }
> > };
> >
> > The mentioned override only happens on Windows (mingw32). Changing from
> > gnu_printf to printf is a no-op for GCC and stops Clang from warning.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/111
> > Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > drivers/net/ethernet/intel/iavf/iavf_osdep.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/intel/iavf/iavf_osdep.h b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> > index e6e0b0328706..c90cafb526d0 100644
> > --- a/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> > +++ b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> > @@ -46,7 +46,7 @@ struct iavf_virt_mem {
> >
> > #define iavf_debug(h, m, s, ...) iavf_debug_d(h, m, s, ##__VA_ARGS__)
> > extern void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
> > - __attribute__ ((format(gnu_printf, 3, 4)));
> > + __printf(3, 4);
>
> And you make use of the __attribute__ wrapper from
> include/linux/compiler_attributes.h, cool.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> --
> Thanks,
> ~Nick Desaulniers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d
2019-01-10 4:21 [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d Nathan Chancellor
2019-01-10 18:54 ` Nick Desaulniers
@ 2019-01-16 22:38 ` Miguel Ojeda
2019-01-30 18:20 ` [Intel-wired-lan] " Bowers, AndrewX
2 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2019-01-16 22:38 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Jeff Kirsher, David S. Miller, intel-wired-lan,
Network Development, linux-kernel, Nick Desaulniers
Hi Nathan,
On Thu, Jan 10, 2019 at 5:22 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> In file included from drivers/net/ethernet/intel/iavf/iavf_main.c:4:
> In file included from drivers/net/ethernet/intel/iavf/iavf.h:37:
> In file included from drivers/net/ethernet/intel/iavf/iavf_type.h:8:
> drivers/net/ethernet/intel/iavf/iavf_osdep.h:49:18: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
> __attribute__ ((format(gnu_printf, 3, 4)));
> ^
> 1 warning generated.
>
> We can convert from gnu_printf to printf without any side effects for
> two reasons:
>
> 1. All iavf_debug instances use standard printf formats, as pointed out
> by Miguel Ojeda at the below link, meaning gnu_printf is not strictly
> required.
>
> 2. However, GCC has aliased printf to gnu_printf on Linux since at least
> 2010 based on git history.
>
> From gcc/c-family/c-format.c:
>
> /* Attributes such as "printf" are equivalent to those such as
> "gnu_printf" unless this is overridden by a target. */
> static const target_ovr_attr gnu_target_overrides_format_attributes[] =
> {
> { "gnu_printf", "printf" },
> { "gnu_scanf", "scanf" },
> { "gnu_strftime", "strftime" },
> { "gnu_strfmon", "strfmon" },
> { NULL, NULL }
> };
>
> The mentioned override only happens on Windows (mingw32). Changing from
> gnu_printf to printf is a no-op for GCC and stops Clang from warning.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/111
> Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
I forgot, in case you wanted it:
Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Thanks for taking care of writing the patch!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [Intel-wired-lan] [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d
2019-01-10 4:21 [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d Nathan Chancellor
2019-01-10 18:54 ` Nick Desaulniers
2019-01-16 22:38 ` Miguel Ojeda
@ 2019-01-30 18:20 ` Bowers, AndrewX
2 siblings, 0 replies; 5+ messages in thread
From: Bowers, AndrewX @ 2019-01-30 18:20 UTC (permalink / raw)
To: netdev, linux-kernel, intel-wired-lan
> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
> Behalf Of Nathan Chancellor
> Sent: Wednesday, January 9, 2019 8:22 PM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>
> Cc: netdev@vger.kernel.org; Nick Desaulniers <ndesaulniers@google.com>;
> linux-kernel@vger.kernel.org; Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com>; intel-wired-lan@lists.osuosl.org;
> Nathan Chancellor <natechancellor@gmail.com>; David S. Miller
> <davem@davemloft.net>
> Subject: [Intel-wired-lan] [PATCH] iavf: Use printf instead of gnu_printf for
> iavf_debug_d
>
> Clang warns:
>
> In file included from drivers/net/ethernet/intel/iavf/iavf_main.c:4:
> In file included from drivers/net/ethernet/intel/iavf/iavf.h:37:
> In file included from drivers/net/ethernet/intel/iavf/iavf_type.h:8:
> drivers/net/ethernet/intel/iavf/iavf_osdep.h:49:18: warning: 'format'
> attribute argument not supported: gnu_printf [-Wignored-attributes]
> __attribute__ ((format(gnu_printf, 3, 4)));
> ^
> 1 warning generated.
>
> We can convert from gnu_printf to printf without any side effects for two
> reasons:
>
> 1. All iavf_debug instances use standard printf formats, as pointed out
> by Miguel Ojeda at the below link, meaning gnu_printf is not strictly
> required.
>
> 2. However, GCC has aliased printf to gnu_printf on Linux since at least
> 2010 based on git history.
>
> From gcc/c-family/c-format.c:
>
> /* Attributes such as "printf" are equivalent to those such as
> "gnu_printf" unless this is overridden by a target. */
> static const target_ovr_attr gnu_target_overrides_format_attributes[] =
> {
> { "gnu_printf", "printf" },
> { "gnu_scanf", "scanf" },
> { "gnu_strftime", "strftime" },
> { "gnu_strfmon", "strfmon" },
> { NULL, NULL }
> };
>
> The mentioned override only happens on Windows (mingw32). Changing
> from gnu_printf to printf is a no-op for GCC and stops Clang from warning.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/111
> Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/net/ethernet/intel/iavf/iavf_osdep.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-30 18:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10 4:21 [PATCH] iavf: Use printf instead of gnu_printf for iavf_debug_d Nathan Chancellor
2019-01-10 18:54 ` Nick Desaulniers
2019-01-10 19:07 ` Nathan Chancellor
2019-01-16 22:38 ` Miguel Ojeda
2019-01-30 18:20 ` [Intel-wired-lan] " Bowers, AndrewX
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 NNTP newsgroup(s).