From: Chris Patterson <cjp256@gmail.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Chris Patterson <pattersonc@ainfosec.com>,
Wei Liu <wei.liu2@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [[PATCH v2 2/2] libxl: replace deprecated readdir_r() with readdir()
Date: Thu, 2 Jun 2016 14:51:40 -0400 [thread overview]
Message-ID: <CABZSBQdfxVbiS2GcJZ+os2trFYrefBA1AXiiT8N2dVuEYHLkfA@mail.gmail.com> (raw)
In-Reply-To: <22352.23310.897270.202510@mariner.uk.xensource.com>
On Thu, Jun 2, 2016 at 12:13 PM, Ian Jackson <Ian.Jackson@eu.citrix.com> wrote:
> Chris Patterson writes ("Re: [[PATCH v2 2/2] libxl: replace deprecated readdir_r() with readdir()"):
>> You're right, it should check for the error afterwards.
>>
>> How about something along the lines of:
>>
>> int saved_errno = errno;
>> errno = 0;
>> while ((de = readdir(dir)) != NULL) {
>> ...
>
> Wrong because you need to set errno=0 before each call to readdir.
> I really think you should abandon your efforts to keep the readdir
> call inside the while() condition :-).
>
I agree. How does something like this look?
- int r = readdir_r(dir, de_buf, &de);
-
- if (r) {
+ errno = 0;
+ de = readdir(dir);
+
+ if (!de && errno) {
And I'll apply the same construct for tools/libfsimage/common/fsimage_plugin.c.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
prev parent reply other threads:[~2016-06-02 18:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 18:19 [[PATCH v2 1/2] libfsimage: replace deprecated readdir_r() with readdir() Chris Patterson
2016-06-01 18:19 ` [[PATCH v2 2/2] libxl: " Chris Patterson
2016-06-02 10:11 ` Ian Jackson
2016-06-02 13:17 ` Chris Patterson
2016-06-02 16:13 ` Ian Jackson
2016-06-02 18:51 ` Chris Patterson [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=CABZSBQdfxVbiS2GcJZ+os2trFYrefBA1AXiiT8N2dVuEYHLkfA@mail.gmail.com \
--to=cjp256@gmail.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=pattersonc@ainfosec.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).