qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: remove unnecessary local from __get_user(), __put_user()
@ 2010-11-08 18:13 Peter Maydell
  2010-11-15  8:00 ` Riku Voipio
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2010-11-08 18:13 UTC (permalink / raw)
  To: qemu-devel

Remove an unnecessary local variable from the __get_user() and
__put_user() macros. This avoids confusing compilation failures
if the name of the local variable ('size') happens to be the
same as the variable the macro user is trying to read/write.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/qemu.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 708021e..d717392 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -266,8 +266,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
  */
 #define __put_user(x, hptr)\
 ({\
-    int size = sizeof(*hptr);\
-    switch(size) {\
+    switch(sizeof(*hptr)) {\
     case 1:\
         *(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
         break;\
@@ -288,8 +287,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
 
 #define __get_user(x, hptr) \
 ({\
-    int size = sizeof(*hptr);\
-    switch(size) {\
+    switch(sizeof(*hptr)) {\
     case 1:\
         x = (typeof(*hptr))*(uint8_t *)(hptr);\
         break;\
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: remove unnecessary local from __get_user(), __put_user()
  2010-11-08 18:13 [Qemu-devel] [PATCH] linux-user: remove unnecessary local from __get_user(), __put_user() Peter Maydell
@ 2010-11-15  8:00 ` Riku Voipio
  0 siblings, 0 replies; 2+ messages in thread
From: Riku Voipio @ 2010-11-15  8:00 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Mon, Nov 08, 2010 at 06:13:58PM +0000, Peter Maydell wrote:
> Remove an unnecessary local variable from the __get_user() and
> __put_user() macros. This avoids confusing compilation failures
> if the name of the local variable ('size') happens to be the
> same as the variable the macro user is trying to read/write.

Looks fine, will push on my next patchset

Acked-by: Riku Voipio <riku.voipio@iki.fi>
 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  linux-user/qemu.h |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
> index 708021e..d717392 100644
> --- a/linux-user/qemu.h
> +++ b/linux-user/qemu.h
> @@ -266,8 +266,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
>   */
>  #define __put_user(x, hptr)\
>  ({\
> -    int size = sizeof(*hptr);\
> -    switch(size) {\
> +    switch(sizeof(*hptr)) {\
>      case 1:\
>          *(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
>          break;\
> @@ -288,8 +287,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
>  
>  #define __get_user(x, hptr) \
>  ({\
> -    int size = sizeof(*hptr);\
> -    switch(size) {\
> +    switch(sizeof(*hptr)) {\
>      case 1:\
>          x = (typeof(*hptr))*(uint8_t *)(hptr);\
>          break;\
> -- 
> 1.7.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-15  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-08 18:13 [Qemu-devel] [PATCH] linux-user: remove unnecessary local from __get_user(), __put_user() Peter Maydell
2010-11-15  8:00 ` Riku Voipio

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).