public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux•intel.com>
To: Kees Cook <keescook@chromium•org>,
	Andrew Morton <akpm@linux-foundation•org>
Cc: linux-mips@linux-mips•org,
	linux-decnet-user@lists•sourceforge.net, kernel@stlinux•com,
	Qianqian Xie <xieqianqian@huawei•com>,
	Mugunthan V N <mugunthanvnm@ti•com>,
	Tony Lindgren <tony@atomide•com>,
	Viresh Kumar <viresh.kumar@linaro•org>,
	Rasmus Villemoes <linux@rasmusvillemoes•dk>,
	dri-devel@lists•freedesktop.org, linux-kernel@vger•kernel.org,
	Eric Dumazet <edumazet@google•com>,
	"Maciej W. Rozycki" <macro@linux-mips•org>,
	Christian Gromm <christian.gromm@microchip•com>,
	Daniel Vetter <daniel.vetter@intel•com>,
	Ingo Molnar <mingo@kernel•org>,
	Andrey Shvetsov <andrey.shvetsov@k2l•de>,
	devel@driverdev•osuosl.org, Kejian Yan <yankejian@huawei•com>,
	Felipe Balbi <felipe.balbi@linux•intel.com>,
	Russell King <linux@armlinux•org.uk>,
	Jarod Wilson <jarod@redhat•com>,
	linux-hippi@sunsite•dk, Daode Huang <huangdaode@hisilicon•com>,
	linux-serial@vger•kernel.org, Jiri Slaby <jslaby@s
Subject: Re: [PATCH] format-security: move static strings to const
Date: Thu, 06 Apr 2017 11:48:48 +0300	[thread overview]
Message-ID: <87mvbtzztb.fsf@intel.com> (raw)
In-Reply-To: <20170405214711.GA5711@beast>

On Thu, 06 Apr 2017, Kees Cook <keescook@chromium•org> wrote:
> While examining output from trial builds with -Wformat-security enabled,
> many strings were found that should be defined as "const", or as a char
> array instead of char pointer. This makes some static analysis easier,
> by producing fewer false positives.
>
> As these are all trivial changes, it seemed best to put them all in
> a single patch rather than chopping them up per maintainer.

> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index f6d4d9700734..1ff9d5912b83 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2331,7 +2331,7 @@ EXPORT_SYMBOL(drm_fb_helper_hotplug_event);
>  int __init drm_fb_helper_modinit(void)
>  {
>  #if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT)
> -	const char *name = "fbcon";
> +	const char name[] = "fbcon";

I'd always write the former out of habit. Why should I start using the
latter? What makes it better?

What keeps the kernel from accumulating tons more of the former?

Here's an interesting comparison of the generated code. I'm a bit
surprised by what gcc does, I would have expected no difference, like
clang. https://godbolt.org/g/OdqUvN

The other changes adding const in this patch are, of course, good.


BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists•freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-04-06  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 21:47 [PATCH] format-security: move static strings to const Kees Cook
2017-04-06  8:27 ` Daniel Vetter
2017-04-06  8:48 ` Jani Nikula [this message]
2017-04-07  3:21   ` Kees Cook

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=87mvbtzztb.fsf@intel.com \
    --to=jani.nikula@linux$(echo .)intel.com \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=andrey.shvetsov@k2l$(echo .)de \
    --cc=christian.gromm@microchip$(echo .)com \
    --cc=daniel.vetter@intel$(echo .)com \
    --cc=devel@driverdev$(echo .)osuosl.org \
    --cc=dri-devel@lists$(echo .)freedesktop.org \
    --cc=edumazet@google$(echo .)com \
    --cc=felipe.balbi@linux$(echo .)intel.com \
    --cc=huangdaode@hisilicon$(echo .)com \
    --cc=jarod@redhat$(echo .)com \
    --cc=jslaby@s \
    --cc=keescook@chromium$(echo .)org \
    --cc=kernel@stlinux$(echo .)com \
    --cc=linux-decnet-user@lists$(echo .)sourceforge.net \
    --cc=linux-hippi@sunsite$(echo .)dk \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-mips@linux-mips$(echo .)org \
    --cc=linux-serial@vger$(echo .)kernel.org \
    --cc=linux@armlinux$(echo .)org.uk \
    --cc=linux@rasmusvillemoes$(echo .)dk \
    --cc=macro@linux-mips$(echo .)org \
    --cc=mingo@kernel$(echo .)org \
    --cc=mugunthanvnm@ti$(echo .)com \
    --cc=tony@atomide$(echo .)com \
    --cc=viresh.kumar@linaro$(echo .)org \
    --cc=xieqianqian@huawei$(echo .)com \
    --cc=yankejian@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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