summaryrefslogtreecommitdiff
path: root/usr.bin/make/meta.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-02-04 23:22:19 +0000
committerrillig <rillig@NetBSD.org>2022-02-04 23:22:19 +0000
commit2bf5716a7b9fdcc681e834d8aabc5d5fdd340f1b (patch)
tree51e3c924b03f53012efeef3fabbcafb2a5a89b41 /usr.bin/make/meta.c
parent96ab9b0200dc9f801397194d5fca21cd0cdec051 (diff)
make: use unsigned int for line numbers everywhere
Previously, some line numbers were stored as signed int while others were stored as size_t. Since line numbers are never negative, use an unsigned type. Since the maximum file size for makefiles is 1 GB (see loadfile), unsigned int is large enough even on 64-bit platforms. Using a single data types reduces the number of type conversions. Using unsigned int improves compatibility with C90 (printf %u instead of %zu), which is needed by bmake, which is derived from usr.bin/make. No functional change.
Diffstat (limited to 'usr.bin/make/meta.c')
-rw-r--r--usr.bin/make/meta.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/usr.bin/make/meta.c b/usr.bin/make/meta.c
index 5b239c1f478..700d85709b5 100644
--- a/usr.bin/make/meta.c
+++ b/usr.bin/make/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.195 2022/01/27 06:02:59 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.196 2022/02/04 23:22:19 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -1025,7 +1025,7 @@ meta_ignore(GNode *gn, const char *p)
* Setting oodate true will have that effect.
*/
#define CHECK_VALID_META(p) if (!(p != NULL && *p != '\0')) { \
- warnx("%s: %d: malformed", fname, lineno); \
+ warnx("%s: %u: malformed", fname, lineno); \
oodate = true; \
continue; \
}
@@ -1137,7 +1137,7 @@ meta_oodate(GNode *gn, bool oodate)
if ((fp = fopen(fname, "r")) != NULL) {
static char *buf = NULL;
static size_t bufsz;
- int lineno = 0;
+ unsigned lineno = 0;
int lastpid = 0;
int pid;
int x;
@@ -1174,7 +1174,7 @@ meta_oodate(GNode *gn, bool oodate)
if (buf[x - 1] == '\n')
buf[x - 1] = '\0';
else {
- warnx("%s: %d: line truncated at %u", fname, lineno, x);
+ warnx("%s: %u: line truncated at %u", fname, lineno, x);
oodate = true;
break;
}
@@ -1195,7 +1195,7 @@ meta_oodate(GNode *gn, bool oodate)
/* Delimit the record type. */
p = buf;
#ifdef DEBUG_META_MODE
- DEBUG3(META, "%s: %d: %s\n", fname, lineno, buf);
+ DEBUG3(META, "%s: %u: %s\n", fname, lineno, buf);
#endif
strsep(&p, " ");
if (have_filemon) {
@@ -1263,7 +1263,7 @@ meta_oodate(GNode *gn, bool oodate)
continue;
#ifdef DEBUG_META_MODE
if (DEBUG(META))
- debug_printf("%s: %d: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
+ debug_printf("%s: %u: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
fname, lineno,
pid, buf[0], cwd, lcwd, latestdir);
#endif
@@ -1294,7 +1294,7 @@ meta_oodate(GNode *gn, bool oodate)
#ifdef DEBUG_META_MODE
if (DEBUG(META))
debug_printf(
- "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
+ "%s: %u: %d: cwd=%s lcwd=%s ldir=%s\n",
fname, lineno,
child, cwd, lcwd, latestdir);
#endif
@@ -1309,7 +1309,7 @@ meta_oodate(GNode *gn, bool oodate)
Global_Set(lcwd_vname, lcwd);
Global_Set(ldir_vname, lcwd);
#ifdef DEBUG_META_MODE
- DEBUG4(META, "%s: %d: cwd=%s ldir=%s\n",
+ DEBUG4(META, "%s: %u: cwd=%s ldir=%s\n",
fname, lineno, cwd, lcwd);
#endif
break;
@@ -1462,7 +1462,7 @@ meta_oodate(GNode *gn, bool oodate)
for (sdp = sdirs; *sdp != NULL && !found; sdp++) {
#ifdef DEBUG_META_MODE
- DEBUG3(META, "%s: %d: looking for: %s\n",
+ DEBUG3(META, "%s: %u: looking for: %s\n",
fname, lineno, *sdp);
#endif
if (cached_stat(*sdp, &cst) == 0) {
@@ -1472,12 +1472,12 @@ meta_oodate(GNode *gn, bool oodate)
}
if (found) {
#ifdef DEBUG_META_MODE
- DEBUG3(META, "%s: %d: found: %s\n",
+ DEBUG3(META, "%s: %u: found: %s\n",
fname, lineno, p);
#endif
if (!S_ISDIR(cst.cst_mode) &&
cst.cst_mtime > gn->mtime) {
- DEBUG3(META, "%s: %d: file '%s' is newer than the target...\n",
+ DEBUG3(META, "%s: %u: file '%s' is newer than the target...\n",
fname, lineno, p);
oodate = true;
} else if (S_ISDIR(cst.cst_mode)) {
@@ -1509,7 +1509,7 @@ meta_oodate(GNode *gn, bool oodate)
* meta data file.
*/
if (cmdNode == NULL) {
- DEBUG2(META, "%s: %d: there were more build commands in the meta data file than there are now...\n",
+ DEBUG2(META, "%s: %u: there were more build commands in the meta data file than there are now...\n",
fname, lineno);
oodate = true;
} else {
@@ -1526,7 +1526,7 @@ meta_oodate(GNode *gn, bool oodate)
}
if (hasOODATE) {
needOODATE = true;
- DEBUG2(META, "%s: %d: cannot compare command using .OODATE\n",
+ DEBUG2(META, "%s: %u: cannot compare command using .OODATE\n",
fname, lineno);
}
(void)Var_Subst(cmd, gn, VARE_UNDEFERR, &cmd);
@@ -1549,7 +1549,7 @@ meta_oodate(GNode *gn, bool oodate)
x = n;
lineno++;
if (buf[x - 1] != '\n') {
- warnx("%s: %d: line truncated at %u", fname, lineno, x);
+ warnx("%s: %u: line truncated at %u", fname, lineno, x);
break;
}
cp = strchr(cp + 1, '\n');
@@ -1561,7 +1561,7 @@ meta_oodate(GNode *gn, bool oodate)
!hasOODATE &&
!(gn->type & OP_NOMETA_CMP) &&
(meta_cmd_cmp(gn, p, cmd, cmp_filter) != 0)) {
- DEBUG4(META, "%s: %d: a build command has changed\n%s\nvs\n%s\n",
+ DEBUG4(META, "%s: %u: a build command has changed\n%s\nvs\n%s\n",
fname, lineno, p, cmd);
if (!metaIgnoreCMDs)
oodate = true;
@@ -1575,13 +1575,13 @@ meta_oodate(GNode *gn, bool oodate)
* that weren't in the meta data file.
*/
if (!oodate && cmdNode != NULL) {
- DEBUG2(META, "%s: %d: there are extra build commands now that weren't in the meta data file\n",
+ DEBUG2(META, "%s: %u: there are extra build commands now that weren't in the meta data file\n",
fname, lineno);
oodate = true;
}
CHECK_VALID_META(p);
if (strcmp(p, cwd) != 0) {
- DEBUG4(META, "%s: %d: the current working directory has changed from '%s' to '%s'\n",
+ DEBUG4(META, "%s: %u: the current working directory has changed from '%s' to '%s'\n",
fname, lineno, p, curdir);
oodate = true;
}