[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()



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 :-).

> if (errno) {
>    LOGE(ERROR, "readdir failed: %s", strerror(errno));
>    rc = ERROR_FAIL;
> }
> errno = saved_errno;

I haven't eyeballed the context in detail but I don't understand why
you think it necessary to save and restore errno.  All the many system
and library calls made throughout this code may overwrite it anyway.

Ian.

_______________________________________________
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®.