r23486: Ok, this time with a hopefully successful make test in the right place:
authorVolker Lendecke <vlendec@samba.org>
Thu, 14 Jun 2007 12:03:46 +0000 (12:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:21 +0000 (12:23 -0500)
Remove two local variables

source/locking/locking.c
source/smbd/reply.c

index 47566e0393e92b320428494b9dd527e82baaf0bd..8070f4b9b36c31cfa0ee6eb7c929493236d3f34b 100644 (file)
@@ -844,10 +844,6 @@ BOOL rename_share_filename(struct messaging_context *msg_ctx,
        char *frm = NULL;
        int i;
 
-       if (!lck) {
-               return False;
-       }
-
        DEBUG(10, ("rename_share_filename: servicepath %s newname %s\n",
                servicepath, newname));
 
index 272c3966ba3f468de865c2b9a8b5037d435b0389..45c4b1d1dfb4f3fe3fe927feae396cf9fe0c9e05 100644 (file)
@@ -4168,13 +4168,15 @@ static BOOL resolve_wildcards(const char *name1, char *name2)
  asynchronously.
 ****************************************************************************/
 
-static void rename_open_files(connection_struct *conn, struct share_mode_lock *lck,
-                             struct file_id id, const char *newname)
+static void rename_open_files(connection_struct *conn,
+                             struct share_mode_lock *lck,
+                             const char *newname)
 {
        files_struct *fsp;
        BOOL did_rename = False;
 
-       for(fsp = file_find_di_first(id); fsp; fsp = file_find_di_next(fsp)) {
+       for(fsp = file_find_di_first(lck->id); fsp;
+           fsp = file_find_di_next(fsp)) {
                /* fsp_name is a relative path under the fsp. To change this for other
                   sharepaths we need to manipulate relative paths. */
                /* TODO - create the absolute path and manipulate the newname
@@ -4191,7 +4193,7 @@ static void rename_open_files(connection_struct *conn, struct share_mode_lock *l
 
        if (!did_rename) {
                DEBUG(10,("rename_open_files: no open files on file_id %s for %s\n",
-                         file_id_static_string(&id), newname ));
+                         file_id_static_string(&lck->id), newname ));
        }
 
        /* Send messages to all smbd's (not ourself) that the name has changed. */
@@ -4237,7 +4239,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstrin
        SMB_STRUCT_STAT sbuf;
        pstring newname_last_component;
        NTSTATUS status = NT_STATUS_OK;
-       BOOL dest_exists;
        struct share_mode_lock *lck = NULL;
 
        ZERO_STRUCT(sbuf);
@@ -4306,9 +4307,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstrin
                return NT_STATUS_OK;
        }
 
-       dest_exists = vfs_object_exist(conn,newname,NULL);
-
-       if(!replace_if_exists && dest_exists) {
+       if(!replace_if_exists && vfs_object_exist(conn, newname, NULL)) {
                DEBUG(3,("rename_internals_fsp: dest exists doing rename %s -> %s\n",
                        fsp->fsp_name,newname));
                return NT_STATUS_OBJECT_NAME_COLLISION;
@@ -4341,13 +4340,20 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstrin
 
        lck = get_share_mode_lock(NULL, fsp->file_id, NULL, NULL);
 
+       /*
+        * We have the file open ourselves, so not being able to get the
+        * corresponding share mode lock is a fatal error.
+        */
+
+       SMB_ASSERT(lck != NULL);
+
        if(SMB_VFS_RENAME(conn,fsp->fsp_name, newname) == 0) {
                uint32 create_options = fsp->fh->private_options;
 
                DEBUG(3,("rename_internals_fsp: succeeded doing rename on %s -> %s\n",
                        fsp->fsp_name,newname));
 
-               rename_open_files(conn, lck, fsp->file_id, newname);
+               rename_open_files(conn, lck, newname);
 
                /*
                 * A rename acts as a new file create w.r.t. allowing an initial delete
@@ -4455,7 +4461,6 @@ NTSTATUS rename_internals(connection_struct *conn,
        const char *dname;
        long offset = 0;
        pstring destname;
-       struct file_id id;
 
        *directory = *mask = 0;
 
@@ -4605,8 +4610,6 @@ NTSTATUS rename_internals(connection_struct *conn,
                 * don't do the rename, just return success.
                 */
 
-               id = file_id_sbuf(&sbuf1);
-
                if (strcsequal(directory, newname)) {
                        DEBUG(3, ("rename_internals: identical names in "
                                  "rename %s - returning success\n",
@@ -4624,12 +4627,19 @@ NTSTATUS rename_internals(connection_struct *conn,
                        return NT_STATUS_SHARING_VIOLATION;
                }
 
-               lck = get_share_mode_lock(NULL, id, NULL, NULL);
+               lck = get_share_mode_lock(NULL, file_id_sbuf(&sbuf1),
+                                         NULL, NULL);
 
                if(SMB_VFS_RENAME(conn,directory, newname) == 0) {
                        DEBUG(3,("rename_internals: succeeded doing rename "
                                 "on %s -> %s\n", directory, newname));
-                       rename_open_files(conn, lck, id, newname);
+                       if (lck != NULL) {
+                               /*
+                                * Only in this case there are open files at
+                                * all.
+                                */
+                               rename_open_files(conn, lck, newname);
+                       }
                        TALLOC_FREE(lck);
                        notify_rename(conn, S_ISDIR(sbuf1.st_mode),
                                      directory, newname);
@@ -4740,8 +4750,6 @@ NTSTATUS rename_internals(connection_struct *conn,
                        return status;
                }
 
-               id = file_id_sbuf(&sbuf1);
-
                if (strcsequal(fname,destname)) {
                        DEBUG(3,("rename_internals: identical names "
                                 "in wildcard rename %s - success\n",
@@ -4761,10 +4769,17 @@ NTSTATUS rename_internals(connection_struct *conn,
                        return NT_STATUS_SHARING_VIOLATION;
                }
 
-               lck = get_share_mode_lock(NULL, id, NULL, NULL);
+               lck = get_share_mode_lock(NULL, file_id_sbuf(&sbuf1), NULL,
+                                         NULL);
 
                if (!SMB_VFS_RENAME(conn,fname,destname)) {
-                       rename_open_files(conn, lck, id, newname);
+                       if (lck != NULL) {
+                               /*
+                                * Only in this case there are open files at
+                                * all.
+                                */
+                               rename_open_files(conn, lck, newname);
+                       }
                        count++;
                        status = NT_STATUS_OK;
                }