git: 342a51f11018 - stable/14 - which: Use size_t instead of ssize_t for pathlen

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 15 Apr 2024 14:05:30 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=342a51f11018a386643402c5b79a6f1768defb29

commit 342a51f11018a386643402c5b79a6f1768defb29
Author:     Collin Funk <collin.funk1@gmail.com>
AuthorDate: 2024-02-11 04:26:38 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-15 14:05:13 +0000

    which: Use size_t instead of ssize_t for pathlen
    
    The "pathlen" variable is the return value of strlen(3) and is then
    passed as an argument to malloc(3) and memcpy(3). The size_t type
    matches the prototype for these functions. The size_t type is unsigned
    so it can fit larger $PATH values than ssize_t. However, in practice
    ssize_t should be larger enough so this change is just for clarity.
    
    Signed-off-by: Collin Funk <collin.funk1@gmail.com>
    
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1113
    
    (cherry picked from commit 8268a31bcceb9ebe32d380cab792c89c5d897d15)
---
 usr.bin/which/which.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c
index f6ee25f60cce..dc22efb815d8 100644
--- a/usr.bin/which/which.c
+++ b/usr.bin/which/which.c
@@ -45,7 +45,7 @@ int
 main(int argc, char **argv)
 {
 	char *p, *path;
-	ssize_t pathlen;
+	size_t pathlen;
 	int opt, status;
 
 	status = EXIT_SUCCESS;