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