mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH] lib: libfile: Do not ignore errors in close()
Date: Mon, 20 Jul 2015 12:51:29 -0700	[thread overview]
Message-ID: <CAHQ1cqGyY6JcqUp1R5qwwrP6g+FEGG4YDZit16vXxuCpiAt+YA@mail.gmail.com> (raw)
In-Reply-To: <20150714050815.GM18700@pengutronix.de>

>>       free(rw_buf);
>>       if (srcfd > 0)
>> -             close(srcfd);
>> +             err1 = close(srcfd);
>>       if (dstfd > 0)
>> -             close(dstfd);
>> +             err2 = close(dstfd);
>
> I agree that an error on closing the destination is an error for
> copy_file, but is an error on closing the source file an error for
> copy_file? We read everything from the source, so errors while closing
> the file should not be relevant.

I guess it depends on one's interpretation of what "success" means for
execution of copy_file(). I personally interpret it as: "the function
accomplished what is was supposed to do and all of the operations that
had to be done in order to do that completed without any errors", but
I can see how that being defined as "the function accomplished it's
main purpose with some possible minor failures" could work too. Since
I expect a call to close() to not fail for 99% of the time I don't see
any harm in checking for errors from both calls, but I don't feel very
strongly about the subject so if you want it I can remove the extra
check.

Andrey

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2015-07-20 19:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13  0:09 Andrey Smirnov
2015-07-14  5:08 ` Sascha Hauer
2015-07-20 19:51   ` Andrey Smirnov [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=CAHQ1cqGyY6JcqUp1R5qwwrP6g+FEGG4YDZit16vXxuCpiAt+YA@mail.gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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