Home | History | Annotate | Line # | Download | only in lint1
      1 /*	$NetBSD: msg_374.c,v 1.6 2024/08/31 06:57:31 rillig Exp $	*/
      2 # 3 "msg_374.c"
      3 
      4 // Test for message: unknown conversion '%.*s', must be one of 'bfF=:*' [374]
      5 
      6 /*
      7  * In the new-style format, an unknown conversion is assumed to have a single
      8  * argument, followed by a null-terminated description.
      9  */
     10 
     11 /* lint1-extra-flags: -X 351 */
     12 
     13 typedef typeof(sizeof(0)) size_t;
     14 typedef unsigned long long uint64_t;
     15 
     16 int snprintb(char *, size_t, const char *, uint64_t);
     17 
     18 void
     19 example(uint64_t u64)
     20 {
     21 	char buf[64];
     22 
     23 	/* expect+4: warning: unknown conversion 'x', must be one of 'bfF=:*' [374] */
     24 	snprintb(buf, sizeof(buf),
     25 	    "\177\020"
     26 	    "x12345\0",
     27 	    u64);
     28 
     29 	/* expect+4: warning: unknown conversion '\000', must be one of 'bfF=:*' [374] */
     30 	snprintb(buf, sizeof(buf),
     31 	    "\177\020"
     32 	    "\00012345\0",
     33 	    u64);
     34 
     35 	/* expect+5: warning: redundant '\0' at the end of the format [377] */
     36 	snprintb(buf, sizeof(buf),
     37 	    "\177\020"
     38 	    "b\00012345\0"
     39 	    "\0",
     40 	    u64);
     41 
     42 	// Real-life example: the '\b' is a typo.
     43 	//
     44 	/* expect+4: warning: unknown conversion '\b', must be one of 'bfF=:*' [374] */
     45 	snprintb(buf, sizeof(buf),
     46 	    "\177\020"
     47 	    "b\15ENCNT\0b\16" "TC\0\b\20DSBL_CSR_DRN\0",
     48 	    u64);
     49 }
     50