[libvirt] [PATCH 1/2] util: Don't fail virGetUserIDByName when user not found
Christophe Fergeau
cfergeau at redhat.com
Fri Dec 7 09:02:47 UTC 2012
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121207/8c957be6/attachment-0001.sig>
More information about the libvir-list
mailing list