Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): convert int to size_t for string lengths
details: https://anonhg.NetBSD.org/src/rev/22b60ece53c7
branches: trunk
changeset: 944279:22b60ece53c7
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Sep 25 17:14:32 2020 +0000
description:
make(1): convert int to size_t for string lengths
Just for formal reasons. There is no practical scenario in which any
filename suffix would grow larger than a few kilocharacters.
diffstat:
usr.bin/make/suff.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diffs (114 lines):
diff -r 500320677b5d -r 22b60ece53c7 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Fri Sep 25 16:28:29 2020 +0000
+++ b/usr.bin/make/suff.c Fri Sep 25 17:14:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.163 2020/09/25 16:28:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.164 2020/09/25 17:14:32 rillig Exp $");
#define SUFF_DEBUG0(fmt) \
if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -172,7 +172,7 @@
*/
typedef struct Suff {
char *name; /* The suffix itself, such as ".c" */
- int nameLen; /* Length of the name, to avoid strlen calls */
+ size_t nameLen; /* Length of the name, to avoid strlen calls */
SuffFlags flags; /* Type of suffix */
SearchPath *searchPath; /* The path along which files of this suffix
* may be found */
@@ -252,8 +252,8 @@
}
struct SuffSuffGetSuffixArgs {
- char *ename; /* The end of the name */
- int len; /* Length of the name */
+ size_t name_len;
+ char *name_end;
};
/* See if suff is a suffix of str. str->ename should point to THE END
@@ -273,11 +273,11 @@
char *p1; /* Pointer into suffix name */
char *p2; /* Pointer into string being examined */
- if (str->len < s->nameLen)
+ if (str->name_len < s->nameLen)
return NULL; /* this string is shorter than the suffix */
p1 = s->name + s->nameLen;
- p2 = str->ename;
+ p2 = str->name_end;
while (p1 >= s->name && *p1 == *p2) {
p1--;
@@ -698,8 +698,8 @@
/*
* Not from, maybe to?
*/
- sd.len = strlen(transform->name);
- sd.ename = transform->name + sd.len;
+ sd.name_len = strlen(transform->name);
+ sd.name_end = transform->name + sd.name_len;
cp = SuffSuffGetSuffix(s, &sd);
if (cp != NULL) {
SuffListNode *ln;
@@ -1143,7 +1143,7 @@
GNode *t, /* Target GNode */
*s; /* Source GNode */
- int prefLen;/* The length of the defined prefix */
+ size_t prefLen;/* The length of the defined prefix */
Suff *suff; /* Suffix on matching beastie */
Src *ret; /* Return value */
char *cp;
@@ -1452,8 +1452,8 @@
if (suff == NULL) {
struct SuffSuffGetSuffixArgs sd; /* Search string data */
SuffListNode *ln;
- sd.len = strlen(gn->name);
- sd.ename = gn->name + sd.len;
+ sd.name_len = strlen(gn->name);
+ sd.name_end = gn->name + sd.name_len;
ln = Lst_Find(sufflist, SuffSuffIsSuffix, &sd);
SUFF_DEBUG1("Wildcard expanding \"%s\"...", gn->name);
@@ -1661,8 +1661,8 @@
/*
* Use first matching suffix...
*/
- sd.len = eoarch - gn->name;
- sd.ename = eoarch;
+ sd.name_len = eoarch - gn->name;
+ sd.name_end = eoarch;
ln = Lst_Find(ms->parents, SuffSuffIsSuffix, &sd);
if (ln != NULL) {
@@ -1725,8 +1725,8 @@
struct SuffSuffGetSuffixArgs sd; /* Search string data */
- sd.len = strlen(gn->name);
- sd.ename = eoname = gn->name + sd.len;
+ sd.name_len = strlen(gn->name);
+ sd.name_end = eoname = gn->name + sd.name_len;
sopref = gn->name;
@@ -1903,7 +1903,7 @@
* Suffix known for the thing -- trim the suffix off
* the path to form the proper .PREFIX variable.
*/
- int savep = strlen(gn->path) - targ->suff->nameLen;
+ size_t savep = strlen(gn->path) - targ->suff->nameLen;
char savec;
if (gn->suffix)
Home |
Main Index |
Thread Index |
Old Index