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


Groups > linux.kernel > #1724288

[PATCH v2] ipv6: sr: Use ARRAY_SIZE macro

From Thomas Meyer <thomas@m3y3r.de>
Newsgroups linux.kernel
Subject [PATCH v2] ipv6: sr: Use ARRAY_SIZE macro
Date 2017-08-31 16:30 +0200
Message-ID <ukyDM-6JK-23@gated-at.bofh.it> (permalink)
References <ukxon-62o-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Grepping for "sizeof\(.+\) / sizeof\(" found this as one of the first
candidates.
Maybe a coccinelle can catch all of those.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 net/ipv6/seg6_hmac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index f950cb53d5e3..33fb35cbfac1 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -12,6 +12,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
@@ -110,7 +111,7 @@ static struct seg6_hmac_algo *__hmac_get_algo(u8 alg_id)
 	struct seg6_hmac_algo *algo;
 	int i, alg_count;
 
-	alg_count = sizeof(hmac_algos) / sizeof(struct seg6_hmac_algo);
+	alg_count = ARRAY_SIZE(hmac_algos);
 	for (i = 0; i < alg_count; i++) {
 		algo = &hmac_algos[i];
 		if (algo->alg_id == alg_id)
@@ -360,7 +361,7 @@ static int seg6_hmac_init_algo(void)
 	struct shash_desc *shash;
 	int i, alg_count, cpu;
 
-	alg_count = sizeof(hmac_algos) / sizeof(struct seg6_hmac_algo);
+	alg_count = ARRAY_SIZE(hmac_algos);
 
 	for (i = 0; i < alg_count; i++) {
 		struct crypto_shash **p_tfm;
@@ -421,7 +422,7 @@ void seg6_hmac_exit(void)
 	struct seg6_hmac_algo *algo = NULL;
 	int i, alg_count, cpu;
 
-	alg_count = sizeof(hmac_algos) / sizeof(struct seg6_hmac_algo);
+	alg_count = ARRAY_SIZE(hmac_algos);
 	for (i = 0; i < alg_count; i++) {
 		algo = &hmac_algos[i];
 		for_each_possible_cpu(cpu) {
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] vt: Use bsearch library function in is_double_width Thomas Meyer <thomas@m3y3r.de> - 2017-08-31 15:10 +0200
  Re: [PATCH] vt: Use bsearch library function in is_double_width Greg KH <gregkh@linuxfoundation.org> - 2017-08-31 15:40 +0200
  [PATCH v2] ipv6: sr: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-08-31 16:30 +0200
    Re: [PATCH v2] ipv6: sr: Use ARRAY_SIZE macro Greg KH <gregkh@linuxfoundation.org> - 2017-08-31 17:10 +0200
      Re: [PATCH v2] ipv6: sr: Use ARRAY_SIZE macro Thomas Meyer <thomas@m3y3r.de> - 2017-09-01 01:20 +0200
  [PATCH v2] vt: Use bsearch library function in is_double_width Thomas Meyer <thomas@m3y3r.de> - 2017-08-31 16:30 +0200
    Re: [PATCH v2] vt: Use bsearch library function in is_double_width Greg KH <gregkh@linuxfoundation.org> - 2017-08-31 17:10 +0200
      Re: [PATCH v2] vt: Use bsearch library function in is_double_width Thomas Meyer <thomas@m3y3r.de> - 2017-09-01 01:30 +0200

csiph-web