}
fclose(f);
+ f = NULL;
if (len > pattern_len) {
len -= pattern_len;
error:
qemu_io_free(buf_origin);
+ if (f) {
+ fclose(f);
+ }
return NULL;
}
return offset;
}
- ret = blk_truncate(blk, offset, PREALLOC_MODE_OFF, &local_err);
+ /*
+ * qemu-io is a debugging tool, so let us be strict here and pass
+ * exact=true. It is better to err on the "emit more errors" side
+ * than to be overly permissive.
+ */
+ ret = blk_truncate(blk, offset, false, PREALLOC_MODE_OFF, 0, &local_err);
if (ret < 0) {
error_report_err(local_err);
return ret;
static void help_oneline(const char *cmd, const cmdinfo_t *ct)
{
- if (cmd) {
- printf("%s ", cmd);
- } else {
- printf("%s ", ct->name);
- if (ct->altname) {
- printf("(or %s) ", ct->altname);
- }
- }
+ printf("%s ", cmd);
if (ct->args) {
printf("%s ", ct->args);
{
const cmdinfo_t *ct;
- if (argc == 1) {
+ if (argc < 2) {
help_all();
return 0;
}