blob: 4209454a28aee446071767d4743ce465cbae5dc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* bad shift right 12 */
#include <testfwk.h>
typedef unsigned int u16_t;
struct myhdr { u16_t x; } h, *p;
#define NTOHS(n) (((((u16_t)(n) & 0xff)) << 8) | (((u16_t)(n) & 0xff00) >> 8))
#define IPH_V(hdr) ((u16_t)NTOHS((hdr)->x) >> 12)
void testBug(void) {
p = &h;
p->x = 0x45;
ASSERT(IPH_V(p)==4);
}
|