Home | History | Annotate | Line # | Download | only in lint1
msg_363.c revision 1.6
      1  1.6  rillig /*	$NetBSD: msg_363.c,v 1.6 2024/08/31 06:57:31 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_363.c"
      3  1.1  rillig 
      4  1.5  rillig // Test for message: escaped character '%.*s' in description of conversion '%.*s' [363]
      5  1.1  rillig 
      6  1.1  rillig /*
      7  1.1  rillig  * The purpose of snprintb is to produce a printable, visible representation
      8  1.5  rillig  * of a binary number, therefore the description should consist of simple
      9  1.5  rillig  * characters only, and these should not need to be escaped.  If they are,
     10  1.5  rillig  * it's often due to a typo, such as a missing terminating '\0'.
     11  1.1  rillig  */
     12  1.1  rillig 
     13  1.1  rillig /* lint1-extra-flags: -X 351 */
     14  1.1  rillig 
     15  1.1  rillig typedef typeof(sizeof(0)) size_t;
     16  1.1  rillig typedef unsigned long long uint64_t;
     17  1.1  rillig 
     18  1.6  rillig int snprintb(char *, size_t, const char *, uint64_t);
     19  1.1  rillig 
     20  1.1  rillig void
     21  1.1  rillig old_style_description(unsigned u32)
     22  1.1  rillig {
     23  1.1  rillig 	char buf[64];
     24  1.1  rillig 
     25  1.1  rillig 	/* expect+6: warning: bit position '\t' in '\tprint' should be escaped as octal or hex [369] */
     26  1.5  rillig 	/* expect+5: warning: escaped character '\377' in description of conversion '\nable\377' [363] */
     27  1.1  rillig 	/* expect+4: warning: bit position '\n' in '\nable\377' should be escaped as octal or hex [369] */
     28  1.1  rillig 	snprintb(buf, sizeof(buf),
     29  1.1  rillig 	    "\020"
     30  1.1  rillig 	    "\001non\tprint\nable\377",
     31  1.1  rillig 	    u32);
     32  1.1  rillig 
     33  1.5  rillig 	/* expect+10: warning: escaped character '\177' in description of conversion '\002""\177' [363] */
     34  1.5  rillig 	/* expect+9: warning: escaped character '\177' in description of conversion '\003aa""""\177' [363] */
     35  1.5  rillig 	/* expect+8: warning: escaped character '\177' in description of conversion '\004""bb""\177' [363] */
     36  1.5  rillig 	/* expect+7: warning: escaped character '\177' in description of conversion '\005""""cc\177' [363] */
     37  1.4  rillig 	snprintb(buf, sizeof(buf),
     38  1.4  rillig 	    "\020"
     39  1.4  rillig 	    "\002""\177"
     40  1.4  rillig 	    "\003aa""""\177"
     41  1.4  rillig 	    "\004""bb""\177"
     42  1.4  rillig 	    "\005""""cc\177",
     43  1.4  rillig 	    u32);
     44  1.4  rillig 
     45  1.3  rillig 	/* expect+6: warning: bit position '\000' (0) in '\000print' out of range 1..32 [371] */
     46  1.1  rillig 	/* expect+5: warning: bit position '\n' in '\nable' should be escaped as octal or hex [369] */
     47  1.2  rillig 	/* expect+4: warning: redundant '\0' at the end of the format [377] */
     48  1.1  rillig 	snprintb(buf, sizeof(buf),
     49  1.1  rillig 	    "\020"
     50  1.1  rillig 	    "\001non\000print\nable\0",
     51  1.1  rillig 	    u32);
     52  1.1  rillig }
     53