Skip to contentSkip to conversation

staging: lustre: libcfs: nidstrings.c - use ARRAY_SIZE macro

PATCH In review Anil Belur 2 participants 3 messages Jul 2, 2014 – Jul 9, 2014 Staging

lore
Share & tools
lore

Anil Belur

author
#0 lore raw

PATCH v2 1/1 staging: lustre: libcfs: nidstrings.c - use ARRAY_SIZE macro

From: Anil Belur <[email protected]>

- this patch replaces sizeof(a)/sizeof(a[0]) with the ARRAY_SIZE macro to get the number of nidstrings (and netstrfns)
- v2: also for netstrfns

---
 drivers/staging/lustre/lustre/libcfs/nidstrings.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/libcfs/nidstrings.c +2 -3
index 87705ae..4fc7b45 100644
@@ -74,8 +74,7 @@ libcfs_next_nidstring(void)
 	spin_lock_irqsave(&libcfs_nidstring_lock, flags);
 
 	str = libcfs_nidstrings[libcfs_nidstring_idx++];
-	if (libcfs_nidstring_idx ==
-	    sizeof(libcfs_nidstrings)/sizeof(libcfs_nidstrings[0]))
+	if (libcfs_nidstring_idx == ARRAY_SIZE(libcfs_nidstrings))
 		libcfs_nidstring_idx = 0;
 
 	spin_unlock_irqrestore(&libcfs_nidstring_lock, flags);
@@ -198,7 +197,7 @@ static struct netstrfns  libcfs_netstrfns[] = {
 	{/* .nf_type      */  -1},
 };
 
-const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]);
+const int libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
 
 int
 libcfs_lo_str2addr(const char *str, int nob, __u32 *addr)
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 7 lines · Anil Belur

From: Anil Belur <[email protected]>

- this patch replaces sizeof(a)/sizeof(a[0]) with the ARRAY_SIZE macro to get the number of nidstrings (and netstrfns)
- v2: also for netstrfns

Someone sent this same patch just before you did, sorry :(

#2 lore raw
Quoted 2 lines · Greg KH

Someone sent this same patch just before you did, sorry :(

Ah - no worries - sorry for the noise.