s3:locking: no need to make a file_id passed by value a constant
authorGregor Beck <gbeck@sernet.de>
Tue, 12 Mar 2013 14:10:51 +0000 (15:10 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 18 Apr 2013 11:15:13 +0000 (13:15 +0200)
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/locking/proto.h
source3/locking/share_mode_lock.c

index 69c78e3233fb19c30a59729687fe7cef4fc90ac1..1d8eb73ebd0b576b1b77c2c819fe3508f8d63d17 100644 (file)
@@ -150,15 +150,15 @@ bool locking_init_readonly(void);
 bool locking_end(void);
 char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
 struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
-                                                    const struct file_id id);
+                                                    struct file_id id);
 struct share_mode_lock *get_share_mode_lock(
        TALLOC_CTX *mem_ctx,
-       const struct file_id id,
+       struct file_id id,
        const char *servicepath,
        const struct smb_filename *smb_fname,
        const struct timespec *old_write_time);
 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
-                                                 const struct file_id id);
+                                                 struct file_id id);
 bool rename_share_filename(struct messaging_context *msg_ctx,
                        struct share_mode_lock *lck,
                        const char *servicepath,
index 4f26099f6043893ab0d237bf9209f82575977dfe..2d7ca39fc78c485680b3865cd3db4ab4ce2be5ed 100644 (file)
@@ -104,10 +104,9 @@ bool locking_end(void)
  Form a static locking key for a dev/inode pair.
 ******************************************************************/
 
-static TDB_DATA locking_key(const struct file_id *id, struct file_id *tmp)
+static TDB_DATA locking_key(const struct file_id *id)
 {
-       *tmp = *id;
-       return make_tdb_data((const uint8_t *)tmp, sizeof(*tmp));
+       return make_tdb_data((const uint8_t *)id, sizeof(*id));
 }
 
 /*******************************************************************
@@ -286,15 +285,14 @@ fail:
 ********************************************************************/
 
 static struct share_mode_lock *get_share_mode_lock_internal(
-       TALLOC_CTX *mem_ctx, const struct file_id id,
+       TALLOC_CTX *mem_ctx, struct file_id id,
        const char *servicepath, const struct smb_filename *smb_fname,
        const struct timespec *old_write_time)
 {
        struct share_mode_lock *lck;
        struct share_mode_data *d;
-       struct file_id tmp;
        struct db_record *rec;
-       TDB_DATA key = locking_key(&id, &tmp);
+       TDB_DATA key = locking_key(&id);
        TDB_DATA value;
 
        rec = dbwrap_fetch_locked(lock_db, mem_ctx, key);
@@ -351,7 +349,7 @@ static int the_lock_destructor(struct share_mode_lock *l)
 
 struct share_mode_lock *get_share_mode_lock(
        TALLOC_CTX *mem_ctx,
-       const struct file_id id,
+       struct file_id id,
        const char *servicepath,
        const struct smb_filename *smb_fname,
        const struct timespec *old_write_time)
@@ -404,11 +402,10 @@ static void fetch_share_mode_unlocked_parser(
 ********************************************************************/
 
 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
-                                                 const struct file_id id)
+                                                 struct file_id id)
 {
        struct share_mode_lock *lck;
-       struct file_id tmp;
-       TDB_DATA key = locking_key(&id, &tmp);
+       TDB_DATA key = locking_key(&id);
        NTSTATUS status;
 
        lck = talloc(mem_ctx, struct share_mode_lock);