From owner-svn-src-head@freebsd.org Mon Feb 27 02:49:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8589ECEF21E for ; Mon, 27 Feb 2017 02:49:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm17-vm0.bullet.mail.ne1.yahoo.com (nm17-vm0.bullet.mail.ne1.yahoo.com [98.138.91.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51C0829C for ; Mon, 27 Feb 2017 02:49:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1488163739; bh=T94pAVqPzJGPGi2ZGXEF4OYxlnZ9iwVpxcgegpzNsUo=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=elFETUNbcup1ZMZ3Izo7hdvLBC4peJfoHncTzgKPypfph7S42xiSvKqJK99Ttfnt3o9mTEz86NGSI7++km+3MFS2GgLLfMGMj9Hz2IFIzOBUNEjb72C6l94VtjmmoIbTRBcZ7j83P0qIUHTdCi8Vq7eUdg2DX3PSJjUfCwlZuEovkVl/Sv+mOXAEFOyJrh27XT0OkTh9dSzzMGKtIVUKfTRhZrTW+m24e+gcfL5KYPQOsk8zFzXrj9PmjcsbPXK18wHpqVztinnU0GebZIvwW0VgaDUwC+og3EWkM1W8WAWzu3zZJ/eA9W3couUxoIF6EIXarnUW75y3Yn3fWVgCkQ== Received: from [98.138.100.111] by nm17.bullet.mail.ne1.yahoo.com with NNFMP; 27 Feb 2017 02:48:59 -0000 Received: from [98.138.84.47] by tm100.bullet.mail.ne1.yahoo.com with NNFMP; 27 Feb 2017 02:48:59 -0000 Received: from [127.0.0.1] by smtp115.mail.ne1.yahoo.com with NNFMP; 27 Feb 2017 02:48:59 -0000 X-Yahoo-Newman-Id: 494556.31278.bm@smtp115.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: J6LHWS8VM1kEeMvf6eEhGCb6ACudEUqaaq_hCnOHFg7RMak oHT0mN8TuyIwqu0Z2cFYxcDo.0kgF2vk.7ooKQYOcLL2Xi.fCwe_uyMIO5R8 q_56hsOBkVuO6dQnyneMpyQfC9wkdm5ap1OdkHjLrpI5mLf1X5fa.yhfqOAd 4tLHj2TG1W1Vi5IMehKZufbu25Hv_ipjvzjuC1jLqPoYlfNqxjsIFtfX2G.J 6V3YApJp5BZZdRswHoE0aphjPmgueRjRQogHOtwIRs43v6C0U7QfX.twjJhZ Jx.hNt7zfhn0aodz.IQy8UKwxtU8g.Mi2DpOawGLbK9lYzrmImXL1DoAerd6 5j9k4QJA8IHOYd0.nBl1HGWzXqeYwfqL3tWy3CIe5XTP9hyER2xtLhK.ngfY Ha9Q5fFxliQ1Hpln2tGQdbSUr7Pk7fEwBrUS1X3t3gGUojBb3NXXx8aQZcvW eqsmZZlkDpTr7WAJkYRAgaKmZjg_8ABUREJGl0WF3bbYTLi.txEVk69gpHtp DNcdjQ4ix5OphdrjBmUddY1cCXBgCZf5XliKjXi9646n9F5I- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r314322 - head/lib/librss To: Cy Schubert References: <201702270237.v1R2bSsC004156@slippy.cwsent.com> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Pedro Giffuni Message-ID: <6a8a34b7-e6ff-b8e2-44a6-7e3cc08e6e3d@FreeBSD.org> Date: Sun, 26 Feb 2017 21:51:47 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <201702270237.v1R2bSsC004156@slippy.cwsent.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 02:49:06 -0000 On 2/26/2017 9:37 PM, Cy Schubert wrote: > In message <404d743b-735b-0605-5ab5-ccb95ce24ad8@FreeBSD.org>, Pedro > Giffuni wr > ites: >> This is a multi-part message in MIME format. >> --------------C3FC59CAC7D072A09BF70AAF >> Content-Type: text/plain; charset=windows-1252; format=flowed >> Content-Transfer-Encoding: 7bit >> >> Hello; >> >> On 2/26/2017 8:51 PM, Cy Schubert wrote: >>> In message <201702270010.v1R0A1wm074123@repo.freebsd.org>, "Pedro F. >>> Giffuni" w >>> rites: >>>> Author: pfg >>>> Date: Mon Feb 27 00:10:00 2017 >>>> New Revision: 314322 >>>> URL: https://svnweb.freebsd.org/changeset/base/314322 >>>> >>>> Log: >>>> librss: simplify some NULL checks. >>>> >>>> MFC after: 1 week >>>> >>>> Modified: >>>> head/lib/librss/librss.c >>>> >>>> Modified: head/lib/librss/librss.c >>>> ========================================================================== >> === >>>> = >>>> --- head/lib/librss/librss.c Sun Feb 26 22:17:06 2017 (r31432 >> 1) >>>> +++ head/lib/librss/librss.c Mon Feb 27 00:10:00 2017 (r31432 >> 2) >>>> @@ -244,10 +244,10 @@ rss_config_get(void) >>>> return (rc); >>>> >>>> error: >>>> - if ((rc != NULL) && rc->rss_bucket_map) >>>> + if (rc != NULL) { >>>> free(rc->rss_bucket_map); >>> What happens if rc is not NULL and rc->rss_bucket_map is NULL? >> According the free(3): " If /ptr/ is *NULL*, no action occurs." >> > Good point. > > Then why even test for RC being NULL? If rc is NULL, there is a chance that rc->rss_bucket_map is random garbage and you might be "double freeing" something. > The only reason I can think of doing any test for NULL before free(3) is > that if the likelihood of *ptr being NULL is greater than the likelihood of > *ptr not being NULL then you save running the extra instructions to make > that determination in free(), e.g. pushes, call, return, pops. > The check for rc NULL is necessary, the only optimization is that having done the check we already know if we need to free(rc), so while we could leave the second free() outside the branch it is better to leave it within the "if" . Pedro.