From owner-svn-src-all@freebsd.org Wed Oct 2 12:00:10 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DB1212CB92; Wed, 2 Oct 2019 12:00:10 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46jvpL0gkWz4Jpy; Wed, 2 Oct 2019 12:00:10 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id DFD10A74B; Wed, 2 Oct 2019 12:00:09 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f173.google.com with SMTP id w14so25894313qto.9; Wed, 02 Oct 2019 05:00:09 -0700 (PDT) X-Gm-Message-State: APjAAAVMo+A/Eer5vtGDhFgEZLGRTYh0rsOQ30Rk1rLNZu47oI/rvg2A I92GGP3iQvF505EFuwpj+IYDNRUD55likVVipd4= X-Google-Smtp-Source: APXvYqxyWg9NWIxnjpqSVXCB7J9VSHRlkRhf/McVJxkzYZFvvlAzJQYSpL/llbtHeqw9WM5TzZUXz4Z5RgKKtzSKG0I= X-Received: by 2002:a0c:9276:: with SMTP id 51mr2484973qvz.35.1570017609280; Wed, 02 Oct 2019 05:00:09 -0700 (PDT) MIME-Version: 1.0 References: <201910020615.x926FUJj091147@repo.freebsd.org> In-Reply-To: From: Kyle Evans Date: Wed, 2 Oct 2019 06:59:57 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r352953 - in head/usr.bin: killall split To: Conrad Meyer Cc: Alexander Kabaev , src-committers , svn-src-all , svn-src-head , Kubilay Kocak Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Oct 2019 12:00:10 -0000 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. On Wed, Oct 2, 2019, 02:03 Conrad Meyer 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 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(); >