makefs: further size_t warning cleanup (missing from r317944)

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2017-05-08 16:57:33 +00:00
parent 243a297a95
commit c5a0915477
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=317945

View File

@ -79,13 +79,14 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
char path[MAXPATHLEN + 1];
struct stat stbuf;
char *name, *rp;
int dot, len;
size_t len;
int dot;
assert(root != NULL);
assert(dir != NULL);
len = (size_t)snprintf(path, sizeof(path), "%s/%s", root, dir);
if (len >= (int)sizeof(path))
len = snprintf(path, sizeof(path), "%s/%s", root, dir);
if (len >= sizeof(path))
errx(1, "Pathname too long.");
if (debug & DEBUG_WALK_DIR)
printf("walk_dir: %s %p\n", path, parent);
@ -119,8 +120,8 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
}
if (debug & DEBUG_WALK_DIR_NODE)
printf("scanning %s/%s/%s\n", root, dir, name);
if (snprintf(path + len, sizeof(path) - len, "/%s", name) >=
(int)sizeof(path) - len)
if ((size_t)snprintf(path + len, sizeof(path) - len, "/%s",
name) >= sizeof(path) - len)
errx(1, "Pathname too long.");
if (lstat(path, &stbuf) == -1)
err(1, "Can't lstat `%s'", path);
@ -396,8 +397,8 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode, int speconly)
if (strcmp(curnode->name, curfsnode->name) == 0)
break;
}
if (snprintf(path, sizeof(path), "%s/%s",
dir, curnode->name) >= sizeof(path))
if ((size_t)snprintf(path, sizeof(path), "%s/%s", dir,
curnode->name) >= sizeof(path))
errx(1, "Pathname too long.");
if (curfsnode == NULL) { /* need new entry */
struct stat stbuf;