pkarashchenko commented on code in PR #7491: URL: https://github.com/apache/incubator-nuttx/pull/7491#discussion_r1010088983
########## include/nuttx/usb/usb.h: ########## @@ -65,10 +65,10 @@ #define MSBYTE(u16) ((u16) >> 8) /* Get MS byte from uint16_t */ #define LSBYTE(u16) ((u16) & 0xff) /* Get LS byte from uint16_t */ -#define GETUINT16(p) (((uint16_t)p[1] << 8) | (uint16_t)p[0]) -#define GETUINT32(p) (((uint32_t)p[3] << 24) | \ - ((uint32_t)p[2] << 16) | \ - ((uint32_t)p[1] << 8) | (uint32_t)p[0]) +#define GETUINT16(p) ((uint16_t)((p[1] << 8) | p[0])) Review Comment: Try running ``` #include <stdio.h> #include <stdint.h> #define MK16(p) (((uint16_t)p[1] << 8) | (uint16_t)p[0]) #define MK16_(p) ((uint16_t)((p[1] << 8) | p[0])) int main() { uint8_t a[2] = {1,2}; uint8_t b[2] = {3,4}; printf("Output1 %04hx %04hx\n", MK16(a), MK16(b)); printf("Output2 %04hx %04hx\n", MK16_(a), MK16_(b)); return 0; } ``` Both will print ``` Output1 0201 0403 Output2 0201 0403 ``` If the warning matters then I was expecting to see `0000` printed as a second value of a faulty case. The `hx` matters only for `scanf` case and that is why `PRIx8` and `PRIx16` are defined to `"x"`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org