1 /* $NetBSD: msg_370.c,v 1.3 2024/08/31 06:57:31 rillig Exp $ */ 2 # 3 "msg_370.c" 3 4 // Test for message: field width '%.*s' in '%.*s' should be escaped as octal or hex [370] 5 6 /* 7 * To distinguish field widths from the description text, they should use 8 * octal or hex escape sequences. Of these, octal escape sequences are less 9 * error-prone, as they consist of at most 3 octal digits, whereas hex escape 10 * sequences consume as many digits as available. 11 */ 12 13 /* lint1-extra-flags: -X 351 */ 14 15 typedef typeof(sizeof(0)) size_t; 16 typedef unsigned long long uint64_t; 17 18 int snprintb(char *, size_t, const char *, uint64_t); 19 20 void 21 example(uint64_t u64) 22 { 23 char buf[64]; 24 25 /* expect+11: warning: bit position ' ' in 'f space\0' should be escaped as octal or hex [369] */ 26 /* expect+10: warning: field width ' ' in 'f space\0' should be escaped as octal or hex [370] */ 27 /* expect+9: warning: bit position '\t' in 'f\t\ttab\0' should be escaped as octal or hex [369] */ 28 /* expect+8: warning: field width '\t' in 'f\t\ttab\0' should be escaped as octal or hex [370] */ 29 /* expect+7: warning: bit position '\n' in 'f\n\nnewline\0' should be escaped as octal or hex [369] */ 30 /* expect+6: warning: field width '\n' in 'f\n\nnewline\0' should be escaped as octal or hex [370] */ 31 snprintb(buf, sizeof(buf), 32 "\177\020" 33 "f space\0" 34 "f\t\ttab\0" 35 "f\n\nnewline\0", 36 u64); 37 /* expect-1: warning: 'f\n\nnewline\0' overlaps earlier 'f\t\ttab\0' on bit 10 [376] */ 38 39 /* expect+11: warning: bit position ' ' in 'F space\0' should be escaped as octal or hex [369] */ 40 /* expect+10: warning: field width ' ' in 'F space\0' should be escaped as octal or hex [370] */ 41 /* expect+9: warning: bit position '\t' in 'F\t\ttab\0' should be escaped as octal or hex [369] */ 42 /* expect+8: warning: field width '\t' in 'F\t\ttab\0' should be escaped as octal or hex [370] */ 43 /* expect+7: warning: bit position '\n' in 'F\n\nnewline\0' should be escaped as octal or hex [369] */ 44 /* expect+6: warning: field width '\n' in 'F\n\nnewline\0' should be escaped as octal or hex [370] */ 45 snprintb(buf, sizeof(buf), 46 "\177\020" 47 "F space\0" 48 "F\t\ttab\0" 49 "F\n\nnewline\0", 50 u64); 51 /* expect-1: warning: 'F\n\nnewline\0' overlaps earlier 'F\t\ttab\0' on bit 10 [376] */ 52 } 53