From: tb Date: Tue, 10 Jul 2018 17:45:52 +0000 (+0000) Subject: Fix a few, but not all, clang warnings: Use "%s" to print modifiable X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0971b67f68eabe84e58ba202abe73d50c878d1ac;p=openbsd Fix a few, but not all, clang warnings: Use "%s" to print modifiable strings, add a couple of braces, ansify a few functions, add and remove a few extra parens. ok jcs --- diff --git a/gnu/usr.bin/cvs/diff/diff3.c b/gnu/usr.bin/cvs/diff/diff3.c index 4a6fba618c2..10903fa2e29 100644 --- a/gnu/usr.bin/cvs/diff/diff3.c +++ b/gnu/usr.bin/cvs/diff/diff3.c @@ -1502,7 +1502,7 @@ output_diff3 (diff, mapping, rev_mapping) line = 0; do { - printf_output (line_prefix); + printf_output ("%s", line_prefix); cp = D_RELNUM (ptr, realfile, line); length = D_RELLEN (ptr, realfile, line); write_output (cp, length); @@ -1554,11 +1554,12 @@ undotlines (leading_dot, start, num) int leading_dot, start, num; { write_output (".\n", 2); - if (leading_dot) + if (leading_dot) { if (num == 1) printf_output ("%ds/^\\.//\n", start); else printf_output ("%d,%ds/^\\.//\n", start, start + num - 1); + } } /* @@ -1749,11 +1750,12 @@ output_diff3_merge (infile, diff, mapping, rev_mapping, do { c = getc (infile); - if (c == EOF) + if (c == EOF) { if (ferror (infile)) diff3_perror_with_exit ("input file"); else if (feof (infile)) diff3_fatal ("input file shrank"); + } cc = c; write_output (&cc, 1); } @@ -1803,7 +1805,7 @@ output_diff3_merge (infile, diff, mapping, rev_mapping, linesread += i; while (0 <= --i) while ((c = getc (infile)) != '\n') - if (c == EOF) + if (c == EOF) { if (ferror (infile)) diff3_perror_with_exit ("input file"); else if (feof (infile)) @@ -1812,6 +1814,7 @@ output_diff3_merge (infile, diff, mapping, rev_mapping, diff3_fatal ("input file shrank"); return conflicts_found; } + } } /* Copy rest of common file. */ while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile))) diff --git a/gnu/usr.bin/cvs/diff/side.c b/gnu/usr.bin/cvs/diff/side.c index d776e77eab3..8836c1f471e 100644 --- a/gnu/usr.bin/cvs/diff/side.c +++ b/gnu/usr.bin/cvs/diff/side.c @@ -122,7 +122,7 @@ print_half_line (line, indent, out_bound) break; case '\b': - if (in_position != 0 && --in_position < out_bound) + if (in_position != 0 && --in_position < out_bound) { if (out_position <= in_position) /* Add spaces to make up for suppressed tab past out_bound. */ for (; out_position < in_position; out_position++) @@ -133,6 +133,7 @@ print_half_line (line, indent, out_bound) cc = c; write_output (&cc, 1); } + } break; case '\f': diff --git a/gnu/usr.bin/cvs/lib/getline.c b/gnu/usr.bin/cvs/lib/getline.c index bda96e27e14..4d49b6b64a5 100644 --- a/gnu/usr.bin/cvs/lib/getline.c +++ b/gnu/usr.bin/cvs/lib/getline.c @@ -46,13 +46,8 @@ char *malloc (), *realloc (); error. */ int -getstr (lineptr, n, stream, terminator, offset, limit) - char **lineptr; - size_t *n; - FILE *stream; - char terminator; - int offset; - int limit; +getstr (char **lineptr, size_t *n, FILE *stream, char terminator, int offset, + int limit) { int nchars_avail; /* Allocated but unused chars in *LINEPTR. */ char *read_pos; /* Where we're reading into *LINEPTR. */ @@ -154,20 +149,13 @@ getstr (lineptr, n, stream, terminator, offset, limit) } int -get_line (lineptr, n, stream) - char **lineptr; - size_t *n; - FILE *stream; +get_line (char **lineptr, size_t *n, FILE *stream) { return getstr (lineptr, n, stream, '\n', 0, GETLINE_NO_LIMIT); } int -getline_safe (lineptr, n, stream, limit) - char **lineptr; - size_t *n; - FILE *stream; - int limit; +getline_safe (char **lineptr, size_t *n, FILE *stream, int limit) { return getstr (lineptr, n, stream, '\n', 0, limit); } diff --git a/gnu/usr.bin/cvs/lib/regex.c b/gnu/usr.bin/cvs/lib/regex.c index 1c3ab8d0e17..eea3447502f 100644 --- a/gnu/usr.bin/cvs/lib/regex.c +++ b/gnu/usr.bin/cvs/lib/regex.c @@ -2514,11 +2514,12 @@ regex_compile (pattern, size, syntax, bufp) case ')': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - if (COMPILE_STACK_EMPTY) + if (COMPILE_STACK_EMPTY) { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else FREE_STACK_RETURN (REG_ERPAREN); + } handle_close: if (fixup_alt_jump) @@ -2534,11 +2535,12 @@ regex_compile (pattern, size, syntax, bufp) } /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) + if (COMPILE_STACK_EMPTY) { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else FREE_STACK_RETURN (REG_ERPAREN); + } /* Since we just checked for an empty stack above, this ``can't happen''. */ diff --git a/gnu/usr.bin/cvs/src/admin.c b/gnu/usr.bin/cvs/src/admin.c index c5995ab831f..935e1b4c99b 100644 --- a/gnu/usr.bin/cvs/src/admin.c +++ b/gnu/usr.bin/cvs/src/admin.c @@ -776,7 +776,7 @@ admin_fileproc (callerdat, finfo) if (delta->other_delta == NULL) delta->other_delta = getlist(); - if (n = findnode (delta->other_delta, "commitid")) + if ((n = findnode (delta->other_delta, "commitid"))) { error (0, 0, "%s: revision %s already has commitid %s", rcs->path, rev, n->data); diff --git a/gnu/usr.bin/cvs/src/hash.c b/gnu/usr.bin/cvs/src/hash.c index 7e562b89f0d..66ec46a7eda 100644 --- a/gnu/usr.bin/cvs/src/hash.c +++ b/gnu/usr.bin/cvs/src/hash.c @@ -306,7 +306,7 @@ findnode (list, key) /* This probably should be "assert (list != NULL)" (or if not we should document the current behavior), but only if we check all the callers to see if any are relying on this behavior. */ - if ((list == (List *) NULL)) + if (list == (List *) NULL) return ((Node *) NULL); assert (key != NULL);