]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
sha1-ssse3.asm: Fix building on Windows
[wimlib] / src / dentry.c
index c8d5734d17f3e1fe99eb13bc725da9eaea3f46b4..68a5d925627a5ae925c2d0db40898657b4fdd80c 100644 (file)
@@ -197,9 +197,9 @@ dentry_min_len_with_names(u16 file_name_nbytes, u16 short_name_nbytes)
 {
        u64 length = sizeof(struct wim_dentry_on_disk);
        if (file_name_nbytes)
-               length += file_name_nbytes + 2;
+               length += (u32)file_name_nbytes + 2;
        if (short_name_nbytes)
-               length += short_name_nbytes + 2;
+               length += (u32)short_name_nbytes + 2;
        return length;
 }
 
@@ -266,7 +266,7 @@ ads_entry_total_length(const struct wim_ads_entry *entry)
 {
        u64 len = sizeof(struct wim_ads_entry_on_disk);
        if (entry->stream_name_nbytes)
-               len += entry->stream_name_nbytes + 2;
+               len += (u32)entry->stream_name_nbytes + 2;
        return (len + 7) & ~7;
 }
 
@@ -430,7 +430,6 @@ dentry_full_path(struct wim_dentry *dentry)
 static int
 dentry_calculate_subdir_offset(struct wim_dentry *dentry, void *_subdir_offset_p)
 {
-
        if (dentry_is_directory(dentry)) {
                u64 *subdir_offset_p = _subdir_offset_p;
                struct wim_dentry *child;
@@ -1209,7 +1208,7 @@ read_dentry(const u8 * restrict buf, size_t buf_len,
                        goto err_free_dentry;
                }
                dentry->file_name_nbytes = file_name_nbytes;
-               p += file_name_nbytes + 2;
+               p += (u32)file_name_nbytes + 2;
        }
 
        /* Read the short filename if present.  Note: if there is no short
@@ -1222,7 +1221,7 @@ read_dentry(const u8 * restrict buf, size_t buf_len,
                        goto err_free_dentry;
                }
                dentry->short_name_nbytes = short_name_nbytes;
-               p += short_name_nbytes + 2;
+               p += (u32)short_name_nbytes + 2;
        }
 
        /* Read extra data at end of dentry (but before alternate data stream
@@ -1406,12 +1405,7 @@ read_dentry_tree(const u8 *buf, size_t buf_len,
                {
                        WARNING("The root directory has a nonempty name; "
                                "removing it.");
-                       FREE(root->file_name);
-                       FREE(root->short_name);
-                       root->file_name = NULL;
-                       root->short_name = NULL;
-                       root->file_name_nbytes = 0;
-                       root->short_name_nbytes = 0;
+                       dentry_set_name(root, NULL);
                }
 
                if (unlikely(!dentry_is_directory(root))) {
@@ -1460,7 +1454,7 @@ write_ads_entry(const struct wim_ads_entry *ads_entry,
        p += sizeof(struct wim_ads_entry_on_disk);
        if (ads_entry->stream_name_nbytes) {
                p = mempcpy(p, ads_entry->stream_name,
-                           ads_entry->stream_name_nbytes + 2);
+                           (u32)ads_entry->stream_name_nbytes + 2);
        }
        /* Align to 8-byte boundary */
        while ((uintptr_t)p & 7)
@@ -1533,10 +1527,10 @@ write_dentry(const struct wim_dentry * restrict dentry, u8 * restrict p)
        wimlib_assert(dentry_is_root(dentry) != dentry_has_long_name(dentry));
 
        if (dentry_has_long_name(dentry))
-               p = mempcpy(p, dentry->file_name, dentry->file_name_nbytes + 2);
+               p = mempcpy(p, dentry->file_name, (u32)dentry->file_name_nbytes + 2);
 
        if (dentry_has_short_name(dentry))
-               p = mempcpy(p, dentry->short_name, dentry->short_name_nbytes + 2);
+               p = mempcpy(p, dentry->short_name, (u32)dentry->short_name_nbytes + 2);
 
        /* Align to 8-byte boundary */
        while ((uintptr_t)p & 7)