From: Eric Biggers Date: Fri, 13 Dec 2013 16:11:28 +0000 (-0600) Subject: wim_recalculate_refcnts(): Check for error X-Git-Tag: v1.6.0~156 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=1c19875f1bcbfe341014b20b9bbbc9b5fa0cea4d wim_recalculate_refcnts(): Check for error --- diff --git a/include/wimlib/wim.h b/include/wimlib/wim.h index e972950c..ee270ed3 100644 --- a/include/wimlib/wim.h +++ b/include/wimlib/wim.h @@ -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 diff --git a/src/verify.c b/src/verify.c index 10db1635..a9de1146 100644 --- a/src/verify.c +++ b/src/verify.c @@ -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; } diff --git a/src/wim.c b/src/wim.c index 60e29b48..2f5f5e0e 100644 --- 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; }