Keep in sync with protocol if idev data on stream but no hlink_pool.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 415de19..51584f2 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -81,7 +81,7 @@ void init_flist(void)
        struct file_struct f;
 
        /* Figure out how big the file_struct is without trailing padding */
-       file_struct_len = ((char*)&f.flags - (char*)&f) + sizeof f.flags;
+       file_struct_len = offsetof(struct file_struct, flags) + sizeof f.flags;
 }
 
 
@@ -659,10 +659,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags,
 #if SUPPORT_HARD_LINKS
        if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode))
                flags |= XMIT_HAS_IDEV_DATA;
-       if (flags & XMIT_HAS_IDEV_DATA && flist->hlink_pool) {
+       if (flags & XMIT_HAS_IDEV_DATA) {
                INO64_T inode;
-               file->link_u.idev = pool_talloc(flist->hlink_pool,
-                   struct idev, 1, "inode_table");
                if (protocol_version < 26) {
                        dev = read_int(f);
                        inode = read_int(f);
@@ -672,6 +670,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags,
                        inode = read_longint(f);
                }
                if (flist->hlink_pool) {
+                       file->link_u.idev = pool_talloc(flist->hlink_pool,
+                           struct idev, 1, "inode_table");
                        file->F_INODE = inode;
                        file->F_DEV = dev;
                }
@@ -1175,8 +1175,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                        finish_filelist_progress(flist);
        }
 
-       if (flist->hlink_pool)
-       {
+       if (flist->hlink_pool) {
                pool_destroy(flist->hlink_pool);
                flist->hlink_pool = NULL;
        }