Check all snprintf calls for returning values for tests.

This commit is contained in:
Milan Broz
2022-02-24 15:24:06 +01:00
parent 677e06c48a
commit 12c35da768
4 changed files with 38 additions and 29 deletions

View File

@@ -196,9 +196,12 @@ int create_dmdevice_over_loop(const char *dm_name, const uint64_t size)
printf("No enough space on backing loop device\n.");
return -2;
}
snprintf(cmd, sizeof(cmd),
"dmsetup create %s --table \"0 %" PRIu64 " linear %s %" PRIu64 "\"",
dm_name, size, THE_LOOP_DEV, t_dev_offset);
r = snprintf(cmd, sizeof(cmd),
"dmsetup create %s --table \"0 %" PRIu64 " linear %s %" PRIu64 "\"",
dm_name, size, THE_LOOP_DEV, t_dev_offset);
if (r < 0 || (size_t)r >= sizeof(cmd))
return -3;
if (!(r = _system(cmd, 1)))
t_dev_offset += size;
return r;