msg_377.c revision 1.2 1 1.2 rillig /* $NetBSD: msg_377.c,v 1.2 2024/03/03 10:27:18 rillig Exp $ */
2 1.1 rillig # 3 "msg_377.c"
3 1.1 rillig
4 1.2 rillig // Test for message: redundant '\0' at the end of the format [377]
5 1.1 rillig
6 1.1 rillig /*
7 1.2 rillig * Each directive in the new-style format ends with a '\0' that needs to be
8 1.2 rillig * spelled out.
9 1.2 rillig *
10 1.2 rillig * In both old-style and new-style formats, the '\0' that ends the whole
11 1.2 rillig * format is provided by the compiler as part of the string literal.
12 1.1 rillig */
13 1.1 rillig
14 1.1 rillig /* lint1-extra-flags: -X 351 */
15 1.1 rillig
16 1.1 rillig typedef typeof(sizeof(0)) size_t;
17 1.1 rillig typedef unsigned long long uint64_t;
18 1.1 rillig
19 1.1 rillig int snprintb(char*, size_t, const char*, uint64_t);
20 1.1 rillig
21 1.1 rillig void
22 1.1 rillig example(unsigned u32, uint64_t u64)
23 1.1 rillig {
24 1.1 rillig char buf[64];
25 1.1 rillig
26 1.2 rillig /* expect+9: warning: old-style format contains '\0' [362] */
27 1.2 rillig /* expect+8: warning: old-style format contains '\0' [362] */
28 1.2 rillig /* expect+7: warning: bit position '\000' (0) in '\000out-of-range' out of range 1..32 [371] */
29 1.2 rillig /* expect+6: warning: redundant '\0' at the end of the format [377] */
30 1.1 rillig snprintb(buf, sizeof(buf),
31 1.1 rillig "\020"
32 1.1 rillig "\005bit"
33 1.2 rillig "\000out-of-range"
34 1.1 rillig "\0",
35 1.1 rillig u32);
36 1.1 rillig
37 1.2 rillig /* expect+5: warning: redundant '\0' at the end of the format [377] */
38 1.1 rillig snprintb(buf, sizeof(buf),
39 1.1 rillig "\177\020"
40 1.1 rillig "b\005bit\0"
41 1.1 rillig "\0",
42 1.1 rillig u64);
43 1.1 rillig }
44