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: pgpnSP9Ep7PUR.pgp
Description: PGP signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to