linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [fs-btrfs] question about apparent useless function call
Date: Thu, 18 May 2017 16:02:40 +0200	[thread overview]
Message-ID: <20170518140240.GQ4065@suse.cz> (raw)
In-Reply-To: <20170517173744.Horde.ZnZtEWjHK8oS0VfIRkwAwkd@gator4166.hostgator.com>

On Wed, May 17, 2017 at 05:37:44PM -0500, Gustavo A. R. Silva wrote:
> While looking into Coverity ID 1398149 I ran into the following piece  
> of code at fs/btrfs/zlib.c:295:
> 
> 295done:
> 296        zlib_inflateEnd(&workspace->strm);
> 297        if (data_in)
> 298                kunmap(pages_in[page_in_index]);
> 299        if (!ret)
> 300                zero_fill_bio(orig_bio);
> 301        return ret;
> 302}
> 
> The issue here is that calling function zlib_inflateEnd() at line 296  
> _seems_ to be useless once this function _seems_ to be only useful for  
> its return value, which is ignored. The same for line 388.
> 
> Can someone help me understand what is the purpose of these calls?
> Should them be removed, or the return value actually evaluated?

I don't think that removing the functions is a good idea, even if
they're trivial in the end. The error value needs to be checked but
seems that the only thing we can do at that point is to inform the user
that something bad happen inside the decompressor.  The cleanup (kunmap
or memset) has to be done anyway.

      reply	other threads:[~2017-05-18 14:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 22:37 [fs-btrfs] question about apparent useless function call Gustavo A. R. Silva
2017-05-18 14:02 ` David Sterba [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170518140240.GQ4065@suse.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=garsilva@embeddedor.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).