* [PATCH] usb: Replace empty define with do while
@ 2018-06-07 20:05 ` Corentin Labbe
0 siblings, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2018-06-07 20:05 UTC (permalink / raw)
To: gregkh, stern; +Cc: linux-kernel, linux-usb, Corentin Labbe
It's dangerous to use empty code define.
Furthermore it lead to the following warning:
"suggest braces around empty body in an « else » statement"
So let's replace emptyness by "do {} while(0)"
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
drivers/usb/host/ehci.h | 2 +-
drivers/usb/host/fotg210.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index c8e9a48e1d51..a60d91eac771 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -237,7 +237,7 @@ struct ehci_hcd { /* one per controller */
struct ehci_stats stats;
# define COUNT(x) ((x)++)
#else
-# define COUNT(x)
+# define COUNT(x) do {} while (0)
#endif
/* debug files */
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
index 7fcd785c7bc8..dca46d04e288 100644
--- a/drivers/usb/host/fotg210.h
+++ b/drivers/usb/host/fotg210.h
@@ -179,7 +179,7 @@ struct fotg210_hcd { /* one per controller */
struct fotg210_stats stats;
# define COUNT(x) ((x)++)
#else
-# define COUNT(x)
+# define COUNT(x) do {} while (0)
#endif
/* debug files */
--
2.16.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* usb: Replace empty define with do while
@ 2018-06-07 20:05 ` Corentin Labbe
0 siblings, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2018-06-07 20:05 UTC (permalink / raw)
To: gregkh, stern; +Cc: linux-kernel, linux-usb, Corentin Labbe
It's dangerous to use empty code define.
Furthermore it lead to the following warning:
"suggest braces around empty body in an « else » statement"
So let's replace emptyness by "do {} while(0)"
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
drivers/usb/host/ehci.h | 2 +-
drivers/usb/host/fotg210.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index c8e9a48e1d51..a60d91eac771 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -237,7 +237,7 @@ struct ehci_hcd { /* one per controller */
struct ehci_stats stats;
# define COUNT(x) ((x)++)
#else
-# define COUNT(x)
+# define COUNT(x) do {} while (0)
#endif
/* debug files */
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
index 7fcd785c7bc8..dca46d04e288 100644
--- a/drivers/usb/host/fotg210.h
+++ b/drivers/usb/host/fotg210.h
@@ -179,7 +179,7 @@ struct fotg210_hcd { /* one per controller */
struct fotg210_stats stats;
# define COUNT(x) ((x)++)
#else
-# define COUNT(x)
+# define COUNT(x) do {} while (0)
#endif
/* debug files */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: Replace empty define with do while
@ 2018-06-07 20:16 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2018-06-07 20:16 UTC (permalink / raw)
To: Corentin Labbe, gregkh, stern; +Cc: linux-kernel, linux-usb
On Thu, 2018-06-07 at 20:05 +0000, Corentin Labbe wrote:
> It's dangerous to use empty code define.
> Furthermore it lead to the following warning:
> "suggest braces around empty body in an « else » statement"
>
> So let's replace emptyness by "do {} while(0)"
I also suggest renaming COUNT to something more
intelligible like INCR as the uses are all for
incrementing variables that may not exist.
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index c8e9a48e1d51..a60d91eac771 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -237,7 +237,7 @@ struct ehci_hcd { /* one per controller */
> struct ehci_stats stats;
> # define COUNT(x) ((x)++)
> #else
> -# define COUNT(x)
> +# define COUNT(x) do {} while (0)
> #endif
>
> /* debug files */
> diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
> index 7fcd785c7bc8..dca46d04e288 100644
> --- a/drivers/usb/host/fotg210.h
> +++ b/drivers/usb/host/fotg210.h
> @@ -179,7 +179,7 @@ struct fotg210_hcd { /* one per controller */
> struct fotg210_stats stats;
> # define COUNT(x) ((x)++)
> #else
> -# define COUNT(x)
> +# define COUNT(x) do {} while (0)
> #endif
>
> /* debug files */
^ permalink raw reply [flat|nested] 4+ messages in thread
* usb: Replace empty define with do while
@ 2018-06-07 20:16 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2018-06-07 20:16 UTC (permalink / raw)
To: Corentin Labbe, gregkh, stern; +Cc: linux-kernel, linux-usb
On Thu, 2018-06-07 at 20:05 +0000, Corentin Labbe wrote:
> It's dangerous to use empty code define.
> Furthermore it lead to the following warning:
> "suggest braces around empty body in an « else » statement"
>
> So let's replace emptyness by "do {} while(0)"
I also suggest renaming COUNT to something more
intelligible like INCR as the uses are all for
incrementing variables that may not exist.
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index c8e9a48e1d51..a60d91eac771 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -237,7 +237,7 @@ struct ehci_hcd { /* one per controller */
> struct ehci_stats stats;
> # define COUNT(x) ((x)++)
> #else
> -# define COUNT(x)
> +# define COUNT(x) do {} while (0)
> #endif
>
> /* debug files */
> diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
> index 7fcd785c7bc8..dca46d04e288 100644
> --- a/drivers/usb/host/fotg210.h
> +++ b/drivers/usb/host/fotg210.h
> @@ -179,7 +179,7 @@ struct fotg210_hcd { /* one per controller */
> struct fotg210_stats stats;
> # define COUNT(x) ((x)++)
> #else
> -# define COUNT(x)
> +# define COUNT(x) do {} while (0)
> #endif
>
> /* debug files */
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-07 20:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 20:05 [PATCH] usb: Replace empty define with do while Corentin Labbe
2018-06-07 20:05 ` Corentin Labbe
2018-06-07 20:16 ` [PATCH] " Joe Perches
2018-06-07 20:16 ` Joe Perches
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.