[libvirt] [PATCH] locking: remove redundant codes

From: Alex Jia <ajia@redhat.com> * src/locking/lock_driver_sanlock.c: remove redundant codes in error_unlink label from virLockManagerSanlockSetupLockspace, in fact, the codes make sure 'path' is non-null before getting to error_unlink label, so 'if (path)' is redundant, removing it in here and will also silence coverity. Signed-off-by: Alex Jia <ajia@redhat.com> --- src/locking/lock_driver_sanlock.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c index 2d72510..c4dce4f 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -250,8 +250,7 @@ static int virLockManagerSanlockSetupLockspace(void) return 0; error_unlink: - if (path) - unlink(path); + unlink(path); error: VIR_FORCE_CLOSE(fd); VIR_FREE(path); -- 1.7.1

On 09/21/2011 07:15 PM, ajia@redhat.com wrote:
From: Alex Jia<ajia@redhat.com>
* src/locking/lock_driver_sanlock.c: remove redundant codes in error_unlink label from virLockManagerSanlockSetupLockspace, in fact, the codes make sure 'path' is non-null before getting to error_unlink label, so 'if (path)' is redundant, removing it in here and will also silence coverity.
I'd rather go with my more comprehensive patch, since it also fixes a mem leak: https://www.redhat.com/archives/libvir-list/2011-September/msg00865.html -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 09/22/2011 09:35 AM, Eric Blake wrote:
On 09/21/2011 07:15 PM, ajia@redhat.com wrote:
From: Alex Jia<ajia@redhat.com>
* src/locking/lock_driver_sanlock.c: remove redundant codes in error_unlink label from virLockManagerSanlockSetupLockspace, in fact, the codes make sure 'path' is non-null before getting to error_unlink label, so 'if (path)' is redundant, removing it in here and will also silence coverity.
I'd rather go with my more comprehensive patch, since it also fixes a mem leak: https://www.redhat.com/archives/libvir-list/2011-September/msg00865.html
Agree, my patch is incomplete, it's okay for me. Thanks, Alex
participants (3)
-
ajia@redhat.com
-
Alex Jia
-
Eric Blake