Re: [PATCH 1/2] util: Don't fail virGetUserIDByName when user not found

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

 



On Fri, Dec 07, 2012 at 01:40:20AM +0800, Osier Yang wrote:
> How about make the logic a bit more clear like:
> 
>     if (!pw) {
>         if ((rc == 0) || (rc == EINTR) || (rc == EIO) ||
>             (rc == EMFILE) || (rc == ENFILE) || (rc == ENOMEM)) {

This does not look right, we want to run the code from the 'else' block
when rc is EINTR, EIO, EMFILE, ENFILE or ENOMEM, ie something like

if (!pw) {
    if (rc == 0 ||
        (rc != EINTR && rc != EIO && rc != EMFILE && rc != ENFILE && rc != ENOMEM)) {

             VIR_DEBUG("User record for user '%s' does not exist", name);
             ret = 1;
             goto cleanup;
         } else {
             virReportSystemError(rc, _("Failed to get user record for name '%s'"),
                                  name);
             goto cleanup;
         }
     }
}
*uid = pw->pw_uid;
ret = 0;

I'm not sure this is much clearer than the initial version, though
reworking that test would be a good opportunity to remove the extra () that
Eric mentioned, so feel free to change it.

Christophe

Attachment: pgpR26KRUUZJ8.pgp
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]