1 /* $NetBSD: msg_135.c,v 1.8 2021/07/15 21:12:46 rillig Exp $ */ 2 # 3 "msg_135.c" 3 4 // Test for message: converting '%s' to '%s' may cause alignment problem [135] 5 6 /* lint1-extra-flags: -h */ 7 8 void sink(const void *); 9 10 unsigned 11 read_uint(const unsigned char **pp) 12 { 13 unsigned val; 14 15 val = *(const unsigned *)(*pp); /* expect: 135 */ 16 pp += sizeof(unsigned); 17 return val; 18 } 19 20 struct incomplete; /* expect: never defined */ 21 22 struct complete { 23 int member; 24 }; 25 26 /* 27 * These types of conversions are typically seen in OpenSSL, when converting 28 * from the publicly visible, incomplete 'struct lhash_st' to a private 29 * implementation type such as 'struct lhash_st_OPENSSL_STRING'. 30 * 31 * Before tree.c 1.277 from 2021-04-17, lint warned about this, even though 32 * there was not enough evidence that there really was an alignment problem, 33 * resulting in many false positives. 34 * 35 * See openssl/lhash.h. 36 */ 37 void 38 pointer_to_structs(struct incomplete *incomplete) 39 { 40 struct complete *complete; 41 42 complete = (struct complete *)incomplete; 43 sink(complete); 44 } 45 46 void 47 unsigned_char_to_unsigned_type(unsigned char *ucp) 48 { 49 unsigned short *usp; 50 51 /* FIXME */ 52 /* expect+1: warning: converting 'pointer to unsigned char' to 'pointer to unsigned short' may cause alignment problem [135] */ 53 usp = (unsigned short *)ucp; 54 sink(usp); 55 } 56 57 void 58 plain_char_to_unsigned_type(char *cp) 59 { 60 unsigned short *usp; 61 62 /* FIXME */ 63 /* expect+1: warning: converting 'pointer to char' to 'pointer to unsigned short' may cause alignment problem [135] */ 64 usp = (unsigned short *)cp; 65 sink(usp); 66 } 67