Merge pull request #103 from mackerel3/antipattern

use strncat(sizeof(...) - strlen(...) - 1)
This commit is contained in:
Thomas Arp 2022-09-03 12:33:01 +02:00 committed by GitHub
commit 16a46903e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -1148,7 +1148,7 @@ int format_script(struct descriptor_data *d)
*line = '\0'; *line = '\0';
for (nlen = 0, i = 0;i<indent;i++) { for (nlen = 0, i = 0;i<indent;i++) {
strncat(line, " ", sizeof(line)-1); strncat(line, " ", sizeof(line) - strlen(line) - 1);
nlen += 2; nlen += 2;
} }

View file

@ -268,7 +268,7 @@ void create_world_index(int znum, const char *type)
while (get_line(oldfile, buf)) { while (get_line(oldfile, buf)) {
if (*buf == '$') { if (*buf == '$') {
/* The following used to add a blank line, thanks to Brian Taylor for the fix. */ /* The following used to add a blank line, thanks to Brian Taylor for the fix. */
fprintf(newfile, "%s", (!found ? strncat(buf1, "\n$\n", sizeof(buf1)-1) : "$\n")); fprintf(newfile, "%s", (!found ? strncat(buf1, "\n$\n", sizeof(buf1) - strlen(buf1) - 1) : "$\n"));
break; break;
} else if (!found) { } else if (!found) {
sscanf(buf, "%d", &num); sscanf(buf, "%d", &num);