Skip to content

Commit 10e5208

Browse files
committed
Address PR 254 review comments on Cache_open
- Explicitly check if Data_size() returns a stat failure (-1) to distinguish it from cache metadata size mismatch. - Avoid multi-line backslash string continuation in lprintf by using string literal concatenation instead.
1 parent dbcb853 commit 10e5208

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/cache.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,13 @@ Cache *Cache_open(const char *fn)
840840
ok = 0;
841841
} else {
842842
off_t d_size = Data_size(actual_fn);
843-
if (cf->content_length > d_size) {
844-
lprintf(error, "metadata inconsistency %s, \
845-
cf->content_length: %jd, Data_size(fn): %jd.\n",
843+
if (d_size < 0) {
844+
lprintf(error, "cannot stat data file %s.\n", actual_fn);
845+
ok = 0;
846+
} else if (cf->content_length > d_size) {
847+
lprintf(error,
848+
"metadata inconsistency %s, "
849+
"cf->content_length: %jd, Data_size(fn): %jd.\n",
846850
actual_fn, (intmax_t)cf->content_length,
847851
(intmax_t)d_size);
848852
ok = 0;

0 commit comments

Comments
 (0)