]> wimlib.net Git - wimlib/blobdiff - src/inode.c
Close error file opened by name
[wimlib] / src / inode.c
index ae971d8343da5bc239aec20cbf9401546b27efc2..79adf36520da542ebc84bf588ec68ca0ece0882e 100644 (file)
@@ -547,9 +547,10 @@ stream_not_found_error(const struct wim_inode *inode, const u8 *hash)
 {
        if (wimlib_print_errors) {
                ERROR("\"%"TS"\": stream not found", inode_first_full_path(inode));
-               tfprintf(stderr, T("        SHA-1 message digest of missing stream:\n        "));
-               print_hash(hash, stderr);
-               tputc(T('\n'), stderr);
+               tfprintf(wimlib_error_file,
+                        T("        SHA-1 message digest of missing stream:\n        "));
+               print_hash(hash, wimlib_error_file);
+               tputc(T('\n'), wimlib_error_file);
        }
        return WIMLIB_ERR_RESOURCE_NOT_FOUND;
 }
@@ -564,8 +565,9 @@ stream_not_found_error(const struct wim_inode *inode, const u8 *hash)
  *     Inode to load the alternate data streams into.  @inode->i_num_ads must
  *     have been set to the number of alternate data streams that are expected.
  *
- * @remaining_size:
+ * @nbytes_remaining_p:
  *     Number of bytes of data remaining in the buffer pointed to by @p.
+ *     On success this will be updated to point just past the ADS entries.
  *
  * On success, inode->i_ads_entries is set to an array of `struct
  * wim_ads_entry's of length inode->i_num_ads.  On failure, @inode is not
@@ -578,8 +580,9 @@ stream_not_found_error(const struct wim_inode *inode, const u8 *hash)
  */
 int
 read_ads_entries(const u8 * restrict p, struct wim_inode * restrict inode,
-                size_t nbytes_remaining)
+                size_t *nbytes_remaining_p)
 {
+       size_t nbytes_remaining = *nbytes_remaining_p;
        u16 num_ads;
        struct wim_ads_entry *ads_entries;
        int ret;
@@ -661,7 +664,7 @@ read_ads_entries(const u8 * restrict p, struct wim_inode * restrict inode,
                 * that less than @length is actually remaining in the metadata
                 * resource. We should set the remaining bytes to 0 if this
                 * happens. */
-               length = (length + 7) & ~(u64)7;
+               length = (length + 7) & ~7;
                p += length;
                if (nbytes_remaining < length)
                        nbytes_remaining = 0;
@@ -670,6 +673,7 @@ read_ads_entries(const u8 * restrict p, struct wim_inode * restrict inode,
        }
        inode->i_ads_entries = ads_entries;
        inode->i_next_stream_id = inode->i_num_ads + 1;
+       *nbytes_remaining_p = nbytes_remaining;
        ret = 0;
        goto out;
 out_of_memory: