All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>, davem@davemloft.net
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com
Subject: Re: [net-next 09/15] ixgbevf: Resolve truncation warning for q_vector->name
Date: Thu, 1 Jun 2017 12:30:03 +0300	[thread overview]
Message-ID: <b6cc6ba2-fc27-3e32-073b-06b1cb462e18@cogentembedded.com> (raw)
In-Reply-To: <20170531211936.63417-10-jeffrey.t.kirsher@intel.com>

Hello!

On 6/1/2017 12:19 AM, Jeff Kirsher wrote:

> From: Tony Nguyen <anthony.l.nguyen@intel.com>
>
> The following warning is now shown as a result of new checks added for
> gcc 7:
>
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c: In function ‘ixgbevf_open’:
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:1363:13: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size between 3 and 18 [-Wformat-truncation=]
>       "%s-%s-%d", netdev->name, "TxRx", ri++);
>              ^~
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:1363:6: note: directive argument in the range [0, 2147483647]
>       "%s-%s-%d", netdev->name, "TxRx", ri++);
>       ^~~~~~~~~~
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:1362:4: note: ‘snprintf’ output between 8 and 32 bytes into a destination of size 24
>     snprintf(q_vector->name, sizeof(q_vector->name) - 1,
>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       "%s-%s-%d", netdev->name, "TxRx", ri++);
>       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Resolve this warning by making a couple of changes.
>  - Don't reserve space for the null terminator.  Since snprintf adds the
>    null terminator automatically, there is no need for us to reserve a byte
>    for it.
>
>  - Change a couple variables that can never be negative from int to
>    unsigned int.
>
> While we're making changes to the format string, move the constant strings
> into the format string instead of providing them as specifiers.

    I suspect that trick saved some data space due to using the identical (and 
so merged) format strings...

> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

[...]

MBR, Sergei

  reply	other threads:[~2017-06-01  9:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 21:19 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2017-05-31 Jeff Kirsher
2017-05-31 21:19 ` [net-next 01/15] ixgbe/ixgbevf: Enables TSO for MPLS encapsulated packets Jeff Kirsher
2017-05-31 21:19 ` [net-next 02/15] ixgbe: initialize u64_stats_sync structures early at ixgbe_probe Jeff Kirsher
2017-05-31 21:19 ` [net-next 03/15] ixgbe: Remove MAC X550EM_X 1Gbase-t led_[on|off] support Jeff Kirsher
2017-05-31 21:19 ` [net-next 04/15] ixgbe: enable L3/L4 filtering for Tx switched packets Jeff Kirsher
2017-05-31 21:19 ` [net-next 05/15] ixgbe: Correct thermal sensor event check Jeff Kirsher
2017-05-31 21:19 ` [net-next 06/15] ixgbe: Add error checking to setting VF MAC Jeff Kirsher
2017-05-31 21:19 ` [net-next 07/15] ixgbe: Resolve truncation warning for q_vector->name Jeff Kirsher
2017-05-31 21:19 ` [net-next 08/15] ixgbe: Resolve warnings for -Wimplicit-fallthrough Jeff Kirsher
2017-05-31 21:19 ` [net-next 09/15] ixgbevf: Resolve truncation warning for q_vector->name Jeff Kirsher
2017-06-01  9:30   ` Sergei Shtylyov [this message]
2017-05-31 21:19 ` [net-next 10/15] ixgbevf: Resolve warnings for -Wimplicit-fallthrough Jeff Kirsher
2017-05-31 21:19 ` [net-next 11/15] ixgbe: correct CS4223/7 PHY identification Jeff Kirsher
2017-05-31 21:19 ` [net-next 12/15] ixgbe: add write flush when configuring CS4223/7 Jeff Kirsher
2017-05-31 21:19 ` [net-next 13/15] ixgbe: always call setup_mac_link for multispeed fiber Jeff Kirsher
2017-05-31 21:19 ` [net-next 14/15] ixgbe: add missing configuration for rate select 1 Jeff Kirsher
2017-05-31 21:19 ` [net-next 15/15] ixgbe: fix incorrect status check Jeff Kirsher
2017-05-31 21:55 ` [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2017-05-31 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6cc6ba2-fc27-3e32-073b-06b1cb462e18@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.