]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify mkdir_internal()
authorVolker Lendecke <vl@samba.org>
Wed, 17 Sep 2025 13:49:49 +0000 (06:49 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
Save a few lines by moving the NULL check out of the if-branches. Swap
branches to avoid a ! in the condition, makes it easier to read for me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index e62206c71e6da937221392699099ede445a86155..b423fd9fb0cbefd3045068915995619bf81fc296 100644 (file)
@@ -4587,21 +4587,17 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                return NT_STATUS_NO_MEMORY;
        }
        SMB_ASSERT(smbd_is_tmpname(tmp_atname->base_name, NULL));
-       if (!ISDOT(parent_dir_fname->base_name)) {
+       if (ISDOT(parent_dir_fname->base_name)) {
+               tmp_dname = talloc_strdup(frame, tmp_atname->base_name);
+       } else {
                tmp_dname = talloc_asprintf(frame,
                                            "%s/%s",
                                            parent_dir_fname->base_name,
                                            tmp_atname->base_name);
-               if (tmp_dname == NULL) {
-                       TALLOC_FREE(frame);
-                       return NT_STATUS_NO_MEMORY;
-               }
-       } else {
-               tmp_dname = talloc_strdup(frame, tmp_atname->base_name);
-               if (tmp_dname == NULL) {
-                       TALLOC_FREE(frame);
-                       return NT_STATUS_NO_MEMORY;
-               }
+       }
+       if (tmp_dname == NULL) {
+               TALLOC_FREE(frame);
+               return NT_STATUS_NO_MEMORY;
        }
 
        smb_dname->base_name = tmp_dname;