diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2013-07-12 01:32:31 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-07-29 06:58:12 -0400 |
commit | 925403f425a4a9c503f2fc295652647b1eb10d82 (patch) | |
tree | eb3c1528de7ed53c3f6a5960e74c9fc1c36f6ace | |
parent | 519c6013d356fef95c9e45cfb533b3e68b47dbf4 (diff) |
usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro
Current usbhsx_for_each_xxx macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the binary which was
compiled by (at least) gcc 4.8.1 is broken
This patch tidyup these issues
Reported-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Reviewed-by: Takashi Yoshii <takashi.yoshii.zj@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_gadget.c | 6 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_host.c | 6 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/pipe.h | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 805940c37353..3385aeb5a364 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -77,9 +77,9 @@ struct usbhsg_recip_handle { | |||
77 | struct usbhsg_gpriv, mod) | 77 | struct usbhsg_gpriv, mod) |
78 | 78 | ||
79 | #define __usbhsg_for_each_uep(start, pos, g, i) \ | 79 | #define __usbhsg_for_each_uep(start, pos, g, i) \ |
80 | for (i = start, pos = (g)->uep + i; \ | 80 | for ((i) = start; \ |
81 | i < (g)->uep_size; \ | 81 | ((i) < (g)->uep_size) && ((pos) = (g)->uep + (i)); \ |
82 | i++, pos = (g)->uep + i) | 82 | (i)++) |
83 | 83 | ||
84 | #define usbhsg_for_each_uep(pos, gpriv, i) \ | 84 | #define usbhsg_for_each_uep(pos, gpriv, i) \ |
85 | __usbhsg_for_each_uep(1, pos, gpriv, i) | 85 | __usbhsg_for_each_uep(1, pos, gpriv, i) |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index b86815421c8d..e40f565004d0 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -111,9 +111,9 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
111 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) | 111 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) |
112 | 112 | ||
113 | #define __usbhsh_for_each_udev(start, pos, h, i) \ | 113 | #define __usbhsh_for_each_udev(start, pos, h, i) \ |
114 | for (i = start, pos = (h)->udev + i; \ | 114 | for ((i) = start; \ |
115 | i < USBHSH_DEVICE_MAX; \ | 115 | ((i) < USBHSH_DEVICE_MAX) && ((pos) = (h)->udev + (i)); \ |
116 | i++, pos = (h)->udev + i) | 116 | (i)++) |
117 | 117 | ||
118 | #define usbhsh_for_each_udev(pos, hpriv, i) \ | 118 | #define usbhsh_for_each_udev(pos, hpriv, i) \ |
119 | __usbhsh_for_each_udev(1, pos, hpriv, i) | 119 | __usbhsh_for_each_udev(1, pos, hpriv, i) |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index b476fde955bf..3e5349879838 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -54,9 +54,9 @@ struct usbhs_pipe_info { | |||
54 | * pipe list | 54 | * pipe list |
55 | */ | 55 | */ |
56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ | 56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ |
57 | for (i = start, pos = (info)->pipe + i; \ | 57 | for ((i) = start; \ |
58 | i < (info)->size; \ | 58 | ((i) < (info)->size) && ((pos) = (info)->pipe + (i)); \ |
59 | i++, pos = (info)->pipe + i) | 59 | (i)++) |
60 | 60 | ||
61 | #define usbhs_for_each_pipe(pos, priv, i) \ | 61 | #define usbhs_for_each_pipe(pos, priv, i) \ |
62 | __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) | 62 | __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) |