All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Cripps <acripps@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] Re: [PATCH ARRAY_SIZE 4/4] kernel 2.6 size macro clean ups in
Date: Tue, 29 May 2007 21:12:36 +0000	[thread overview]
Message-ID: <465C9A14.2060702@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: srfArray_Size.patch --]
[-- Type: text/plain, Size: 3272 bytes --]

Went through and removed the MAX_EVCS and MAX_INIT_EVC macros in favor of
using the ARRAY_SIZE(arr) defined in kernel.h
Compile tested, no issues found.
Signed-off-by: Aaron Cripps <cripps@cs.mun.ca>

diff -Nuar linux-2.6/drivers/net/skfp/srf.c linux-2.6-patched/drivers/net/skfp/srf.c
--- linux-2.6/drivers/net/skfp/srf.c	2007-05-22 20:31:05.000000000 -0230
+++ linux-2.6-patched/drivers/net/skfp/srf.c	2007-05-25 22:40:20.000000000 -0230
@@ -23,7 +23,7 @@
 #include "h/fddi.h"
 #include "h/smc.h"
 #include "h/smt_p.h"
-
+#include <include/linux/kernel.h>
 #define KERNEL
 #include "h/smtstate.h"
 
@@ -43,8 +43,6 @@
 static void smt_send_srf(struct s_smc *smc);
 static struct s_srf_evc *smt_get_evc(struct s_smc *smc, int code, int index);
 
-#define MAX_EVCS	(sizeof(smc->evcs)/sizeof(smc->evcs[0]))
-
 struct evc_init {
 	u_char code ;
 	u_char index ;
@@ -67,8 +65,6 @@
 	{ SMT_EVENT_PORT_PATH_CHANGE,		INDEX_PORT,NUMPHYS,SMT_P4053 } ,
 } ;
 
-#define MAX_INIT_EVC	(sizeof(evc_inits)/sizeof(evc_inits[0]))
-
 void smt_init_evc(struct s_smc *smc)
 {
 	struct s_srf_evc	*evc ;
@@ -84,7 +80,7 @@
 	evc = smc->evcs ;
 	init = evc_inits ;
 
-	for (i = 0 ; (unsigned) i < MAX_INIT_EVC ; i++) {
+	for (i = 0 ; (unsigned) i < ARRAY_SIZE(evc_inits) ; i++) {
 		for (index = 0 ; index < init->n ; index++) {
 			evc->evc_code = init->code ;
 			evc->evc_para = init->para ;
@@ -98,7 +94,7 @@
 		init++ ;
 	}
 
-	if ((unsigned) (evc - smc->evcs) > MAX_EVCS) {
+	if ((unsigned) (evc - smc->evcs) > ARRAY_SIZE(smc->evcs)) {
 		SMT_PANIC(smc,SMT_E0127, SMT_E0127_MSG) ;
 	}
 
@@ -139,7 +135,8 @@
 		offset++ ;
 	}
 #ifdef	DEBUG
-	for (i = 0, evc = smc->evcs ; (unsigned) i < MAX_EVCS ; i++, evc++) {
+	for (i = 0, evc = smc->evcs ; 
+			(unsigned) i < ARRAY_SIZE(smc->evcs) ; i++, evc++) {
 		if (SMT_IS_CONDITION(evc->evc_code)) {
 			if (!evc->evc_cond_state) {
 				SMT_PANIC(smc,SMT_E0128, SMT_E0128_MSG) ;
@@ -163,7 +160,8 @@
 	int			i ;
 	struct s_srf_evc	*evc ;
 
-	for (i = 0, evc = smc->evcs ; (unsigned) i < MAX_EVCS ; i++, evc++) {
+	for (i = 0, evc = smc->evcs ;
+			(unsigned) i < ARRAY_SIZE(smc->evcs) ; i++, evc++) {
 		if (evc->evc_code == code && evc->evc_index == index)
 			return(evc) ;
 	}
@@ -337,7 +335,8 @@
 	struct s_srf_evc	*evc ;
 	int			i ;
 
-	for (i = 0, evc = smc->evcs ; (unsigned) i < MAX_EVCS ; i++, evc++) {
+	for (i = 0, evc = smc->evcs ;
+			(unsigned) i < ARRAY_SIZE(smc->evcs) ; i++, evc++) {
 		evc->evc_rep_required = FALSE ;
 		if (SMT_IS_CONDITION(evc->evc_code))
 			*evc->evc_cond_state = FALSE ;
@@ -351,7 +350,8 @@
 	int			i ;
 
 	smc->srf.any_report = FALSE ;
-	for (i = 0, evc = smc->evcs ; (unsigned) i < MAX_EVCS ; i++, evc++) {
+	for (i = 0, evc = smc->evcs ;
+			(unsigned) i < ARRAY_SIZE(smc->evcs) ; i++, evc++) {
 		if (SMT_IS_CONDITION(evc->evc_code)) {
 			if (*evc->evc_cond_state == FALSE)
 				evc->evc_rep_required = FALSE ;
@@ -405,7 +405,8 @@
 	smt_add_para(smc,&pcon,(u_short) SMT_P1033,0,0) ;
 	smt_add_para(smc,&pcon,(u_short) SMT_P1034,0,0) ;
 
-	for (i = 0, evc = smc->evcs ; (unsigned) i < MAX_EVCS ; i++, evc++) {
+	for (i = 0, evc = smc->evcs ;
+			(unsigned) i < ARRAY_SIZE(smc->evcs) ; i++, evc++) {
 		if (evc->evc_rep_required) {
 			smt_add_para(smc,&pcon,evc->evc_para,
 				(int)evc->evc_index,0) ;


[-- Attachment #3: Type: text/plain, Size: 187 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

             reply	other threads:[~2007-05-29 21:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-29 21:12 Aaron Cripps [this message]
2007-05-30 12:12 ` [KJ] Re: [PATCH ARRAY_SIZE 4/4] kernel 2.6 size macro clean ups Robert P. J. Day

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=465C9A14.2060702@gmail.com \
    --to=acripps@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.