mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rustad, Mark D" <mark.d.rustad@intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iwl4965: Enable checking of format strings
Date: Thu, 12 Feb 2015 00:41:39 +0000	[thread overview]
Message-ID: <60178C37-F104-430E-92EB-B6DDFAEB2F99@intel.com> (raw)
In-Reply-To: <1423695069-23436-1-git-send-email-linux@rasmusvillemoes.dk>

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

On Feb 11, 2015, at 2:51 PM, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> Since these fmt_* variables are just const char*, and not const
> char[], gcc (and smatch) doesn't to type checking of the arguments to
> the printf functions. Since the linker knows perfectly well to merge
> identical string constants, there's no point in having three static
> pointers waste memory and give an extra level of indirection.
> 
> This removes over 100 "non-constant format argument" warnings from
> smatch, accounting for about 20% of all such warnings in an
> allmodconfig.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/net/wireless/iwlegacy/4965-debug.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c
> index e0597bfdddb8..18855325cc1c 100644
> --- a/drivers/net/wireless/iwlegacy/4965-debug.c
> +++ b/drivers/net/wireless/iwlegacy/4965-debug.c
> @@ -28,10 +28,9 @@
> #include "common.h"
> #include "4965.h"
> 
> -static const char *fmt_value = "  %-30s %10u\n";
> -static const char *fmt_table = "  %-30s %10u  %10u  %10u  %10u\n";
> -static const char *fmt_header =
> -    "%-32s    current  cumulative       delta         max\n";

Why not change these to:
static const char fmt_value[] = "  %-30s %10u\n";
static const char fmt_table[] = "  %-30s %10u  %10u  %10u  %10u\n";
static const char fmt_header[] =
    "%-32s    current  cumulative       delta         max\n";

I think that is better than the macros and avoids the extra pointers that I agree are useless.

-- 
Mark Rustad, Networking Division, Intel Corporation


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

  reply	other threads:[~2015-02-12  0:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 22:51 Rasmus Villemoes
2015-02-12  0:41 ` Rustad, Mark D [this message]
2015-02-12 10:20   ` Rasmus Villemoes
2015-02-13  7:55     ` Mark Rustad
2015-02-13 10:39       ` Rasmus Villemoes
2015-02-13 11:20         ` David Laight
2015-02-13 12:04           ` Rasmus Villemoes
2015-04-28 16:19 ` Kalle Valo
2015-04-28 17:49   ` Stanislaw Gruszka

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=60178C37-F104-430E-92EB-B6DDFAEB2F99@intel.com \
    --to=mark.d.rustad@intel.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=netdev@vger.kernel.org \
    --cc=sgruszka@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®