Cleanup v1.2.4
authorEric Biggers <ebiggers3@gmail.com>
Tue, 5 Feb 2013 21:32:52 +0000 (15:32 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 5 Feb 2013 21:32:52 +0000 (15:32 -0600)
src/decompress.c
src/lzx-decompress.c
src/ntfs-apply.c
src/ntfs-capture.c

index c5e739110783e5f3921c83e3e14a6f19af649a82..bed7b5a486876c3d056f4888f20cd9e0cb031823 100644 (file)
@@ -245,7 +245,6 @@ int make_huffman_decode_table(u16 decode_table[],  unsigned num_syms,
                unsigned sym = sorted_syms[i];
                unsigned codeword_len = lens[sym];
                unsigned extra_bits = codeword_len - table_bits;
                unsigned sym = sorted_syms[i];
                unsigned codeword_len = lens[sym];
                unsigned extra_bits = codeword_len - table_bits;
-               unsigned extra_mask;
 
                cur_codeword <<= (codeword_len - prev_codeword_len);
                prev_codeword_len = codeword_len;
 
                cur_codeword <<= (codeword_len - prev_codeword_len);
                prev_codeword_len = codeword_len;
index 2b3c0f903149f73965fadfb47dd3457d1d057b70..13b00761eff664eaf4b68b6350c35620c9d12c4e 100644 (file)
@@ -318,7 +318,6 @@ static int lzx_read_block_header(struct input_bitstream *istream,
        unsigned s;
        unsigned i;
        unsigned len;
        unsigned s;
        unsigned i;
        unsigned len;
-       u32 R[3];
 
        ret = bitstream_ensure_bits(istream, 4);
        if (ret != 0) {
 
        ret = bitstream_ensure_bits(istream, 4);
        if (ret != 0) {
index fc1a354d595ee164d503e7a3ae9939b6dcd075ff..31b84239d00db6c8621678f2be18ca45a78d9708 100644 (file)
@@ -198,26 +198,20 @@ static ntfs_inode *dentry_open_parent_ni(const struct wim_dentry *dentry,
  * existing NTFS inode which already has a name @inode->i_extracted_file.
  *
  * The new name is made in the POSIX namespace (this is the behavior of
  * existing NTFS inode which already has a name @inode->i_extracted_file.
  *
  * The new name is made in the POSIX namespace (this is the behavior of
- * ntfs_link()).  I am assuming this is an acceptable behavior; however, it's
- * possible that the original name was actually in the Win32 namespace.  Note
- * that the WIM format does not provide enough information to distinguish Win32
- * names from POSIX names in all cases.
+ * ntfs_link()).
  *
  *
- * Return 0 on success, nonzero on failure.
+ * Return 0 on success, nonzero on failure.  dir_ni is closed either way.
  */
 static int apply_ntfs_hardlink(const struct wim_dentry *from_dentry,
                               const struct wim_inode *inode,
  */
 static int apply_ntfs_hardlink(const struct wim_dentry *from_dentry,
                               const struct wim_inode *inode,
-                              ntfs_inode **dir_ni_p)
+                              ntfs_inode *dir_ni)
 {
        int ret;
        ntfs_inode *to_ni;
 {
        int ret;
        ntfs_inode *to_ni;
-       ntfs_inode *dir_ni;
        ntfs_volume *vol;
 
        ntfs_volume *vol;
 
-       dir_ni = *dir_ni_p;
        vol = dir_ni->vol;
        ret = ntfs_inode_close(dir_ni);
        vol = dir_ni->vol;
        ret = ntfs_inode_close(dir_ni);
-       *dir_ni_p = NULL;
        if (ret != 0) {
                ERROR_WITH_ERRNO("Error closing directory");
                return WIMLIB_ERR_NTFS_3G;
        if (ret != 0) {
                ERROR_WITH_ERRNO("Error closing directory");
                return WIMLIB_ERR_NTFS_3G;
@@ -245,10 +239,9 @@ static int apply_ntfs_hardlink(const struct wim_dentry *from_dentry,
        ret |= ntfs_inode_close(dir_ni);
        ret |= ntfs_inode_close(to_ni);
        if (ret) {
        ret |= ntfs_inode_close(dir_ni);
        ret |= ntfs_inode_close(to_ni);
        if (ret) {
-               ERROR_WITH_ERRNO("Could not create hard link `%s' => `%s' (ret=%d)",
+               ERROR_WITH_ERRNO("Could not create hard link `%s' => `%s'",
                                 from_dentry->full_path_utf8,
                                 from_dentry->full_path_utf8,
-                                inode->i_extracted_file,
-                                ret);
+                                inode->i_extracted_file);
                ret = WIMLIB_ERR_NTFS_3G;
        }
        return ret;
                ret = WIMLIB_ERR_NTFS_3G;
        }
        return ret;
@@ -390,9 +383,9 @@ static int do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *dir_ni,
                                /* Already extracted another dentry in the hard
                                 * link group.  Make a hard link instead of
                                 * extracting the file data. */
                                /* Already extracted another dentry in the hard
                                 * link group.  Make a hard link instead of
                                 * extracting the file data. */
-                               ret = apply_ntfs_hardlink(dentry, inode,
-                                                         &dir_ni);
-                               goto out_close_dir_ni;
+                               ret = apply_ntfs_hardlink(dentry, inode, dir_ni);
+                               /* dir_ni was closed */
+                               goto out;
                        } else {
                                /* None of the dentries of this inode have been
                                 * extracted yet, so go ahead and extract the
                        } else {
                                /* None of the dentries of this inode have been
                                 * extracted yet, so go ahead and extract the
index ff8c3a9b68b8bb20cf21f6a2aa72156abdb181e5..dcff1fe4e720f31bf4590e13c7cf604a5afbac9d 100644 (file)
 #include <errno.h>
 #include "rbtree.h"
 
 #include <errno.h>
 #include "rbtree.h"
 
-/* Structure that allows searching the security descriptors by SHA1 message
- * digest. */
+/* Red-black tree that maps SHA1 message digests of security descriptors to
+ * security IDs, which are themselves indices into the table of security
+ * descriptors in the 'struct wim_security_data'. */
 struct sd_set {
        struct wim_security_data *sd;
        struct rb_root rb_root;
 };
 
 struct sd_set {
        struct wim_security_data *sd;
        struct rb_root rb_root;
 };
 
-/* Binary tree node of security descriptors, indexed by the @hash field. */
 struct sd_node {
        int security_id;
        u8 hash[SHA1_HASH_SIZE];
 struct sd_node {
        int security_id;
        u8 hash[SHA1_HASH_SIZE];
@@ -489,19 +489,18 @@ static int set_dentry_dos_name(struct wim_dentry *dentry, void *arg)
        if (dentry->is_win32_name) {
                node = lookup_dos_name(map, dentry->d_inode->i_ino);
                if (node) {
        if (dentry->is_win32_name) {
                node = lookup_dos_name(map, dentry->d_inode->i_ino);
                if (node) {
-                       dentry->short_name = MALLOC(node->name_len_bytes + 2);
+                       dentry->short_name = MALLOC(node->name_len_bytes);
                        if (!dentry->short_name)
                                return WIMLIB_ERR_NOMEM;
                        memcpy(dentry->short_name, node->dos_name,
                               node->name_len_bytes);
                        if (!dentry->short_name)
                                return WIMLIB_ERR_NOMEM;
                        memcpy(dentry->short_name, node->dos_name,
                               node->name_len_bytes);
-                       *(u16*)&dentry->short_name[node->name_len_bytes] = 0;
                        dentry->short_name_len = node->name_len_bytes;
                        DEBUG("Assigned DOS name to ino %"PRIu64,
                              dentry->d_inode->i_ino);
                } else {
                        dentry->short_name_len = node->name_len_bytes;
                        DEBUG("Assigned DOS name to ino %"PRIu64,
                              dentry->d_inode->i_ino);
                } else {
-                       DEBUG("ino %"PRIu64" has Win32 name with no "
-                             "corresponding DOS name",
-                             dentry->d_inode->i_ino);
+                       WARNING("NTFS inode %"PRIu64" has Win32 name with no "
+                               "corresponding DOS name",
+                               dentry->d_inode->i_ino);
                }
        }
        return 0;
                }
        }
        return 0;
@@ -559,14 +558,14 @@ static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
 
        ctx = dirent;
        if (name_type & FILE_NAME_DOS) {
 
        ctx = dirent;
        if (name_type & FILE_NAME_DOS) {
-               /* Special case: If this is the entry for a DOS name, store it
-                * for later. */
+               /* If this is the entry for a DOS name, store it for later. */
                ret = insert_dos_name(ctx->dos_name_map, name,
                                      name_len, mref & MFT_REF_MASK_CPU);
                ret = insert_dos_name(ctx->dos_name_map, name,
                                      name_len, mref & MFT_REF_MASK_CPU);
-               if (ret != 0)
+
+               /* Return now if an error occurred or if this is just a DOS name
+                * and not a Win32+DOS name. */
+               if (ret != 0 || name_type == FILE_NAME_DOS)
                        return ret;
                        return ret;
-               if (name_type == FILE_NAME_DOS) /* DOS only, not Win32 + DOS */
-                       return 0;
        }
        ret = utf16_to_utf8((const char*)name, name_len * 2,
                            &utf8_name, &utf8_name_len);
        }
        ret = utf16_to_utf8((const char*)name, name_len * 2,
                            &utf8_name, &utf8_name_len);