Module Name:    src
Committed By:   riastradh
Date:           Sat Aug 12 12:46:33 UTC 2023

Modified Files:
        src/lib/libc/gen: vis.c

Log Message:
vis(3): Make maxolen unsigned size_t, not ssize_t.

It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too.  So there appears to have never been any reason for this to be
signed.

Part of PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/lib/libc/gen/vis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/vis.c
diff -u src/lib/libc/gen/vis.c:1.76 src/lib/libc/gen/vis.c:1.77
--- src/lib/libc/gen/vis.c:1.76	Thu Jun 29 16:11:31 2023
+++ src/lib/libc/gen/vis.c	Sat Aug 12 12:46:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vis.c,v 1.76 2023/06/29 16:11:31 riastradh Exp $	*/
+/*	$NetBSD: vis.c,v 1.77 2023/08/12 12:46:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.76 2023/06/29 16:11:31 riastradh Exp $");
+__RCSID("$NetBSD: vis.c,v 1.77 2023/08/12 12:46:33 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 #ifdef __FBSDID
 __FBSDID("$FreeBSD$");
@@ -403,7 +403,8 @@ istrsenvisx(char **mbdstp, size_t *dlen,
 	visfun_t f;
 	int clen = 0, cerr, error = -1, i, shft;
 	char *mbdst, *mdst;
-	ssize_t mbslength, maxolen;
+	ssize_t mbslength;
+	size_t maxolen;
 	mbstate_t mbstate;
 
 	_DIAGASSERT(mbdstp != NULL);
@@ -569,7 +570,7 @@ istrsenvisx(char **mbdstp, size_t *dlen,
 			cerr = 1;
 		}
 		/* If this character would exceed our output limit, stop. */
-		if (olen + clen > (size_t)maxolen)
+		if (olen + clen > maxolen)
 			break;
 		/* Advance output pointer by number of bytes written. */
 		mbdst += clen;

Reply via email to