Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH] USB: gadget: dummy_hcd: switch char * to u8 * | Date | Fri, 21 Oct 2022 22:02:35 +0000 |
| |
From: Linus Torvalds > Sent: 21 October 2022 18:31 ... > I think you might as well also remove the cast that was always a bit odd: > > buf[0] = (u8)dum->devstatus; ... > I suspect a comment would be more readable than an odd cast that > doesn't actually change anything (since the assignment does it > anyway).
I've seen a compiler generate an '& 0xff' for the cast before storing the low byte. Don't even think about what that compiler would generated for: buf[0] = (u8)(dum->devstatus & 0xff);
The code is much easier to read as just an assignment :-)
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |