]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
error_inject: Reduce indentation with an early return
authorVolker Lendecke <vl@samba.org>
Mon, 26 Jun 2023 10:48:16 +0000 (12:48 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 3 Jul 2023 19:40:35 +0000 (19:40 +0000)
Review with "git show -b"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_error_inject.c

index edb7c64a92a7bf94d9d914fa39cd295c78037de1..529504fd8d5e9d60ad621dd0114a2c6e152790f0 100644 (file)
@@ -52,29 +52,29 @@ static int find_unix_error_from_string(const char *err_str)
 static int inject_unix_error(const char *vfs_func, vfs_handle_struct *handle)
 {
        const char *err_str;
+       int error;
 
        err_str = lp_parm_const_string(SNUM(handle->conn),
                                       "error_inject", vfs_func, NULL);
+       if (err_str == NULL) {
+               return 0;
+       }
 
-       if (err_str != NULL) {
-               int error;
-
-               error = find_unix_error_from_string(err_str);
-               if (error != 0) {
-                       DBG_WARNING("Returning error %s for VFS function %s\n",
-                                   err_str, vfs_func);
-                       return error;
-               }
-
-               if (strequal(err_str, "panic")) {
-                       DBG_ERR("Panic in VFS function %s\n", vfs_func);
-                       smb_panic("error_inject");
-               }
+       error = find_unix_error_from_string(err_str);
+       if (error != 0) {
+               DBG_WARNING("Returning error %s for VFS function %s\n",
+                           err_str, vfs_func);
+               return error;
+       }
 
-               DBG_ERR("Unknown error inject %s requested "
-                       "for vfs function %s\n", err_str, vfs_func);
+       if (strequal(err_str, "panic")) {
+               DBG_ERR("Panic in VFS function %s\n", vfs_func);
+               smb_panic("error_inject");
        }
 
+       DBG_ERR("Unknown error inject %s requested "
+               "for vfs function %s\n", err_str, vfs_func);
+
        return 0;
 }