git: b95e96028e5a - main - libdiff: More type issues.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Fri, 03 May 2024 16:32:51 UTC
The branch main has been updated by des:

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

commit b95e96028e5a53116462151aee8fda7523a68d09
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-05-03 16:32:41 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-05-03 16:32:41 +0000

    libdiff: More type issues.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D45080
---
 contrib/libdiff/lib/diff_output.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/contrib/libdiff/lib/diff_output.c b/contrib/libdiff/lib/diff_output.c
index 78d9b8942077..3b84608882f6 100644
--- a/contrib/libdiff/lib/diff_output.c
+++ b/contrib/libdiff/lib/diff_output.c
@@ -75,8 +75,8 @@ diff_output_lines(struct diff_output_info *outinfo, FILE *dest,
 	foreach_diff_atom(atom, start_atom, count) {
 		off_t outlen = 0;
 		int i, ch, nbuf = 0;
-		unsigned int len = atom->len;
-		unsigned char buf[DIFF_OUTPUT_BUF_SIZE + 1 /* '\n' */];
+		size_t len = atom->len, wlen;
+		char buf[DIFF_OUTPUT_BUF_SIZE + 1 /* '\n' */];
 		size_t n;
 
 		n = strlcpy(buf, prefix, sizeof(buf));
@@ -97,19 +97,19 @@ diff_output_lines(struct diff_output_info *outinfo, FILE *dest,
 			if (rc)
 				return rc;
 			if (nbuf >= DIFF_OUTPUT_BUF_SIZE) {
-				rc = fwrite(buf, 1, nbuf, dest);
-				if (rc != nbuf)
+				wlen = fwrite(buf, 1, nbuf, dest);
+				if (wlen != nbuf)
 					return errno;
-				outlen += rc;
+				outlen += wlen;
 				nbuf = 0;
 			}
 			buf[nbuf++] = ch;
 		}
 		buf[nbuf++] = '\n';
-		rc = fwrite(buf, 1, nbuf, dest);
-		if (rc != nbuf)
+		wlen = fwrite(buf, 1, nbuf, dest);
+		if (wlen != nbuf)
 			return errno;
-		outlen += rc;
+		outlen += wlen;
 		if (outinfo) {
 			ARRAYLIST_ADD(offp, outinfo->line_offsets);
 			if (offp == NULL)
@@ -253,7 +253,7 @@ diff_output_trailing_newline_msg(struct diff_output_info *outinfo, FILE *dest,
 }
 
 static bool
-is_function_prototype(unsigned char ch)
+is_function_prototype(char ch)
 {
 	return (isalpha((unsigned char)ch) || ch == '_' || ch == '$' ||
 	    ch == '-' || ch == '+');
@@ -268,7 +268,7 @@ diff_output_match_function_prototype(char *prototype, size_t prototype_size,
 {
 	struct diff_atom *start_atom, *atom;
 	const struct diff_data *data;
-	unsigned char buf[DIFF_FUNCTION_CONTEXT_SIZE];
+	char buf[DIFF_FUNCTION_CONTEXT_SIZE];
 	const char *state = NULL;
 	int rc, i, ch;
 
@@ -285,7 +285,7 @@ diff_output_match_function_prototype(char *prototype, size_t prototype_size,
 		rc = get_atom_byte(&ch, atom, 0);
 		if (rc)
 			return rc;
-		buf[0] = (unsigned char)ch;
+		buf[0] = ch;
 		if (!is_function_prototype(buf[0]))
 			continue;
 		for (i = 1; i < atom->len && i < sizeof(buf) - 1; i++) {
@@ -294,7 +294,7 @@ diff_output_match_function_prototype(char *prototype, size_t prototype_size,
 				return rc;
 			if (ch == '\n')
 				break;
-			buf[i] = (unsigned char)ch;
+			buf[i] = ch;
 		}
 		buf[i] = '\0';
 		if (begins_with(buf, "private:")) {