Convert pnmatch to single element array in regexec calls
The regexec function is declared as taking an array of regmatch_t elements, and passing in the pointer to singleton element, while correct, triggers a Coverity warning. Convert the singleton into an array of one to silence the warning. Reported by: Coverity Coverity CID: 1009732, 1009733 MFC after: 2 weeks
This commit is contained in:
parent
5a391b572b
commit
c5672dd7b9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352953
@ -98,7 +98,7 @@ main(int ac, char **av)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
regex_t rgx;
|
regex_t rgx;
|
||||||
regmatch_t pmatch;
|
regmatch_t pmatch[1];
|
||||||
int i, j, ch;
|
int i, j, ch;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char first;
|
char first;
|
||||||
@ -361,9 +361,9 @@ main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mflag) {
|
if (mflag) {
|
||||||
pmatch.rm_so = 0;
|
pmatch[0].rm_so = 0;
|
||||||
pmatch.rm_eo = strlen(thiscmd);
|
pmatch[0].rm_eo = strlen(thiscmd);
|
||||||
if (regexec(&rgx, thiscmd, 0, &pmatch,
|
if (regexec(&rgx, thiscmd, 0, pmatch,
|
||||||
REG_STARTEND) != 0)
|
REG_STARTEND) != 0)
|
||||||
matched = 0;
|
matched = 0;
|
||||||
regfree(&rgx);
|
regfree(&rgx);
|
||||||
@ -387,9 +387,9 @@ main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mflag) {
|
if (mflag) {
|
||||||
pmatch.rm_so = 0;
|
pmatch[0].rm_so = 0;
|
||||||
pmatch.rm_eo = strlen(thiscmd);
|
pmatch[0].rm_eo = strlen(thiscmd);
|
||||||
if (regexec(&rgx, thiscmd, 0, &pmatch,
|
if (regexec(&rgx, thiscmd, 0, pmatch,
|
||||||
REG_STARTEND) == 0)
|
REG_STARTEND) == 0)
|
||||||
matched = 1;
|
matched = 1;
|
||||||
regfree(&rgx);
|
regfree(&rgx);
|
||||||
|
@ -281,11 +281,11 @@ split2(void)
|
|||||||
|
|
||||||
/* Check if we need to start a new file */
|
/* Check if we need to start a new file */
|
||||||
if (pflag) {
|
if (pflag) {
|
||||||
regmatch_t pmatch;
|
regmatch_t pmatch[1];
|
||||||
|
|
||||||
pmatch.rm_so = 0;
|
pmatch[0].rm_so = 0;
|
||||||
pmatch.rm_eo = len - 1;
|
pmatch[0].rm_eo = len - 1;
|
||||||
if (regexec(&rgx, bfr, 0, &pmatch, REG_STARTEND) == 0)
|
if (regexec(&rgx, bfr, 0, pmatch, REG_STARTEND) == 0)
|
||||||
newfile();
|
newfile();
|
||||||
} else if (lcnt++ == numlines) {
|
} else if (lcnt++ == numlines) {
|
||||||
newfile();
|
newfile();
|
||||||
|
Loading…
Reference in New Issue
Block a user