* [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate
[not found] <20070205165429.GD3896@Ahmed>
@ 2007-02-05 16:59 ` Ahmed S. Darwish
2007-02-05 20:22 ` Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: Ahmed S. Darwish @ 2007-02-05 16:59 UTC (permalink / raw)
To: ebs; +Cc: netdev, linux-kernel, linuxppc-embedded
Hi,
A patch to use ARRAY_SIZE macro already defined in kernel.h.
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
---
Patch isn't compile-tested cause I don't have the needed hardware.
diff --git a/drivers/net/ibm_emac/ibm_emac_debug.c b/drivers/net/ibm_emac/ibm_emac_debug.c
index 92f970d..1f70906 100644
--- a/drivers/net/ibm_emac/ibm_emac_debug.c
+++ b/drivers/net/ibm_emac/ibm_emac_debug.c
@@ -132,7 +132,7 @@ void emac_dbg_register(int idx, struct ocp_enet_private *dev)
{
unsigned long flags;
- if (idx >= sizeof(__emacs) / sizeof(__emacs[0])) {
+ if (idx >= ARRAY_SIZE(__emacs)) {
printk(KERN_WARNING
"invalid index %d when registering EMAC for debugging\n",
idx);
@@ -148,7 +148,7 @@ void mal_dbg_register(int idx, struct ibm_ocp_mal *mal)
{
unsigned long flags;
- if (idx >= sizeof(__mals) / sizeof(__mals[0])) {
+ if (idx >= ARRAY_SIZE(__mals)) {
printk(KERN_WARNING
"invalid index %d when registering MAL for debugging\n",
idx);
@@ -167,11 +167,11 @@ void emac_dbg_dump_all(void)
local_irq_save(flags);
- for (i = 0; i < sizeof(__mals) / sizeof(__mals[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(__mals); ++i)
if (__mals[i])
emac_mal_dump(__mals[i]);
- for (i = 0; i < sizeof(__emacs) / sizeof(__emacs[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(__emacs); ++i)
if (__emacs[i])
emac_mac_dump(i, __emacs[i]);
--
Ahmed S. Darwish
http://darwish-07.blogspot.com
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate
2007-02-05 16:59 ` [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate Ahmed S. Darwish
@ 2007-02-05 20:22 ` Alexey Dobriyan
2007-02-06 9:12 ` Ahmed S. Darwish
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2007-02-05 20:22 UTC (permalink / raw)
To: Ahmed S. Darwish; +Cc: netdev, linuxppc-embedded, linux-kernel
On Mon, Feb 05, 2007 at 06:59:16PM +0200, Ahmed S. Darwish wrote:
> A patch to use ARRAY_SIZE macro already defined in kernel.h.
OK, but checks you're changing are strange. idx there is signed so
BUG_ON(idx < 0 || idx > ARRAY_SIZE());
should be more appropriate.
> --- a/drivers/net/ibm_emac/ibm_emac_debug.c
> +++ b/drivers/net/ibm_emac/ibm_emac_debug.c
> @@ -132,7 +132,7 @@ void emac_dbg_register(int idx, struct ocp_enet_private *dev)
> {
> unsigned long flags;
>
> - if (idx >= sizeof(__emacs) / sizeof(__emacs[0])) {
> + if (idx >= ARRAY_SIZE(__emacs)) {
no __vi, no cookie. :)
> printk(KERN_WARNING
> "invalid index %d when registering EMAC for debugging\n",
> idx);
> @@ -148,7 +148,7 @@ void mal_dbg_register(int idx, struct ibm_ocp_mal *mal)
> {
> unsigned long flags;
>
> - if (idx >= sizeof(__mals) / sizeof(__mals[0])) {
> + if (idx >= ARRAY_SIZE(__mals)) {
> printk(KERN_WARNING
> "invalid index %d when registering MAL for debugging\n",
> idx);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate
2007-02-05 20:22 ` Alexey Dobriyan
@ 2007-02-06 9:12 ` Ahmed S. Darwish
0 siblings, 0 replies; 3+ messages in thread
From: Ahmed S. Darwish @ 2007-02-06 9:12 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: netdev, linuxppc-embedded, linux-kernel
On Mon, Feb 05, 2007 at 11:22:06PM +0300, Alexey Dobriyan wrote:
> On Mon, Feb 05, 2007 at 06:59:16PM +0200, Ahmed S. Darwish wrote:
> > A patch to use ARRAY_SIZE macro already defined in kernel.h.
>
> OK, but checks you're changing are strange. idx there is signed so
>
> BUG_ON(idx < 0 || idx > ARRAY_SIZE());
>
> should be more appropriate.
It's just a janitor patch. I don't like to mess with code logic in such
kind of patches (to minimize errors and because I can't find time to
understand all affected files since they are scattered allover the tree).
Thanks,
--
Ahmed S. Darwish
http://darwish-07.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-06 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20070205165429.GD3896@Ahmed>
2007-02-05 16:59 ` [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate Ahmed S. Darwish
2007-02-05 20:22 ` Alexey Dobriyan
2007-02-06 9:12 ` Ahmed S. Darwish
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).