Module Name: src
Committed By: rillig
Date: Mon Mar 25 22:37:43 UTC 2024
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_356.c msg_362.c msg_364.c msg_365.c
msg_366.c msg_368.c msg_374.c msg_377.c msg_378.c
src/usr.bin/xlint/lint1: cksnprintb.c err.c
Log Message:
lint: rename snprintb 'directives' to 'conversions'
This aligns the terminology with the snprintf function.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_356.c \
src/tests/usr.bin/xlint/lint1/msg_362.c \
src/tests/usr.bin/xlint/lint1/msg_364.c \
src/tests/usr.bin/xlint/lint1/msg_365.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_366.c \
src/tests/usr.bin/xlint/lint1/msg_377.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_368.c \
src/tests/usr.bin/xlint/lint1/msg_378.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_374.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/cksnprintb.c
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/xlint/lint1/err.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_356.c
diff -u src/tests/usr.bin/xlint/lint1/msg_356.c:1.2 src/tests/usr.bin/xlint/lint1/msg_356.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_356.c:1.2 Fri Mar 1 17:22:55 2024
+++ src/tests/usr.bin/xlint/lint1/msg_356.c Mon Mar 25 22:37:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_356.c,v 1.2 2024/03/01 17:22:55 rillig Exp $ */
+/* $NetBSD: msg_356.c,v 1.3 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_356.c"
// Test for message: short octal escape '%.*s' followed by digit '%c' [356]
@@ -6,8 +6,8 @@
/* lint1-extra-flags: -X 351 */
// When counting backwards in octal, the number before \040 is not \039 but
-// \037. This mistake sometimes happens while encoding the bit numbers for
-// snprintb(3) format directives.
+// \037. This mistake sometimes happens when encoding the bit numbers for
+// snprintb(3) format conversions.
char snprintb_fmt[] = "\020"
"\0040bit32" // 3-digit octal escapes are fine
Index: src/tests/usr.bin/xlint/lint1/msg_362.c
diff -u src/tests/usr.bin/xlint/lint1/msg_362.c:1.2 src/tests/usr.bin/xlint/lint1/msg_362.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_362.c:1.2 Sun Mar 3 13:09:23 2024
+++ src/tests/usr.bin/xlint/lint1/msg_362.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_362.c,v 1.2 2024/03/03 13:09:23 rillig Exp $ */
+/* $NetBSD: msg_362.c,v 1.3 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_362.c"
-// Test for message: directive '%.*s' should not be escaped [362]
+// Test for message: conversion '%.*s' should not be escaped [362]
/*
- * Since the characters used for the directive type are chosen to be easily
+ * Since the characters used for the conversion type were chosen to be easily
* readable, it doesn't make sense to obfuscate them.
*/
@@ -20,10 +20,10 @@ example(unsigned u32)
{
char buf[64];
- /* expect+9: warning: directive '\142' should not be escaped [362] */
+ /* expect+9: warning: conversion '\142' should not be escaped [362] */
/* expect+8: warning: bit position 'o' in '\142old-style-lsb\0' should be escaped as octal or hex [369] */
/* expect+7: warning: bit position 'o' (111) in '\142old-style-lsb\0' out of range 0..63 [371] */
- /* expect+6: warning: unknown directive '\001', must be one of 'bfF=:*' [374] */
+ /* expect+6: warning: unknown conversion '\001', must be one of 'bfF=:*' [374] */
snprintb(buf, sizeof(buf),
"\177\020"
"\142old-style-lsb\0"
Index: src/tests/usr.bin/xlint/lint1/msg_364.c
diff -u src/tests/usr.bin/xlint/lint1/msg_364.c:1.2 src/tests/usr.bin/xlint/lint1/msg_364.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_364.c:1.2 Sun Mar 3 10:27:18 2024
+++ src/tests/usr.bin/xlint/lint1/msg_364.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_364.c,v 1.2 2024/03/03 10:27:18 rillig Exp $ */
+/* $NetBSD: msg_364.c,v 1.3 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_364.c"
// Test for message: missing bit position after '%.*s' [364]
/*
- * The directives 'b', 'f' and 'F' require a bit position as their first
+ * The conversions 'b', 'f' and 'F' require a bit position as their first
* argument.
*/
Index: src/tests/usr.bin/xlint/lint1/msg_365.c
diff -u src/tests/usr.bin/xlint/lint1/msg_365.c:1.2 src/tests/usr.bin/xlint/lint1/msg_365.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_365.c:1.2 Sun Mar 3 10:27:18 2024
+++ src/tests/usr.bin/xlint/lint1/msg_365.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_365.c,v 1.2 2024/03/03 10:27:18 rillig Exp $ */
+/* $NetBSD: msg_365.c,v 1.3 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_365.c"
// Test for message: missing field width after '%.*s' [365]
/*
- * The directives 'f' and 'F' require a field width as their second argument.
+ * The conversions 'f' and 'F' require a field width as their second argument.
*/
/* lint1-extra-flags: -X 351 */
Index: src/tests/usr.bin/xlint/lint1/msg_366.c
diff -u src/tests/usr.bin/xlint/lint1/msg_366.c:1.3 src/tests/usr.bin/xlint/lint1/msg_366.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_366.c:1.3 Sun Mar 3 10:27:18 2024
+++ src/tests/usr.bin/xlint/lint1/msg_366.c Mon Mar 25 22:37:43 2024
@@ -1,15 +1,15 @@
-/* $NetBSD: msg_366.c,v 1.3 2024/03/03 10:27:18 rillig Exp $ */
+/* $NetBSD: msg_366.c,v 1.4 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_366.c"
// Test for message: missing '\0' at the end of '%.*s' [366]
/*
- * In the new-style format, each directive ends with a '\0'. If that's not
+ * In the new-style format, each conversion ends with a '\0'. If that's not
* the case, snprintb will read beyond the end of the format argument, looking
* for the terminating '\0'. In the most common case where the format comes
- * from a string literal, the '\0' from the directive needs to be spelled out,
- * while the '\0' that terminates the sequence of directives is provided by
- * the C compiler.
+ * from a string literal, the '\0' from the conversion needs to be spelled
+ * out, while the '\0' that terminates the sequence of conversions is provided
+ * by the C compiler.
*/
/* lint1-extra-flags: -X 351 */
Index: src/tests/usr.bin/xlint/lint1/msg_377.c
diff -u src/tests/usr.bin/xlint/lint1/msg_377.c:1.3 src/tests/usr.bin/xlint/lint1/msg_377.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_377.c:1.3 Sun Mar 3 13:09:23 2024
+++ src/tests/usr.bin/xlint/lint1/msg_377.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_377.c,v 1.3 2024/03/03 13:09:23 rillig Exp $ */
+/* $NetBSD: msg_377.c,v 1.4 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_377.c"
// Test for message: redundant '\0' at the end of the format [377]
/*
- * Each directive in the new-style format ends with a '\0' that needs to be
+ * Each conversion in the new-style format ends with a '\0' that needs to be
* spelled out.
*
* In both old-style and new-style formats, the '\0' that ends the whole
Index: src/tests/usr.bin/xlint/lint1/msg_368.c
diff -u src/tests/usr.bin/xlint/lint1/msg_368.c:1.1 src/tests/usr.bin/xlint/lint1/msg_368.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_368.c:1.1 Fri Mar 1 19:39:29 2024
+++ src/tests/usr.bin/xlint/lint1/msg_368.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_368.c,v 1.1 2024/03/01 19:39:29 rillig Exp $ */
+/* $NetBSD: msg_368.c,v 1.2 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_368.c"
-// Test for message: missing comparison value after directive '%.*s' [368]
+// Test for message: missing comparison value after conversion '%.*s' [368]
/*
- * The directives '=' and ':' require a comparison value as their argument,
+ * The conversions '=' and ':' require a comparison value as their argument,
* followed by the description and the terminating null character.
*/
@@ -20,13 +20,13 @@ example(uint64_t val)
{
char buf[64];
- /* expect+4: warning: missing comparison value after directive '=' [368] */
+ /* expect+4: warning: missing comparison value after conversion '=' [368] */
snprintb(buf, sizeof(buf),
"\177\020"
"=",
val);
- /* expect+4: warning: missing comparison value after directive ':' [368] */
+ /* expect+4: warning: missing comparison value after conversion ':' [368] */
snprintb(buf, sizeof(buf),
"\177\020"
":",
Index: src/tests/usr.bin/xlint/lint1/msg_378.c
diff -u src/tests/usr.bin/xlint/lint1/msg_378.c:1.1 src/tests/usr.bin/xlint/lint1/msg_378.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_378.c:1.1 Sun Mar 3 00:50:41 2024
+++ src/tests/usr.bin/xlint/lint1/msg_378.c Mon Mar 25 22:37:43 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_378.c,v 1.1 2024/03/03 00:50:41 rillig Exp $ */
+/* $NetBSD: msg_378.c,v 1.2 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_378.c"
-// Test for message: directive '%.*s' is unreachable by input value [378]
+// Test for message: conversion '%.*s' is unreachable by input value [378]
/*
* The typical use case of snprintb is to have a format that is specifically
@@ -22,24 +22,24 @@ example(unsigned u32, uint64_t u64)
{
char buf[64];
- /* expect+5: warning: directive '\040bit32' is unreachable by input value [378] */
+ /* expect+5: warning: conversion '\040bit32' is unreachable by input value [378] */
snprintb(buf, sizeof(buf),
"\020"
"\037bit31"
"\040bit32",
u32 >> 1);
- /* expect+5: warning: directive 'b\075bit61\0' is unreachable by input value [378] */
+ /* expect+5: warning: conversion 'b\075bit61\0' is unreachable by input value [378] */
snprintb(buf, sizeof(buf),
"\177\020"
"b\074bit60\0"
"b\075bit61\0",
u64 >> 3);
- /* expect+12: warning: directive 'b\000bit0\0' is unreachable by input value [378] */
- /* expect+11: warning: directive 'b\011bit9\0' is unreachable by input value [378] */
- /* expect+10: warning: directive 'f\017\002bits15-16\0' is unreachable by input value [378] */
- /* expect+9: warning: directive 'f\050\030bits40-63\0' is unreachable by input value [378] */
+ /* expect+12: warning: conversion 'b\000bit0\0' is unreachable by input value [378] */
+ /* expect+11: warning: conversion 'b\011bit9\0' is unreachable by input value [378] */
+ /* expect+10: warning: conversion 'f\017\002bits15-16\0' is unreachable by input value [378] */
+ /* expect+9: warning: conversion 'f\050\030bits40-63\0' is unreachable by input value [378] */
snprintb(buf, sizeof(buf),
"\177\020"
"b\000bit0\0"
Index: src/tests/usr.bin/xlint/lint1/msg_374.c
diff -u src/tests/usr.bin/xlint/lint1/msg_374.c:1.4 src/tests/usr.bin/xlint/lint1/msg_374.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_374.c:1.4 Sun Mar 3 13:09:23 2024
+++ src/tests/usr.bin/xlint/lint1/msg_374.c Mon Mar 25 22:37:43 2024
@@ -1,10 +1,10 @@
-/* $NetBSD: msg_374.c,v 1.4 2024/03/03 13:09:23 rillig Exp $ */
+/* $NetBSD: msg_374.c,v 1.5 2024/03/25 22:37:43 rillig Exp $ */
# 3 "msg_374.c"
-// Test for message: unknown directive '%.*s', must be one of 'bfF=:*' [374]
+// Test for message: unknown conversion '%.*s', must be one of 'bfF=:*' [374]
/*
- * In the new-style format, an unknown directive is assumed to have a single
+ * In the new-style format, an unknown conversion is assumed to have a single
* argument, followed by a null-terminated description.
*/
@@ -20,13 +20,13 @@ example(uint64_t u64)
{
char buf[64];
- /* expect+4: warning: unknown directive 'x', must be one of 'bfF=:*' [374] */
+ /* expect+4: warning: unknown conversion 'x', must be one of 'bfF=:*' [374] */
snprintb(buf, sizeof(buf),
"\177\020"
"x12345\0",
u64);
- /* expect+4: warning: unknown directive '\000', must be one of 'bfF=:*' [374] */
+ /* expect+4: warning: unknown conversion '\000', must be one of 'bfF=:*' [374] */
snprintb(buf, sizeof(buf),
"\177\020"
"\00012345\0",
@@ -41,12 +41,9 @@ example(uint64_t u64)
// Real-life example: the '\b' is a typo.
//
- // TODO: Warn about the description that is split between string
- // literals for no apparent reason.
- //
- /* expect+4: warning: unknown directive '\b', must be one of 'bfF=:*' [374] */
+ /* expect+4: warning: unknown conversion '\b', must be one of 'bfF=:*' [374] */
snprintb(buf, sizeof(buf),
"\177\020"
- "b\15ENCNT\0b\16" "TC\0\b\20DSBL_" "CSR_DRN\0",
+ "b\15ENCNT\0b\16" "TC\0\b\20DSBL_CSR_DRN\0",
u64);
}
Index: src/usr.bin/xlint/lint1/cksnprintb.c
diff -u src/usr.bin/xlint/lint1/cksnprintb.c:1.11 src/usr.bin/xlint/lint1/cksnprintb.c:1.12
--- src/usr.bin/xlint/lint1/cksnprintb.c:1.11 Wed Mar 13 06:48:49 2024
+++ src/usr.bin/xlint/lint1/cksnprintb.c Mon Mar 25 22:37:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cksnprintb.c,v 1.11 2024/03/13 06:48:49 rillig Exp $ */
+/* $NetBSD: cksnprintb.c,v 1.12 2024/03/25 22:37:43 rillig Exp $ */
/*-
* Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: cksnprintb.c,v 1.11 2024/03/13 06:48:49 rillig Exp $");
+__RCSID("$NetBSD: cksnprintb.c,v 1.12 2024/03/25 22:37:43 rillig Exp $");
#endif
#include <stdbool.h>
@@ -113,8 +113,8 @@ check_bit(checker *ck, uint64_t dir_lsb,
if (ck->covered & field_mask & bit(i)) {
/* '%.*s' overlaps earlier '%.*s' on bit %u */
warning(376,
- len, start, ck->covered_len[i],
- ck->covered_start[i],
+ len, start,
+ ck->covered_len[i], ck->covered_start[i],
ck->new_style ? i : i + 1);
break;
}
@@ -129,7 +129,7 @@ check_bit(checker *ck, uint64_t dir_lsb,
}
if (!(possible_bits(ck->value) & field_mask))
- /* directive '%.*s' is unreachable by input value */
+ /* conversion '%.*s' is unreachable by input value */
warning(378, len, start);
}
@@ -158,7 +158,7 @@ parse_description(checker *ck)
}
static bool
-check_directive(checker *ck)
+check_conversion(checker *ck)
{
bool new_style = ck->new_style;
const buffer *fmt = ck->fmt;
@@ -190,7 +190,7 @@ check_directive(checker *ck)
bool has_cmp = new_style
&& (dir.value == '=' || dir.value == ':');
if (has_cmp && !quoted_next(fmt, it)) {
- /* missing comparison value after directive '%.*s' */
+ /* missing comparison value after conversion '%.*s' */
warning(368, range(dir, *it), start(dir, fmt));
return false;
}
@@ -208,12 +208,12 @@ check_directive(checker *ck)
}
if (!has_bit && !has_cmp && !has_default) {
- /* unknown directive '%.*s', must be one of 'bfF=:*' */
+ /* unknown conversion '%.*s', must be one of 'bfF=:*' */
warning(374, len(dir), start(dir, fmt));
return false;
}
if (new_style && dir.escaped)
- /* directive '%.*s' should not be escaped */
+ /* conversion '%.*s' should not be escaped */
warning(362, len(dir), start(dir, fmt));
bool needs_descr = !(new_style && dir.value == 'F');
@@ -312,6 +312,6 @@ check_snprintb(const tnode_t *expr)
return;
}
- while (check_directive(&ck))
+ while (check_conversion(&ck))
continue;
}
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.232 src/usr.bin/xlint/lint1/err.c:1.233
--- src/usr.bin/xlint/lint1/err.c:1.232 Sun Mar 10 19:45:14 2024
+++ src/usr.bin/xlint/lint1/err.c Mon Mar 25 22:37:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.232 2024/03/10 19:45:14 rillig Exp $ */
+/* $NetBSD: err.c,v 1.233 2024/03/25 22:37:43 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.232 2024/03/10 19:45:14 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.233 2024/03/25 22:37:43 rillig Exp $");
#endif
#include <limits.h>
@@ -417,23 +417,23 @@ static const char *const msgs[] = {
"missing new-style '\\177' or old-style number base", // 359
"missing new-style number base after '\\177'", // 360
"number base '%.*s' is %ju, must be 8, 10 or 16", // 361
- "directive '%.*s' should not be escaped", // 362
+ "conversion '%.*s' should not be escaped", // 362
"non-printing character '%.*s' in description '%.*s'", // 363
"missing bit position after '%.*s'", // 364
"missing field width after '%.*s'", // 365
"missing '\\0' at the end of '%.*s'", // 366
"empty description in '%.*s'", // 367
- "missing comparison value after directive '%.*s'", // 368
+ "missing comparison value after conversion '%.*s'", // 368
"bit position '%.*s' in '%.*s' should be escaped as octal or hex", // 369
"field width '%.*s' in '%.*s' should be escaped as octal or hex", // 370
"bit position '%.*s' (%ju) in '%.*s' out of range %u..%u", // 371
"field width '%.*s' (%ju) in '%.*s' out of range 0..64", // 372
"bit field end %ju in '%.*s' out of range 0..64", // 373
- "unknown directive '%.*s', must be one of 'bfF=:*'", // 374
+ "unknown conversion '%.*s', must be one of 'bfF=:*'", // 374
"comparison value '%.*s' (%ju) exceeds maximum field value %ju", // 375
"'%.*s' overlaps earlier '%.*s' on bit %u", // 376
"redundant '\\0' at the end of the format", // 377
- "directive '%.*s' is unreachable by input value", // 378
+ "conversion '%.*s' is unreachable by input value", // 378
};
static bool is_suppressed[sizeof(msgs) / sizeof(msgs[0])];