libdiff: More type issues.

Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D45080
This commit is contained in:
Dag-Erling Smørgrav 2024-05-03 18:32:41 +02:00
parent b985c9cafd
commit b95e96028e

View file

@ -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:")) {