linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] replace for loop with array initializer
@ 2021-07-12 19:24 Salah Triki
  2021-07-12 20:05 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Salah Triki @ 2021-07-12 19:24 UTC (permalink / raw)
  To: kevin.curtis, davem, kuba; +Cc: netdev, linux-kernel

Replace for loop with array initializer in order to make code more clean.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/net/wan/farsync.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index b3466e084e84..a90d3b9a8170 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -567,7 +567,7 @@ static void fst_process_int_work_q(struct tasklet_struct *unused);
 static DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q);
 static DECLARE_TASKLET(fst_int_task, fst_process_int_work_q);
 
-static struct fst_card_info *fst_card_array[FST_MAX_CARDS];
+static struct fst_card_info *fst_card_array[FST_MAX_CARDS] = { [0 ... FST_MAX_CARDS-1] = NULL };
 static DEFINE_SPINLOCK(fst_work_q_lock);
 static u64 fst_work_txq;
 static u64 fst_work_intq;
@@ -2565,10 +2565,6 @@ static struct pci_driver fst_driver = {
 static int __init
 fst_init(void)
 {
-	int i;
-
-	for (i = 0; i < FST_MAX_CARDS; i++)
-		fst_card_array[i] = NULL;
 	return pci_register_driver(&fst_driver);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] replace for loop with array initializer
  2021-07-12 19:24 [PATCH] replace for loop with array initializer Salah Triki
@ 2021-07-12 20:05 ` Stephen Hemminger
  2021-07-14  4:08   ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2021-07-12 20:05 UTC (permalink / raw)
  To: Salah Triki; +Cc: kevin.curtis, davem, kuba, netdev, linux-kernel

On Mon, 12 Jul 2021 20:24:50 +0100
Salah Triki <salah.triki@gmail.com> wrote:

> diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
> index b3466e084e84..a90d3b9a8170 100644
> --- a/drivers/net/wan/farsync.c
> +++ b/drivers/net/wan/farsync.c
> @@ -567,7 +567,7 @@ static void fst_process_int_work_q(struct tasklet_struct *unused);
>  static DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q);
>  static DECLARE_TASKLET(fst_int_task, fst_process_int_work_q);
>  
> -static struct fst_card_info *fst_card_array[FST_MAX_CARDS];
> +static struct fst_card_info *fst_card_array[FST_MAX_CARDS] = { [0 ... FST_MAX_CARDS-1] = NULL };

Why bother, the default initialization in C is 0 (ie. NULL).
In fact, checkpatch should complain about useless array initialization for this.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] replace for loop with array initializer
  2021-07-12 20:05 ` Stephen Hemminger
@ 2021-07-14  4:08   ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2021-07-14  4:08 UTC (permalink / raw)
  To: Stephen Hemminger, Salah Triki
  Cc: kevin.curtis, davem, kuba, netdev, linux-kernel

On Mon, 2021-07-12 at 13:05 -0700, Stephen Hemminger wrote:
> On Mon, 12 Jul 2021 20:24:50 +0100 Salah Triki <salah.triki@gmail.com> wrote:
> > diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
[]
> > +static struct fst_card_info *fst_card_array[FST_MAX_CARDS] = { [0 ... FST_MAX_CARDS-1] = NULL };
> 
> Why bother, the default initialization in C is 0 (ie. NULL).
> In fact, checkpatch should complain about useless array initialization for this.

I'll look out for your patch to checkpatch.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-14  4:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 19:24 [PATCH] replace for loop with array initializer Salah Triki
2021-07-12 20:05 ` Stephen Hemminger
2021-07-14  4:08   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).