libsmb: Slightly simplify smbc_init()
authorVolker Lendecke <vl@samba.org>
Sat, 1 Apr 2023 10:47:51 +0000 (12:47 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 18 Apr 2023 14:58:36 +0000 (14:58 +0000)
Reduce indentation with an early return, review with git show -w

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/libsmb_compat.c

index c916122d0b82d1ce2de389f80171249abfb8c036..465bb3c70ee4f0cf69413e8db261e7cd445663a7 100644 (file)
@@ -117,23 +117,24 @@ int
 smbc_init(smbc_get_auth_data_fn fn,
           int debug)
 {
-       if (!smbc_compat_initialized) {
-               statcont = smbc_new_context();
-               if (!statcont)
-                       return -1;
-
-                smbc_setDebug(statcont, debug);
-                smbc_setFunctionAuthData(statcont, fn);
+       if (smbc_compat_initialized) {
+               return 0;
+       }
 
-               if (!smbc_init_context(statcont)) {
-                       smbc_free_context(statcont, False);
-                       return -1;
-               }
+       statcont = smbc_new_context();
+       if (!statcont)
+               return -1;
 
-               smbc_compat_initialized = 1;
+       smbc_setDebug(statcont, debug);
+       smbc_setFunctionAuthData(statcont, fn);
 
-               return 0;
+       if (!smbc_init_context(statcont)) {
+               smbc_free_context(statcont, False);
+               return -1;
        }
+
+       smbc_compat_initialized = 1;
+
        return 0;
 }