mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Benjamin Stürz" <benni@stuerz.xyz>, kvalo@kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] ray_cs: Improve card_status[]
Date: Wed, 06 Apr 2022 10:58:35 -0700	[thread overview]
Message-ID: <1064228a2bb8a5fbdcb483295c641c100dd08c9f.camel@perches.com> (raw)
In-Reply-To: <20220406152247.386267-2-benni@stuerz.xyz>

On Wed, 2022-04-06 at 17:22 +0200, Benjamin Stürz wrote:
> Replace comments with C99's designated initializers to improve
> readability and maintainability.
[]
> diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
[]
> @@ -2529,20 +2529,23 @@ static void clear_interrupt(ray_dev_t *local)
>  #define MAXDATA (PAGE_SIZE - 80)
>  
>  static const char *card_status[] = {
> -	"Card inserted - uninitialized",	/* 0 */
> -	"Card not downloaded",			/* 1 */
> -	"Waiting for download parameters",	/* 2 */
> -	"Card doing acquisition",		/* 3 */
> -	"Acquisition complete",			/* 4 */
> -	"Authentication complete",		/* 5 */
> -	"Association complete",			/* 6 */
> -	"???", "???", "???", "???",		/* 7 8 9 10 undefined */
> -	"Card init error",			/* 11 */
> -	"Download parameters error",		/* 12 */
> -	"???",					/* 13 */
> -	"Acquisition failed",			/* 14 */
> -	"Authentication refused",		/* 15 */
> -	"Association failed"			/* 16 */
> +	[CARD_INSERTED]		= "Card inserted - uninitialized",
> +	[CARD_AWAITING_PARAM]	= "Card not downloaded",
> +	[CARD_DL_PARAM]		= "Waiting for download parameters",
> +	[CARD_DOING_ACQ]	= "Card doing acquisition",
> +	[CARD_ACQ_COMPLETE]	= "Acquisition complete",
> +	[CARD_AUTH_COMPLETE]	= "Authentication complete",
> +	[CARD_ASSOC_COMPLETE]	= "Association complete",
> +	[7]			= "???",
> +	[8]			= "???",
> +	[9]			= "???",
> +	[10]			= "???",

Rather than using specific numbers and "???"
it's probably better to use no initialization at all
and change the output call to test the array index
ao all of the [number] = "???" could be removed.

---
 drivers/net/wireless/ray_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 87e98ab068ed..29451cd0a22a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -2600,7 +2600,7 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
 		i = 10;
 	if (i > 16)
 		i = 10;
-	seq_printf(m, "Card status          = %s\n", card_status[i]);
+	seq_printf(m, "Card status          = %s\n", card_status[i] ?: "???");
 
 	seq_printf(m, "Framing mode         = %s\n", framing[translate]);
 


  reply	other threads:[~2022-04-06 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06 15:22 [PATCH v4 0/2] wireless: " Benjamin Stürz
2022-04-06 15:22 ` [PATCH v4 1/2] " Benjamin Stürz
2022-04-06 17:58   ` Joe Perches [this message]
2022-04-06 15:22 ` [PATCH v4 2/2] ray_cs: Make card_status[] const Benjamin Stürz

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=1064228a2bb8a5fbdcb483295c641c100dd08c9f.camel@perches.com \
    --to=joe@perches.com \
    --cc=benni@stuerz.xyz \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@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®