Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/grep/util.c
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | if (f == NULL) { | ||||
file_err = true; | file_err = true; | ||||
if (!sflag) | if (!sflag) | ||||
warn("%s", fn); | warn("%s", fn); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* Convenience */ | /* Convenience */ | ||||
ln = &pc.ln; | ln = &pc.ln; | ||||
pc.ln.file = grep_malloc(strlen(fn) + 1); | pc.ln.file = strdup(fn); | ||||
strcpy(pc.ln.file, fn); | |||||
pc.ln.line_no = 0; | pc.ln.line_no = 0; | ||||
cem: This clang-scan warning is bogus.
But: this could just be: `pc.ln.file = strdup(fn);`
| |||||
Done Inline ActionsIMO, the only non-bogus one was the memory leak, and that was still mostly bogus and not a practical concern. =p I'm ashamed to admit, though, that I hadn't noticed strdup(3) before. This is fixed. kevans: IMO, the only non-bogus one was the memory leak, and that was still mostly bogus and not a… | |||||
pc.ln.len = 0; | pc.ln.len = 0; | ||||
pc.ln.boff = 0; | pc.ln.boff = 0; | ||||
pc.ln.off = -1; | pc.ln.off = -1; | ||||
pc.binary = f->binary; | pc.binary = f->binary; | ||||
pc.printed = 0; | pc.printed = 0; | ||||
tail = 0; | tail = 0; | ||||
last_outed = 0; | last_outed = 0; | ||||
same_file = false; | same_file = false; | ||||
▲ Show 20 Lines • Show All 434 Lines • Show Last 20 Lines |
This clang-scan warning is bogus.
But: this could just be: pc.ln.file = strdup(fn);