Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1725652 > unrolled thread

[PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7

Started byThomas Meyer <thomas@m3y3r.de>
First post2017-09-03 14:40 +0200
Last post2017-09-03 22:30 +0200
Articles 17 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7 Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 8/10] ath9k: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 4/10] drm/nouveau/bios/init: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 10/10] staging/atomisp: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 9/10] [SCSI] bfa: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
      Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro David Miller <davem@davemloft.net> - 2017-09-05 21:00 +0200
        Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-05 21:50 +0200
          Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro Joe Perches <joe@perches.com> - 2017-09-05 22:10 +0200
            Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro David Miller <davem@davemloft.net> - 2017-09-05 23:30 +0200
              Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-06 11:10 +0200
                Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro Joe Perches <joe@perches.com> - 2017-09-06 17:20 +0200
    [PATCH 2/10] drm/amdgpu: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    [PATCH 5/10] [media] lgdt3306a: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 14:40 +0200
    Re: [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7 Joe Perches <joe@perches.com> - 2017-09-03 17:40 +0200
      Re: [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7 Thomas Meyer <thomas@m3y3r.de> - 2017-09-03 22:00 +0200
        Re: [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7 Joe Perches <joe@perches.com> - 2017-09-03 22:30 +0200

#1725652 — [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7
Message-ID<ulClX-8pn-3@gated-at.bofh.it>
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.

Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Run against version v4.13-rc7

Let me know when you as a maintainer are not interested in these kind of patches.
I can exclude you by path; e.g. all findings in "drivers/scsi" will never
be reported again by this semi-automatic program runs.

[toc] | [next] | [standalone]


#1725653 — [PATCH 8/10] ath9k: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 8/10] ath9k: Use ARRAY_SIZE macro
Message-ID<ulClX-8pn-9@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 3dbfd86ebe36..c2e210c0a770 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -15,6 +15,7 @@
  */
 
 #include <asm/unaligned.h>
+#include <linux/kernel.h>
 #include "hw.h"
 #include "ar9003_phy.h"
 #include "ar9003_eeprom.h"
@@ -2946,14 +2947,12 @@ static const struct ar9300_eeprom *ar9300_eep_templates[] = {
 
 static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
 {
-#define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0]))
 	int it;
 
-	for (it = 0; it < N_LOOP; it++)
+	for (it = 0; it < ARRAY_SIZE(ar9300_eep_templates); it++)
 		if (ar9300_eep_templates[it]->templateVersion == id)
 			return ar9300_eep_templates[it];
 	return NULL;
-#undef N_LOOP
 }
 
 static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)

[toc] | [prev] | [next] | [standalone]


#1725655 — [PATCH 4/10] drm/nouveau/bios/init: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 4/10] drm/nouveau/bios/init: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-13@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
index b58ee99f7bfc..440efa333d6c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
@@ -21,6 +21,7 @@
  *
  * Authors: Ben Skeggs
  */
+#include <linux/kernel.h>
 #include <subdev/bios.h>
 #include <subdev/bios/bit.h>
 #include <subdev/bios/bmp.h>
@@ -2271,7 +2272,7 @@ static struct nvbios_init_opcode {
 	[0xaa] = { init_reserved },
 };
 
-#define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0]))
+#define init_opcode_nr (ARRAY_SIZE(init_opcode))
 
 int
 nvbios_exec(struct nvbios_init *init)

[toc] | [prev] | [next] | [standalone]


#1725656 — [PATCH 10/10] staging/atomisp: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 10/10] staging/atomisp: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-17@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/ifmtr/src/ifmtr.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/ifmtr/src/ifmtr.c
index a7c6bba7e094..11d3995ba0db 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/ifmtr/src/ifmtr.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/ifmtr/src/ifmtr.c
@@ -29,6 +29,7 @@ more details.
 #endif
 
 #include "system_global.h"
+#include <linux/kernel.h>
 
 #ifdef USE_INPUT_SYSTEM_VERSION_2
 
@@ -487,7 +488,7 @@ static void ifmtr_set_if_blocking_mode(
 {
 	int i;
 	bool block[] = { false, false, false, false };
-	assert(N_INPUT_FORMATTER_ID <= (sizeof(block) / sizeof(block[0])));
+	assert(N_INPUT_FORMATTER_ID <= (ARRAY_SIZE(block)));
 
 #if !defined(IS_ISP_2400_SYSTEM)
 #error "ifmtr_set_if_blocking_mode: ISP_SYSTEM must be one of {IS_ISP_2400_SYSTEM}"

[toc] | [prev] | [next] | [standalone]


#1725659 — [PATCH 9/10] [SCSI] bfa: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 9/10] [SCSI] bfa: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-21@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 3e1caec82554..4a03cd9fa63f 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -16,6 +16,7 @@
  * General Public License for more details.
  */
 
+#include <linux/kernel.h>
 #include "bfad_drv.h"
 #include "bfa_modules.h"
 #include "bfi_reg.h"
@@ -1957,7 +1958,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
 		{BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
 	};
 
-	*npciids = sizeof(__pciids) / sizeof(__pciids[0]);
+	*npciids = ARRAY_SIZE(__pciids);
 	*pciids = __pciids;
 }
 

[toc] | [prev] | [next] | [standalone]


#1725660 — [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-23@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 72d84a065e34..fabb11475fb4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -21,6 +21,7 @@
  *  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *
  ******************************************************************************/
+#include <linux/kernel.h>
 #include "ixgbe_x540.h"
 #include "ixgbe_type.h"
 #include "ixgbe_common.h"
@@ -947,7 +948,7 @@ static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
 	u16 length, bufsz, i, start;
 	u16 *local_buffer;
 
-	bufsz = sizeof(buf) / sizeof(buf[0]);
+	bufsz = ARRAY_SIZE(buf);
 
 	/* Read a chunk at the pointer location */
 	if (!buffer) {

[toc] | [prev] | [next] | [standalone]


#1726932 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromDavid Miller <davem@davemloft.net>
Date2017-09-05 21:00 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<umreO-6C4-17@gated-at.bofh.it>
In reply to#1725660
From: Thomas Meyer <thomas@m3y3r.de>
Date: Sun, 03 Sep 2017 14:19:31 +0200

> Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> yourself.
> Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> /ARRAY_SIZE(\1)/g' and manual check/verification.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

This should be submitted to the Intel ethernet driver maintainers.

Thank you.

[toc] | [prev] | [next] | [standalone]


#1726958 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-05 21:50 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<ums1b-7ak-11@gated-at.bofh.it>
In reply to#1726932
On Tue, Sep 05, 2017 at 11:50:44AM -0700, David Miller wrote:
> From: Thomas Meyer <thomas@m3y3r.de>
> Date: Sun, 03 Sep 2017 14:19:31 +0200
> 
> > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> > yourself.
> > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> > /ARRAY_SIZE(\1)/g' and manual check/verification.
> > 
> > Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> 
> This should be submitted to the Intel ethernet driver maintainers.
Hi,

my script checks the output of get_maintainer scripts and only sends to "open
list" entries.

The intel-wired-lan@lists.osuosl.org is moderated, so that's why the patch
wasn't send there.

Strangely the lists for nouveau@lists.freedesktop.org and
intel-gvt-dev@lists.freedesktop.org appears as open lists in the MAINTAINERS
file but seems to be also moderated lists... At least I got some reply that my
message awaits approval. Maybe an update to the MAINTAINERS file is missing
here?

I may drop above check in my script and send to all mailing lists that
get_maintainer.pl will return.

> 
> Thank you.

[toc] | [prev] | [next] | [standalone]


#1726962 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromJoe Perches <joe@perches.com>
Date2017-09-05 22:10 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<umskx-7wQ-15@gated-at.bofh.it>
In reply to#1726958
On Tue, 2017-09-05 at 21:45 +0200, Thomas Meyer wrote:
> On Tue, Sep 05, 2017 at 11:50:44AM -0700, David Miller wrote:
> > From: Thomas Meyer <thomas@m3y3r.de>
> > Date: Sun, 03 Sep 2017 14:19:31 +0200
> > 
> > > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> > > yourself.
> > > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> > > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> > > /ARRAY_SIZE(\1)/g' and manual check/verification.
> > > 
> > > Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> > 
> > This should be submitted to the Intel ethernet driver maintainers.
> 
> Hi,
> 
> my script checks the output of get_maintainer scripts and only sends to "open
> list" entries.
> 
> The intel-wired-lan@lists.osuosl.org is moderated, so that's why the patch
> wasn't send there.
> 
> Strangely the lists for nouveau@lists.freedesktop.org and
> intel-gvt-dev@lists.freedesktop.org appears as open lists in the MAINTAINERS
> file but seems to be also moderated lists... At least I got some reply that my
> message awaits approval. Maybe an update to the MAINTAINERS file is missing
> here?
> 
> I may drop above check in my script and send to all mailing lists that
> get_maintainer.pl will return.

There's a difference between moderated and subscriber-only
entries in MAINTAINERS.

get_maintainers will by default list moderated lists and
not show subscriber-only lists unless using the -s switch.

[toc] | [prev] | [next] | [standalone]


#1726993 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromDavid Miller <davem@davemloft.net>
Date2017-09-05 23:30 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<umtzY-8l4-19@gated-at.bofh.it>
In reply to#1726962
From: Joe Perches <joe@perches.com>
Date: Tue, 05 Sep 2017 13:01:18 -0700

> On Tue, 2017-09-05 at 21:45 +0200, Thomas Meyer wrote:
>> On Tue, Sep 05, 2017 at 11:50:44AM -0700, David Miller wrote:
>> > From: Thomas Meyer <thomas@m3y3r.de>
>> > Date: Sun, 03 Sep 2017 14:19:31 +0200
>> > 
>> > > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
>> > > yourself.
>> > > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
>> > > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
>> > > /ARRAY_SIZE(\1)/g' and manual check/verification.
>> > > 
>> > > Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
>> > 
>> > This should be submitted to the Intel ethernet driver maintainers.
>> 
>> Hi,
>> 
>> my script checks the output of get_maintainer scripts and only sends to "open
>> list" entries.
>> 
>> The intel-wired-lan@lists.osuosl.org is moderated, so that's why the patch
>> wasn't send there.
>> 
>> Strangely the lists for nouveau@lists.freedesktop.org and
>> intel-gvt-dev@lists.freedesktop.org appears as open lists in the MAINTAINERS
>> file but seems to be also moderated lists... At least I got some reply that my
>> message awaits approval. Maybe an update to the MAINTAINERS file is missing
>> here?
>> 
>> I may drop above check in my script and send to all mailing lists that
>> get_maintainer.pl will return.
> 
> There's a difference between moderated and subscriber-only
> entries in MAINTAINERS.
> 
> get_maintainers will by default list moderated lists and
> not show subscriber-only lists unless using the -s switch.

Furthermore, nothing prevented you from CC:'ing the maintainer,
Jeff Kirscher.

[toc] | [prev] | [next] | [standalone]


#1727259 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-06 11:10 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<umEvp-7XC-39@gated-at.bofh.it>
In reply to#1726993
On Tue, Sep 05, 2017 at 02:22:05PM -0700, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Tue, 05 Sep 2017 13:01:18 -0700
> 
> > On Tue, 2017-09-05 at 21:45 +0200, Thomas Meyer wrote:
> >> On Tue, Sep 05, 2017 at 11:50:44AM -0700, David Miller wrote:
> >> > From: Thomas Meyer <thomas@m3y3r.de>
> >> > Date: Sun, 03 Sep 2017 14:19:31 +0200
> >> > 
> >> > > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> >> > > yourself.
> >> > > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> >> > > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> >> > > /ARRAY_SIZE(\1)/g' and manual check/verification.
> >> > > 
> >> > > Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> >> > 
> >> > This should be submitted to the Intel ethernet driver maintainers.
> >> 
> >> Hi,
> >> 
> >> my script checks the output of get_maintainer scripts and only sends to "open
> >> list" entries.
> >> 
> >> The intel-wired-lan@lists.osuosl.org is moderated, so that's why the patch
> >> wasn't send there.
> >> 
> >> Strangely the lists for nouveau@lists.freedesktop.org and
> >> intel-gvt-dev@lists.freedesktop.org appears as open lists in the MAINTAINERS
> >> file but seems to be also moderated lists... At least I got some reply that my
> >> message awaits approval. Maybe an update to the MAINTAINERS file is missing
> >> here?
> >> 
> >> I may drop above check in my script and send to all mailing lists that
> >> get_maintainer.pl will return.
> > 
> > There's a difference between moderated and subscriber-only
> > entries in MAINTAINERS.
> > 
> > get_maintainers will by default list moderated lists and
> > not show subscriber-only lists unless using the -s switch.
> 
> Furthermore, nothing prevented you from CC:'ing the maintainer,
> Jeff Kirscher.

Hi,

That's the other condition in my script. I only send to the role
"maintainer" from the output of get_maintainer.pl. But Mr Jeff
Kirscher is only listed as supporter...

Anyway I did bounce the email to him.

with kind regards
thomas

[toc] | [prev] | [next] | [standalone]


#1727590 — Re: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro

FromJoe Perches <joe@perches.com>
Date2017-09-06 17:20 +0200
SubjectRe: [PATCH 6/10] ixgbe: Use ARRAY_SIZE macro
Message-ID<umKhs-3zl-11@gated-at.bofh.it>
In reply to#1727259
On Wed, 2017-09-06 at 11:08 +0200, Thomas Meyer wrote:
> On Tue, Sep 05, 2017 at 02:22:05PM -0700, David Miller wrote:
> > nothing prevented you from CC:'ing the maintainer,
> > Jeff Kirscher.
[]
> That's the other condition in my script. I only send to the role
> "maintainer" from the output of get_maintainer.pl. But Mr Jeff
> Kirscher is only listed as supporter...

Supporter means he gets paid to look after that
subsystem so he is something other than a volunteer.

from MAINTAINERS:
	S: Status, one of the following:
	   Supported:	Someone is actually paid to look after this.
	   Maintained:	Someone actually looks after it.
	   Odd Fixes:	It has a maintainer but they don't have time to do
			much other than throw the odd patch in. See below..
	   Orphan:	No current maintainer [but maybe you could take the
			role as you write your new code].
	   Obsolete:	Old code. Something tagged obsolete generally means
			it has been replaced by a better system and you
			should be using that.

[toc] | [prev] | [next] | [standalone]


#1725661 — [PATCH 2/10] drm/amdgpu: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 2/10] drm/amdgpu: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-27@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
index 9804318f3488..7ef84d884714 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
@@ -20,6 +20,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+#include <linux/kernel.h>
+
 #include "amdgpu.h"
 #include "mmhub_v1_0.h"
 
@@ -268,7 +270,7 @@ const struct pctl_data pctl0_data[] = {
     {0x135, 0x12a810},
     {0x149, 0x7a82c}
 };
-#define PCTL0_DATA_LEN (sizeof(pctl0_data)/sizeof(pctl0_data[0]))
+#define PCTL0_DATA_LEN (ARRAY_SIZE(pctl0_data))
 
 #define PCTL0_RENG_EXEC_END_PTR 0x151
 #define PCTL0_STCTRL_REG_SAVE_RANGE0_BASE  0xa640
@@ -297,7 +299,7 @@ const struct pctl_data pctl1_data[] = {
     {0x1be, 0x17a7dd},
     {0x1d7, 0x12a810}
 };
-#define PCTL1_DATA_LEN (sizeof(pctl1_data)/sizeof(pctl1_data[0]))
+#define PCTL1_DATA_LEN (ARRAY_SIZE(pctl1_data))
 
 #define PCTL1_RENG_EXEC_END_PTR 0x1ea
 #define PCTL1_STCTRL_REG_SAVE_RANGE0_BASE  0xa000

[toc] | [prev] | [next] | [standalone]


#1725662 — [PATCH 5/10] [media] lgdt3306a: Use ARRAY_SIZE macro

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 14:40 +0200
Subject[PATCH 5/10] [media] lgdt3306a: Use ARRAY_SIZE macro
Message-ID<ulClY-8pn-25@gated-at.bofh.it>
In reply to#1725652
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index c9b1eb38444e..724e9aac0f11 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -19,6 +19,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <asm/div64.h>
+#include <linux/kernel.h>
 #include <linux/dvb/frontend.h>
 #include "dvb_math.h"
 #include "lgdt3306a.h"
@@ -2072,7 +2073,7 @@ static const short regtab[] = {
 	0x30aa, /* MPEGLOCK */
 };
 
-#define numDumpRegs (sizeof(regtab)/sizeof(regtab[0]))
+#define numDumpRegs (ARRAY_SIZE(regtab))
 static u8 regval1[numDumpRegs] = {0, };
 static u8 regval2[numDumpRegs] = {0, };
 

[toc] | [prev] | [next] | [standalone]


#1725705

FromJoe Perches <joe@perches.com>
Date2017-09-03 17:40 +0200
Message-ID<ulFab-1GL-31@gated-at.bofh.it>
In reply to#1725652
On Sun, 2017-09-03 at 14:19 +0200, Thomas Meyer wrote:
> Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> yourself.
> 
> Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> /ARRAY_SIZE(\1)/g' and manual check/verification.

Hey Thomas.

There are some instances that span multiple lines that
the regex above misses.

For instance:

diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index 3d701c7a4c91..26a825bd7581 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -929,8 +929,7 @@ static int mlx5_ib_mr_initiator_pfault_handler(
                return -EFAULT;
        }
 
-       if (unlikely(opcode >= sizeof(mlx5_ib_odp_opcode_cap) /
-           sizeof(mlx5_ib_odp_opcode_cap[0]) ||
+       if (unlikely(opcode >= ARRAY_SIZE(mlx5_ib_odp_opcode_cap) ||

Here is another perl command regex that fixes a few more:

$ perl -i -e 'local $/; while (<>) { s/\bsizeof\s*\(\s*(\w+)\s*\)\s*\/\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)/ARRAY_SIZE(\1)/g; print; }' $file

This regex could still miss variants that
have a comment or that don't use parentheses
around the sizeof.

It seems none of those styles exist though.

[toc] | [prev] | [next] | [standalone]


#1725741

FromThomas Meyer <thomas@m3y3r.de>
Date2017-09-03 22:00 +0200
Message-ID<ulJdM-45k-9@gated-at.bofh.it>
In reply to#1725705
On Sun, Sep 03, 2017 at 08:36:02AM -0700, Joe Perches wrote:
> On Sun, 2017-09-03 at 14:19 +0200, Thomas Meyer wrote:
> > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> > yourself.
> > 
> > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> > /ARRAY_SIZE(\1)/g' and manual check/verification.
> 
> Hey Thomas.

Hi Joe,
> 
> There are some instances that span multiple lines that
> the regex above misses.
> 
> For instance:
> 
> diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
> index 3d701c7a4c91..26a825bd7581 100644
> --- a/drivers/infiniband/hw/mlx5/odp.c
> +++ b/drivers/infiniband/hw/mlx5/odp.c
> @@ -929,8 +929,7 @@ static int mlx5_ib_mr_initiator_pfault_handler(
>                 return -EFAULT;
>         }
>  
> -       if (unlikely(opcode >= sizeof(mlx5_ib_odp_opcode_cap) /
> -           sizeof(mlx5_ib_odp_opcode_cap[0]) ||
> +       if (unlikely(opcode >= ARRAY_SIZE(mlx5_ib_odp_opcode_cap) ||
> 
> Here is another perl command regex that fixes a few more:
> 
> $ perl -i -e 'local $/; while (<>) { s/\bsizeof\s*\(\s*(\w+)\s*\)\s*\/\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)/ARRAY_SIZE(\1)/g; print; }' $file
> 
> This regex could still miss variants that
> have a comment or that don't use parentheses
> around the sizeof.

Okay, fine, but I think this patch series is okay to go in anyway. I will
re-run with above regex after the next rcX tag. Would that be fine for you?
What do you think?

> 
> It seems none of those styles exist though.
> 

[toc] | [prev] | [next] | [standalone]


#1725750

FromJoe Perches <joe@perches.com>
Date2017-09-03 22:30 +0200
Message-ID<ulJGN-4tT-7@gated-at.bofh.it>
In reply to#1725741
On Sun, 2017-09-03 at 21:59 +0200, Thomas Meyer wrote:
> On Sun, Sep 03, 2017 at 08:36:02AM -0700, Joe Perches wrote:
> > On Sun, 2017-09-03 at 14:19 +0200, Thomas Meyer wrote:
> > > Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> > > yourself.
> > > 
> > > Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> > > 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> > > /ARRAY_SIZE(\1)/g' and manual check/verification.
> > 
> > Hey Thomas.
> 
> Hi Joe,
> > 
> > There are some instances that span multiple lines that
> > the regex above misses.
> > 
> > For instance:
> > 
> > diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
> > index 3d701c7a4c91..26a825bd7581 100644
> > --- a/drivers/infiniband/hw/mlx5/odp.c
> > +++ b/drivers/infiniband/hw/mlx5/odp.c
> > @@ -929,8 +929,7 @@ static int mlx5_ib_mr_initiator_pfault_handler(
> >                 return -EFAULT;
> >         }
> >  
> > -       if (unlikely(opcode >= sizeof(mlx5_ib_odp_opcode_cap) /
> > -           sizeof(mlx5_ib_odp_opcode_cap[0]) ||
> > +       if (unlikely(opcode >= ARRAY_SIZE(mlx5_ib_odp_opcode_cap) ||
> > 
> > Here is another perl command regex that fixes a few more:
> > 
> > $ perl -i -e 'local $/; while (<>) { s/\bsizeof\s*\(\s*(\w+)\s*\)\s*\/\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)/ARRAY_SIZE(\1)/g; print; }' $file
> > 
> > This regex could still miss variants that
> > have a comment or that don't use parentheses
> > around the sizeof.
> 
> Okay, fine, but I think this patch series is okay to go in anyway. I will
> re-run with above regex after the next rcX tag. Would that be fine for you?
> What do you think?

I think whatever you want to do is fine with me.

If you want, you could use the simple cocci script below
which is _much_ better than the perl regex as it can
find all the appropriate cases not just
	sizeof(var)/sizeof(var[0])

$ cat array_size.cocci
@@
type T;
T[] E;
@@

(
- sizeof(E) /sizeof(*E)
+ ARRAY_SIZE(E)
|
- sizeof(E) /sizeof(E[...])
+ ARRAY_SIZE(E)
|
- sizeof(E) /sizeof(T)
+ ARRAY_SIZE(E)
)
$ 

and maybe this

$ spatch --in-place --all-includes --sp-file array_size.cocci .

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web