[libvirt] [PATCH] lock_daemon: Simplify error handling

No need to check the run_dir variable twice for NULL. --- src/locking/lock_daemon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index f0eba48..97e5d74 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1311,19 +1311,16 @@ int main(int argc, char **argv) { /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - run_dir = strdup(LOCALSTATEDIR "/run/libvirt"); + if (!(run_dir = strdup(LOCALSTATEDIR "/run/libvirt"))) { + virReportOOMError(); + goto cleanup; + } } else { - run_dir = virGetUserRuntimeDirectory(); - - if (!run_dir) { + if (!(run_dir = virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); goto cleanup; } } - if (!run_dir) { - virReportOOMError(); - goto cleanup; - } if (privileged) old_umask = umask(022); -- 1.8.1.1

On 01/16/2013 07:07 PM, Peter Krempa wrote:
No need to check the run_dir variable twice for NULL. --- src/locking/lock_daemon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index f0eba48..97e5d74 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1311,19 +1311,16 @@ int main(int argc, char **argv) {
/* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - run_dir = strdup(LOCALSTATEDIR "/run/libvirt"); + if (!(run_dir = strdup(LOCALSTATEDIR "/run/libvirt"))) { + virReportOOMError(); + goto cleanup; + } } else { - run_dir = virGetUserRuntimeDirectory(); - - if (!run_dir) { + if (!(run_dir = virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); goto cleanup; } } - if (!run_dir) { - virReportOOMError(); - goto cleanup; - }
if (privileged) old_umask = umask(022);
ACK.

On 01/16/13 12:54, Guannan Ren wrote:
On 01/16/2013 07:07 PM, Peter Krempa wrote:
No need to check the run_dir variable twice for NULL. --- src/locking/lock_daemon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
[...]
ACK.
Thanks for the review. Pushed. Peter
participants (2)
-
Guannan Ren
-
Peter Krempa