if (!dev_read_bytes(dev, mda_offset, mda_size, meta_buf)) {
log_print("CHECK: failed to read metadata area at offset %llu size %llu",
(unsigned long long)mda_offset, (unsigned long long)mda_size);
- free(meta_buf);
return 0;
}
if (!(fp = fopen(tofile, "wx"))) {
- log_error("Failed to create file %s.", tofile);
- free(meta_buf);
+ log_error("Failed to create file %s", tofile);
return 0;
}
- if (fwrite(meta_buf, mda_size - 512, 1, fp) < (mda_size - 512))
- log_warn("WARNING: Failed to write " FMTu64 " bytes to file %s.", mda_size - 512, tofile);
+ fwrite(meta_buf, mda_size - 512, 1, fp);
- free(meta_buf);
if (fflush(fp))
stack;
if (fclose(fp))
stack;
-
return 1;
}
* mda_offset + meta_offset.
*/
if (meta_offset + meta_size > mda_size) {
- /* text metadata wraps to start of text metadata area */
+ /* text metadata wraps to start of text metadata area */
uint32_t wrap = (uint32_t) ((meta_offset + meta_size) - mda_size);
off_t offset_a = mda_offset + meta_offset;
uint32_t size_a = meta_size - wrap;
log_print("CHECK: failed to read metadata text at mda_header_%d.raw_locn[%d].offset %llu size %llu part_a %llu %llu", mn, ri,
(unsigned long long)meta_offset, (unsigned long long)meta_size,
(unsigned long long)offset_a, (unsigned long long)size_a);
- free(meta_buf);
return 0;
}
log_print("CHECK: failed to read metadata text at mda_header_%d.raw_locn[%d].offset %llu size %llu part_b %llu %llu", mn, ri,
(unsigned long long)meta_offset, (unsigned long long)meta_size,
(unsigned long long)offset_b, (unsigned long long)size_b);
- free(meta_buf);
return 0;
}
} else {
if (!dev_read_bytes(dev, mda_offset + meta_offset, meta_size, meta_buf)) {
log_print("CHECK: failed to read metadata text at mda_header_%d.raw_locn[%d].offset %llu size %llu", mn, ri,
(unsigned long long)meta_offset, (unsigned long long)meta_size);
- free(meta_buf);
return 0;
}
}
}
out:
- free(meta_buf);
-
- return (!bad) ? 1 : 0;
+ if (bad)
+ return 0;
+ return 1;
}
static int _dump_label_and_pv_header(struct cmd_context *cmd, int print_fields,
if (!dev_read_bytes(dev, lh_offset, 512, buf)) {
log_print("CHECK: failed to read label_header at %llu",
(unsigned long long)lh_offset);
- free(buf);
return 0;
}
(unsigned long long)xlate64(dlocn->size));
}
- free(buf);
-
- return (!bad) ? 1 : 0;
+ if (bad)
+ return 0;
+ return 1;
}
/*
if (!dev_read_bytes(dev, mda_offset, 512, buf)) {
log_print("CHECK: failed to read mda_header at %llu", (unsigned long long)mda_offset);
- free(buf);
return 0;
}
/* Should we also check text metadata if it exists in rlocn1? */
out:
- free(buf);
-
- return (!bad) ? 1 : 0;
+ if (buf)
+ free(buf);
+ if (bad)
+ return 0;
+ return 1;
}
static int _dump_headers(struct cmd_context *cmd,