From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Huth Date: Fri, 12 Feb 2016 12:05:26 +0000 Subject: Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts Message-Id: <56BDCA86.1020504@redhat.com> List-Id: References: <1454957594-30601-1-git-send-email-drjones@redhat.com> <1454957594-30601-2-git-send-email-drjones@redhat.com> In-Reply-To: <1454957594-30601-2-git-send-email-drjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Andrew Jones , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de, lvivier@redhat.com, pbonzini@redhat.com On 08.02.2016 19:53, Andrew Jones wrote: > Signed-off-by: Andrew Jones > --- > lib/asm-generic/io.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h > index a9939d3a5921f..abd245676e97a 100644 > --- a/lib/asm-generic/io.h > +++ b/lib/asm-generic/io.h > @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x) > #endif > > #define le16_to_cpu(x) \ > - ({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; }) > + ({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; }) > #define cpu_to_le16 le16_to_cpu > > #define le32_to_cpu(x) \ > - ({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; }) > + ({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; }) > #define cpu_to_le32 le32_to_cpu > > #define le64_to_cpu(x) \ > - ({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; }) > + ({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; }) > #define cpu_to_le64 le64_to_cpu > > #define be16_to_cpu(x) \ > - ({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; }) > + ({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; }) > #define cpu_to_be16 be16_to_cpu > > #define be32_to_cpu(x) \ > - ({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; }) > + ({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; }) > #define cpu_to_be32 be32_to_cpu > > #define be64_to_cpu(x) \ > - ({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; }) > + ({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; }) > #define cpu_to_be64 be64_to_cpu The typecasts for the __bswapXX() macros certainly do not hurt here, but I think you also do not need them - typecasting should be done automatically through __bswapXX(), shouldn't it? So IMHO it should be enough to typecase the values after the colons. Thomas From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Huth Subject: Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts Date: Fri, 12 Feb 2016 13:05:26 +0100 Message-ID: <56BDCA86.1020504@redhat.com> References: <1454957594-30601-1-git-send-email-drjones@redhat.com> <1454957594-30601-2-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de, lvivier@redhat.com, pbonzini@redhat.com To: Andrew Jones , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49031 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752308AbcBLMFb (ORCPT ); Fri, 12 Feb 2016 07:05:31 -0500 In-Reply-To: <1454957594-30601-2-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08.02.2016 19:53, Andrew Jones wrote: > Signed-off-by: Andrew Jones > --- > lib/asm-generic/io.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h > index a9939d3a5921f..abd245676e97a 100644 > --- a/lib/asm-generic/io.h > +++ b/lib/asm-generic/io.h > @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x) > #endif > > #define le16_to_cpu(x) \ > - ({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; }) > + ({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; }) > #define cpu_to_le16 le16_to_cpu > > #define le32_to_cpu(x) \ > - ({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; }) > + ({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; }) > #define cpu_to_le32 le32_to_cpu > > #define le64_to_cpu(x) \ > - ({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; }) > + ({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; }) > #define cpu_to_le64 le64_to_cpu > > #define be16_to_cpu(x) \ > - ({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; }) > + ({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; }) > #define cpu_to_be16 be16_to_cpu > > #define be32_to_cpu(x) \ > - ({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; }) > + ({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; }) > #define cpu_to_be32 be32_to_cpu > > #define be64_to_cpu(x) \ > - ({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; }) > + ({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; }) > #define cpu_to_be64 be64_to_cpu The typecasts for the __bswapXX() macros certainly do not hurt here, but I think you also do not need them - typecasting should be done automatically through __bswapXX(), shouldn't it? So IMHO it should be enough to typecase the values after the colons. Thomas