Am 15.10.2015 um 18:37 schrieb Russell King - ARM Linux <li...@arm.linux.org.uk>:
> On Thu, Oct 15, 2015 at 07:52:38AM +0200, H. Nikolaus Schaller wrote: >> ERROR: space prohibited before that close parenthesis ')' >> #46: FILE: arch/arm/vdso/vdsomunge.c:64: >> + (((unsigned short)(x) & (unsigned short)0xff00U) >> 8) )) > > I have a pet hatred of too many parens. I also have a hatred of idiotic > casts. What about changing the above to one of: > > (((x) & 0xff00) >> 8) > (((x) >> 8) & 0xff) > >> >> ERROR: space prohibited before that close parenthesis ')' >> #53: FILE: arch/arm/vdso/vdsomunge.c:71: >> + (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) )) > > and one of: > > (((x) & 0xff000000) >> 24) > (((x) >> 24) & 0xff) > > ? Well, the semantics is sometimes the same but I think readability goes down because the macro becomes quite un-symmetric and for >> 8 you should better be sure that values are unsigned if combining with | operator. Of course it is questionable why the constants (with U and UL modifiers) are casted. The full macro (as copied verbatim from existing arch/mips/boot/elf2ecoff.c) is: +#define swab16(x) \ + ((unsigned short)( \ + (((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \ + (((unsigned short)(x) & (unsigned short)0xff00U) >> 8))) + +#define swab32(x) \ + ((unsigned int)( \ + (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \ + (((unsigned int)(x) & (unsigned int)0x0000ff00UL) << 8) | \ + (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >> 8) | \ + (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24))) + I have already submitted a V3 of this patch, so please comment that. A question is why this is not generally available for all HOSTCC based tools so that we could simply include some header. But since that is no kernel code but a tool, I think it is not really necessary to put significant efforts into this piece of code. This was probably the intention of the original code to simply include byteswap.h - then you don't even see how complex the macros are - but it is not a standard header. BR and thanks, Nikolaus Schaller-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/