msg_363.c revision 1.3 1 /* $NetBSD: msg_363.c,v 1.3 2024/03/03 13:09:23 rillig Exp $ */
2 # 3 "msg_363.c"
3
4 // Test for message: non-printing character '%.*s' in description '%.*s' [363]
5
6 /*
7 * The purpose of snprintb is to produce a printable, visible representation
8 * of a binary number, therefore the description should consist of visible
9 * characters only.
10 */
11
12 /* lint1-extra-flags: -X 351 */
13
14 typedef typeof(sizeof(0)) size_t;
15 typedef unsigned long long uint64_t;
16
17 int snprintb(char*, size_t, const char*, uint64_t);
18
19 void
20 old_style_description(unsigned u32)
21 {
22 char buf[64];
23
24 /* expect+6: warning: bit position '\t' in '\tprint' should be escaped as octal or hex [369] */
25 /* expect+5: warning: non-printing character '\377' in description 'able\377' [363] */
26 /* expect+4: warning: bit position '\n' in '\nable\377' should be escaped as octal or hex [369] */
27 snprintb(buf, sizeof(buf),
28 "\020"
29 "\001non\tprint\nable\377",
30 u32);
31
32 /* expect+6: warning: bit position '\000' (0) in '\000print' out of range 1..32 [371] */
33 /* expect+5: warning: bit position '\n' in '\nable' should be escaped as octal or hex [369] */
34 /* expect+4: warning: redundant '\0' at the end of the format [377] */
35 snprintb(buf, sizeof(buf),
36 "\020"
37 "\001non\000print\nable\0",
38 u32);
39 }
40