[Libguestfs] [PATCH libnbd v2 8/8] lib/crypto.c: Remove unneeded else

Nir Soffer nsoffer at redhat.com
Sun Oct 31 15:38:57 UTC 2021


We return on successful if, so the else is not needed. This makes the
flow more clear.

Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
 lib/crypto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/crypto.c b/lib/crypto.c
index 09d98fd..340a6a0 100644
--- a/lib/crypto.c
+++ b/lib/crypto.c
@@ -147,10 +147,12 @@ nbd_unlocked_get_tls_username (struct nbd_handle *h)
       free (str.ptr);
       return NULL;
     }
+
     if (getlogin_r (str.ptr, str.cap) == 0) {
       return str.ptr;
     }
-    else if (errno != ERANGE) {
+
+    if (errno != ERANGE) {
       set_error (errno, "getlogin_r");
       free (str.ptr);
       return NULL;
-- 
2.31.1




More information about the Libguestfs mailing list