]> wimlib.net Git - wimlib/commitdiff
wim_recalculate_refcnts(): Check for error
authorEric Biggers <ebiggers3@gmail.com>
Fri, 13 Dec 2013 16:11:28 +0000 (10:11 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 13 Dec 2013 16:11:28 +0000 (10:11 -0600)
include/wimlib/wim.h
src/verify.c
src/wim.c

index e972950cf720b563013ba78721c337944b29c0a5..ee270ed35b231f26e383bd2bae2e05fe52cfef69 100644 (file)
@@ -102,7 +102,7 @@ static inline bool wim_has_metadata(const WIMStruct *wim)
        return (wim->image_metadata != NULL || wim->hdr.image_count == 0);
 }
 
-extern void
+extern int
 wim_recalculate_refcnts(WIMStruct *wim);
 
 extern u32
index 10db163550dfe8cea3381ec7936a2d9a768ff376..a9de114642138b6aa1bbcb2c9b1f8b012c0366e6 100644 (file)
@@ -151,13 +151,16 @@ tally_image_refcnts(WIMStruct *wim)
  * problem by looking at ALL the images to re-calculate the reference count of
  * EVERY lookup table entry.  This only absolutely has to be done before an image
  * is deleted or before an image is mounted read-write. */
-void
+int
 wim_recalculate_refcnts(WIMStruct *wim)
 {
        unsigned long num_ltes_with_bogus_refcnt = 0;
+       int ret;
 
        for_lookup_table_entry(wim->lookup_table, lte_zero_real_refcnt, NULL);
-       for_image(wim, WIMLIB_ALL_IMAGES, tally_image_refcnts);
+       ret = for_image(wim, WIMLIB_ALL_IMAGES, tally_image_refcnts);
+       if (ret)
+               return ret;
        num_ltes_with_bogus_refcnt = 0;
        for_lookup_table_entry(wim->lookup_table, lte_fix_refcnt,
                               &num_ltes_with_bogus_refcnt);
@@ -168,4 +171,5 @@ wim_recalculate_refcnts(WIMStruct *wim)
                        num_ltes_with_bogus_refcnt);
        }
        wim->refcnts_ok = 1;
+       return 0;
 }
index 60e29b48ee7536fe5c5947e05628cf6f7ce6062c..2f5f5e0e8e27d534c49db96b8af3fad442f9a9f4 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -887,8 +887,11 @@ can_delete_from_wim(WIMStruct *wim)
        ret = can_modify_wim(wim);
        if (ret)
                return ret;
-       if (!wim->refcnts_ok)
-               wim_recalculate_refcnts(wim);
+       if (!wim->refcnts_ok) {
+               ret = wim_recalculate_refcnts(wim);
+               if (ret)
+                       return ret;
+       }
        return 0;
 }