1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

config/util: resolve coverity issues

This commit is contained in:
Peter Howkins 2018-04-04 20:16:24 +01:00
parent ccab0597ed
commit c12c130ece
2 changed files with 16 additions and 12 deletions

View file

@ -179,7 +179,7 @@ int equivalent(lname, rname)
return 1; return 1;
for (s = lname; *s && (s = strchr(s, '/')); s++) { for (s = lname; *s && (s = strchr(s, '/')); s++) {
while (s[1] == '/') while (s[1] == '/')
strcpy(s+1, s+2); memmove(s + 1, s + 2, strlen(s + 2) + 1);
} }
return !strcmp(lname, rname); return !strcmp(lname, rname);
} }
@ -210,12 +210,12 @@ int rel; /* if true, prepend "../" to fn before using */
return 1; return 1;
} }
if (rel) if (rel) {
strcpy (buf, "../"); snprintf(buf, sizeof(buf), "../%s", fn);
else } else {
buf[0] = '\0'; snprintf(buf, sizeof(buf), "%s", fn);
strcat (buf, fn); }
if (!(df = opendir (buf))) { if (!(df = opendir (buf))) {
msg ("%s: Cannot opendir", buf); msg ("%s: Cannot opendir", buf);
return 1; return 1;

View file

@ -298,10 +298,12 @@ static void WriteHeader (tagline, phile, abi)
(*headerproc[abi])(f, phile); (*headerproc[abi])(f, phile);
if (phile->tmpl) CopyTmplEpilog (phile->tmpl, f); if (phile->tmpl) {
CopyTmplEpilog (phile->tmpl, f);
(void) fclose (phile->tmpl);
}
(void) free (fileprotstr); (void) free (fileprotstr);
(void) fclose (phile->tmpl);
(void) fclose (f); (void) fclose (f);
} }
@ -465,7 +467,10 @@ static void WriteSource(tagline, abi)
(*sourceproc[abi])(abi); (*sourceproc[abi])(abi);
if (tmpl) CopyTmplEpilog (tmpl, stdout); if (tmpl) {
CopyTmplEpilog (tmpl, stdout);
fclose(tmpl);
}
} }
static void DoLine(buf) static void DoLine(buf)
@ -613,8 +618,7 @@ static void DoLine(buf)
else else
right = buf + 1; right = buf + 1;
if (buf[0] == 'H') { if (buf[0] == 'H') {
strncpy (lbuf, prefixstr, 1024); snprintf(lbuf, sizeof(lbuf), "%s%s", prefixstr, right);
strncat (lbuf, right, strlen(right));
right = lbuf; right = lbuf;
} }