From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 06 Apr 2017 10:49:12 +0200 (CEST) Received: from mga06.intel.com ([134.134.136.31]:32360 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23990519AbdDFItEL3bHK (ORCPT ); Thu, 6 Apr 2017 10:49:04 +0200 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 06 Apr 2017 01:49:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,283,1488873600"; d="scan'208";a="842574461" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.162]) by FMSMGA003.fm.intel.com with ESMTP; 06 Apr 2017 01:48:49 -0700 From: Jani Nikula To: Kees Cook , Andrew Morton Cc: Tony Lindgren , Russell King , "Maciej W. Rozycki" , Ralf Baechle , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Viresh Kumar , Daniel Vetter , Sean Paul , David Airlie , Yisen Zhuang , Salil Mehta , Thomas Bogendoerfer , Jes Sorensen , Jiri Slaby , Patrice Chotard , "David S. Miller" , James Hogan , Paul Burton , Matt Redfearn , Paolo Bonzini , Ingo Molnar , Rasmus Villemoes , Mugunthan V N , Felipe Balbi , Jarod Wilson , Florian Westphal , Antonio Quartulli , Dmitry Torokhov , Kejian Yan , Daode Huang , Qianqian Xie , Philippe Reynes , Colin Ian King , Eric Dumazet , Christian Gromm , Andrey Shvetsov , Jason Litzinger , WANG Cong , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-mips@linux-mips.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, netdev@vger.kernel.org, linux-hippi@sunsite.dk, devel@driverdev.osuosl.org, kernel@stlinux.com, linux-serial@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] format-security: move static strings to const In-Reply-To: <20170405214711.GA5711@beast> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20170405214711.GA5711@beast> Date: Thu, 06 Apr 2017 11:48:48 +0300 Message-ID: <87mvbtzztb.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 57578 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: jani.nikula@linux.intel.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips On Thu, 06 Apr 2017, Kees Cook 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