mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: LABBE Corentin <clabbe.montjoie@gmail.com>,
	openipmi-developer@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipmi: constify some struct and char arrays
Date: Mon, 16 Nov 2015 07:20:01 -0600	[thread overview]
Message-ID: <5649D801.1040906@acm.org> (raw)
In-Reply-To: <1447417911-17499-1-git-send-email-clabbe.montjoie@gmail.com>

Thanks for fixing the problem reported on this.  Queued for 4.5.

-corey

On 11/13/2015 06:31 AM, LABBE Corentin wrote:
> Lots of char arrays could be set as const since they contain only literal
> char arrays.
> We could in the same time make const some struct members who are pointer
> to those const char arrays.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/char/ipmi/ipmi_msghandler.c |  7 ++++---
>  drivers/char/ipmi/ipmi_si_intf.c    | 27 ++++++++++++++++-----------
>  2 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index e3536da..94fb407 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -472,9 +472,10 @@ static DEFINE_MUTEX(smi_watchers_mutex);
>  #define ipmi_get_stat(intf, stat) \
>  	((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
>  
> -static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI",
> -				   "ACPI", "SMBIOS", "PCI",
> -				   "device-tree", "default" };
> +static const char * const addr_src_to_str[] = {
> +	"invalid", "hotmod", "hardcoded", "SPMI", "ACPI", "SMBIOS", "PCI",
> +	"device-tree", "default"
> +};
>  
>  const char *ipmi_addr_src_to_str(enum ipmi_addr_src src)
>  {
> diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
> index 654f6f3..8d680c8 100644
> --- a/drivers/char/ipmi/ipmi_si_intf.c
> +++ b/drivers/char/ipmi/ipmi_si_intf.c
> @@ -105,7 +105,8 @@ enum si_intf_state {
>  enum si_type {
>      SI_KCS, SI_SMIC, SI_BT
>  };
> -static char *si_to_str[] = { "kcs", "smic", "bt" };
> +
> +static const char * const si_to_str[] = { "kcs", "smic", "bt" };
>  
>  #define DEVICE_NAME "ipmi_si"
>  
> @@ -1319,7 +1320,7 @@ static unsigned int num_slave_addrs;
>  
>  #define IPMI_IO_ADDR_SPACE  0
>  #define IPMI_MEM_ADDR_SPACE 1
> -static char *addr_space_to_str[] = { "i/o", "mem" };
> +static const char * const addr_space_to_str[] = { "i/o", "mem" };
>  
>  static int hotmod_handler(const char *val, struct kernel_param *kp);
>  
> @@ -1701,27 +1702,31 @@ static int mem_setup(struct smi_info *info)
>   */
>  enum hotmod_op { HM_ADD, HM_REMOVE };
>  struct hotmod_vals {
> -	char *name;
> -	int  val;
> +	const char *name;
> +	const int  val;
>  };
> -static struct hotmod_vals hotmod_ops[] = {
> +
> +static const struct hotmod_vals hotmod_ops[] = {
>  	{ "add",	HM_ADD },
>  	{ "remove",	HM_REMOVE },
>  	{ NULL }
>  };
> -static struct hotmod_vals hotmod_si[] = {
> +
> +static const struct hotmod_vals hotmod_si[] = {
>  	{ "kcs",	SI_KCS },
>  	{ "smic",	SI_SMIC },
>  	{ "bt",		SI_BT },
>  	{ NULL }
>  };
> -static struct hotmod_vals hotmod_as[] = {
> +
> +static const struct hotmod_vals hotmod_as[] = {
>  	{ "mem",	IPMI_MEM_ADDR_SPACE },
>  	{ "i/o",	IPMI_IO_ADDR_SPACE },
>  	{ NULL }
>  };
>  
> -static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
> +static int parse_str(const struct hotmod_vals *v, int *val, char *name,
> +		     char **curr)
>  {
>  	char *s;
>  	int  i;
> @@ -2848,7 +2853,7 @@ static int ipmi_parisc_remove(struct parisc_device *dev)
>  	return 0;
>  }
>  
> -static struct parisc_device_id ipmi_parisc_tbl[] = {
> +static const struct parisc_device_id ipmi_parisc_tbl[] = {
>  	{ HPHW_MC, HVERSION_REV_ANY_ID, 0x004, 0xC0 },
>  	{ 0, }
>  };
> @@ -3422,8 +3427,8 @@ static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
>  
>  static const struct ipmi_default_vals
>  {
> -	int type;
> -	int port;
> +	const int type;
> +	const int port;
>  } ipmi_defaults[] =
>  {
>  	{ .type = SI_KCS, .port = 0xca2 },


  reply	other threads:[~2015-11-16 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 12:31 LABBE Corentin
2015-11-16 13:20 ` Corey Minyard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-11-05  9:31 LABBE Corentin
2015-11-06  0:11 ` kbuild test robot

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=5649D801.1040906@acm.org \
    --to=minyard@acm.org \
    --cc=clabbe.montjoie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /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

Powered by JetHome