[libvirt] [PATCH 2/2] nodeinfo: use virDirRead API

Eric Blake eblake at redhat.com
Mon Apr 21 22:09:13 UTC 2014


On 04/20/2014 05:53 AM, Natanael Copa wrote:
> This makes sure that errno is reset before readdir is called, even if
> the loop does a 'continue'.
> 
> This fixes issue with musl libc which sets errno on sscanf. The
> following 'continue' makes the errno be set before calling readdir.
> 
> Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
> ---
>  src/nodeinfo.c | 29 ++++++++---------------------
>  1 file changed, 8 insertions(+), 21 deletions(-)

> @@ -452,8 +453,7 @@ virNodeParseNode(const char *node,
>  
>      /* enumerate sockets in the node */
>      CPU_ZERO(&sock_map);
> -    errno = 0;
> -    while ((cpudirent = readdir(cpudir))) {
> +    while ((direrr = virDirRead(cpudir, &cpudirent, node)) == 0) {

Depends on whether we tweak return semantics of 0 vs 1 in patch 1.  But
modulo that design decision (anyone else with an opinion?) the
conversion is sane.  Are you planning on filling out the series to
include all other clients of readdir()?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140421/905abd57/attachment-0001.sig>


More information about the libvir-list mailing list