Date: Thu, 3 Oct 2019 21:55:20 +1000 From: Kubilay Kocak <koobs@FreeBSD.org> To: Kyle Evans <kevans@freebsd.org>, Conrad Meyer <cem@freebsd.org> Cc: Alexander Kabaev <kan@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org> Subject: Re: svn commit: r352953 - in head/usr.bin: killall split Message-ID: <0faf5475-b409-5d4c-da0a-4ec9b9c66e1d@FreeBSD.org> In-Reply-To: <CACNAnaGa9fjk=Tt5WZNt2Wc2bOUCm311ktidWs%2BS826H%2BabkRw@mail.gmail.com> References: <201910020615.x926FUJj091147@repo.freebsd.org> <CAG6CVpX4UF_WrLjkLBRJmKsza1Rfp5od%2BDJhHssVcNCzx=Tcow@mail.gmail.com> <CACNAnaGa9fjk=Tt5WZNt2Wc2bOUCm311ktidWs%2BS826H%2BabkRw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2/10/2019 9:59 pm, Kyle Evans wrote: > Sorry for the crap formatting, mobile. > > We can perhaps also fix this class with a proper modelling file. koobs was > going to send out an email about it, but I haven't seen anything. Thanks for the public reminder Kyle :] I'll flick it out soon > On Wed, Oct 2, 2019, 02:03 Conrad Meyer <cem@freebsd.org> wrote: > >> Hi Alexander, >> >> Coverity has millions of spurious warnings of this class and they're >> basically all false positives. I think we should instead try to >> figure out how to disable this class of warning on our codebase, since >> it is largely incorrect. >> >> I would encourage reverting this change, because it uglies up the code >> for no functional benefit. The code was correct before the change; >> only Coverity was wrong. >> >> Best, >> Conrad >> >> On Tue, Oct 1, 2019 at 11:15 PM Alexander Kabaev <kan@freebsd.org> wrote: >>> >>> Author: kan >>> Date: Wed Oct 2 06:15:30 2019 >>> New Revision: 352953 >>> URL: https://svnweb.freebsd.org/changeset/base/352953 >>> >>> Log: >>> 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 >>> >>> Modified: >>> head/usr.bin/killall/killall.c >>> head/usr.bin/split/split.c >>> >>> Modified: head/usr.bin/killall/killall.c >>> >> ============================================================================== >>> --- head/usr.bin/killall/killall.c Wed Oct 2 02:37:34 2019 >> (r352952) >>> +++ head/usr.bin/killall/killall.c Wed Oct 2 06:15:30 2019 >> (r352953) >>> @@ -98,7 +98,7 @@ main(int ac, char **av) >>> struct stat sb; >>> struct passwd *pw; >>> regex_t rgx; >>> - regmatch_t pmatch; >>> + regmatch_t pmatch[1]; >>> int i, j, ch; >>> char buf[256]; >>> char first; >>> @@ -361,9 +361,9 @@ main(int ac, char **av) >>> } >>> } >>> if (mflag) { >>> - pmatch.rm_so = 0; >>> - pmatch.rm_eo = strlen(thiscmd); >>> - if (regexec(&rgx, thiscmd, 0, &pmatch, >>> + pmatch[0].rm_so = 0; >>> + pmatch[0].rm_eo = strlen(thiscmd); >>> + if (regexec(&rgx, thiscmd, 0, pmatch, >>> REG_STARTEND) != 0) >>> matched = 0; >>> regfree(&rgx); >>> @@ -387,9 +387,9 @@ main(int ac, char **av) >>> } >>> } >>> if (mflag) { >>> - pmatch.rm_so = 0; >>> - pmatch.rm_eo = strlen(thiscmd); >>> - if (regexec(&rgx, thiscmd, 0, &pmatch, >>> + pmatch[0].rm_so = 0; >>> + pmatch[0].rm_eo = strlen(thiscmd); >>> + if (regexec(&rgx, thiscmd, 0, pmatch, >>> REG_STARTEND) == 0) >>> matched = 1; >>> regfree(&rgx); >>> >>> Modified: head/usr.bin/split/split.c >>> >> ============================================================================== >>> --- head/usr.bin/split/split.c Wed Oct 2 02:37:34 2019 (r352952) >>> +++ head/usr.bin/split/split.c Wed Oct 2 06:15:30 2019 (r352953) >>> @@ -281,11 +281,11 @@ split2(void) >>> >>> /* Check if we need to start a new file */ >>> if (pflag) { >>> - regmatch_t pmatch; >>> + regmatch_t pmatch[1]; >>> >>> - pmatch.rm_so = 0; >>> - pmatch.rm_eo = len - 1; >>> - if (regexec(&rgx, bfr, 0, &pmatch, REG_STARTEND) >> == 0) >>> + pmatch[0].rm_so = 0; >>> + pmatch[0].rm_eo = len - 1; >>> + if (regexec(&rgx, bfr, 0, pmatch, REG_STARTEND) >> == 0) >>> newfile(); >>> } else if (lcnt++ == numlines) { >>> newfile(); >> >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0faf5475-b409-5d4c-da0a-4ec9b9c66e1d>