diff mbox series

[net-next,2/2] net: tipc: Add __printf() markup to fix -Wsuggest-attribute=format

Message ID 20201028003849.929490-3-andrew@lunn.ch (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series Markup some printk like functions | expand

Commit Message

Andrew Lunn Oct. 28, 2020, 12:38 a.m. UTC
net/tipc/netlink_compat.c: In function ‘tipc_tlv_sprintf’:
net/tipc/netlink_compat.c:137:2: warning: function ‘tipc_tlv_sprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
  137 |  n = vscnprintf(buf, rem, fmt, args);

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 net/tipc/netlink_compat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Oct. 29, 2020, 12:40 p.m. UTC | #1
On Thu, Oct 29, 2020 at 10:49:34AM +0800, kernel test robot wrote:
> Hi Andrew,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on net-next/master]
> 
> url:    https://github.com/0day-ci/linux/commits/Andrew-Lunn/net-dccp-Add-__printf-markup-to-fix-Wsuggest-attribute-format/20201029-081346
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cd29296fdfca919590e4004a7e4905544f4c4a32
> config: arc-allyesconfig (attached as .config)
> compiler: arceb-elf-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/0be08855cea6e7b987406c1beee6ca1b508f5066
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Andrew-Lunn/net-dccp-Add-__printf-markup-to-fix-Wsuggest-attribute-format/20201029-081346
>         git checkout 0be08855cea6e7b987406c1beee6ca1b508f5066
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    net/tipc/netlink_compat.c: In function 'tipc_nl_compat_link_stat_dump':
> >> net/tipc/netlink_compat.c:591:39: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'void *' [-Wformat=]
>      591 |  tipc_tlv_sprintf(msg->rep, "\nLink <%s>\n",
>          |                                      ~^
>          |                                       |
>          |                                       char *
>          |                                      %p
>      592 |     nla_data(link[TIPC_NLA_LINK_NAME]));
>          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>          |     |
>          |     void *

Yep, which is the point of adding this markup, and why there is a
follow up patch fixing this.

Please don't let this 0-day report stop the commit being merged.

       Andrew
diff mbox series

Patch

diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 1c7aa51cc2a3..17a90a2fe753 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -118,7 +118,8 @@  static void tipc_tlv_init(struct sk_buff *skb, u16 type)
 	skb_put(skb, sizeof(struct tlv_desc));
 }
 
-static int tipc_tlv_sprintf(struct sk_buff *skb, const char *fmt, ...)
+static __printf(2, 3) int tipc_tlv_sprintf(struct sk_buff *skb,
+					   const char *fmt, ...)
 {
 	int n;
 	u16 len;