[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [[PATCH v2 2/2] libxl: replace deprecated readdir_r() with readdir()



On Thu, Jun 2, 2016 at 12:13 PM, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.