Fix some scan build warnings for api-test-2.

This commit is contained in:
Milan Broz
2022-04-27 20:02:28 +02:00
parent ae3ce2a207
commit a25d10407d
2 changed files with 7 additions and 4 deletions

View File

@@ -199,6 +199,11 @@ static int get_luks2_offsets(int metadata_device,
struct crypt_device *cd = NULL;
static uint64_t default_header_size = 0;
if (r_header_size)
*r_header_size = 0;
if (r_payload_offset)
*r_payload_offset = 0;
if (!default_header_size) {
if (crypt_init(&cd, THE_LOOP_DEV))
return -EINVAL;
@@ -966,8 +971,7 @@ static void AddDeviceLuks2(void)
OK_(!(global_lines != 0));
reset_log();
OK_(crypt_dump_json(cd, &tmp_buf, 0));
OK_(!tmp_buf);
OK_(!(strlen(tmp_buf) != 0));
OK_(!(tmp_buf && strlen(tmp_buf) != 0));
FAIL_(crypt_set_uuid(cd, "blah"), "wrong UUID format");
OK_(crypt_set_uuid(cd, DEVICE_TEST_UUID));

View File

@@ -214,7 +214,6 @@ int get_key_dm(const char *name, char *buffer, unsigned int buffer_size)
struct dm_info dmi;
uint64_t start, length;
char *target_type, *key, *params;
void *next = NULL;
int r = -EINVAL;
if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
@@ -228,7 +227,7 @@ int get_key_dm(const char *name, char *buffer, unsigned int buffer_size)
if (!dmi.exists)
goto out;
next = dm_get_next_target(dmt, next, &start, &length, &target_type, &params);
dm_get_next_target(dmt, NULL, &start, &length, &target_type, &params);
if (!target_type || strcmp(target_type, "crypt") != 0)
goto out;