From owner-svn-src-all@freebsd.org Wed Oct 2 07:02:56 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 40A241246A2; Wed, 2 Oct 2019 07:02:56 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46jnCN0vWLz3PY3; Wed, 2 Oct 2019 07:02:55 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io1-f68.google.com with SMTP id z19so54617862ior.0; Wed, 02 Oct 2019 00:02:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=Lo9rf17BD6rYIKM8WWgyg/Y5LjfecYFXAmN1Zv/NWLo=; b=hBcJmjxlBGnvo08DdEGtM/Jy5t3koLiL7IV/osyf/x5F5ZoBXCUiwmDxCno5XSfSSg 75YPirYRl5L67YvtUQ3Z8wFAmir2n5RPZBe06dAlJrvvODTWihPstxMeLCgb0vYe6tpR M6nQc8jYJpvUuJsqRl89jk42a6ucRKK59Zx17ms26dt4F+ascTloXACtBZJrPksFkFYq vlgB4zmZ87kHYhqhagm4/LnO0JHN5aO71azRAcK2t04CNVYH5rAMy3OFjAvb5viItF37 RHM5QHEkph25kPFJjRc/ULRFhrHe3S11UAnSE3UBgSyx/SmYsin5dF4ya8UocdjNQOIT olww== X-Gm-Message-State: APjAAAV6QYl7L2OF7ummil0keZ1q5qUOngJK1Rz/iPJbz0ATjxhP7Fj0 eGluOWpXaGZrX1PSRR8O1WoBKwml X-Google-Smtp-Source: APXvYqxQIqyrRXlq71ZN4i+caYHWqoDQdKLH7zHxdpQ7/WrtohFJne+z/+o/JGMcyp5yA1XoImk7bA== X-Received: by 2002:a5d:9903:: with SMTP id x3mr2103529iol.28.1569999774492; Wed, 02 Oct 2019 00:02:54 -0700 (PDT) Received: from mail-io1-f47.google.com (mail-io1-f47.google.com. [209.85.166.47]) by smtp.gmail.com with ESMTPSA id k5sm8632899ilg.17.2019.10.02.00.02.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Oct 2019 00:02:54 -0700 (PDT) Received: by mail-io1-f47.google.com with SMTP id a1so54530035ioc.6; Wed, 02 Oct 2019 00:02:53 -0700 (PDT) X-Received: by 2002:a92:aa48:: with SMTP id j69mr2410124ili.231.1569999773575; Wed, 02 Oct 2019 00:02:53 -0700 (PDT) MIME-Version: 1.0 References: <201910020615.x926FUJj091147@repo.freebsd.org> In-Reply-To: <201910020615.x926FUJj091147@repo.freebsd.org> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Wed, 2 Oct 2019 00:02:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r352953 - in head/usr.bin: killall split To: Alexander Kabaev Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46jnCN0vWLz3PY3 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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 07:02:56 -0000 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();