Fix some cppcheck warnings.

Despite it is nonsense and cppcheck should understand the code better :-)
This commit is contained in:
Milan Broz
2018-12-04 12:30:14 +01:00
parent 9cbd36163c
commit 3ea8e01a9d
3 changed files with 9 additions and 3 deletions

View File

@@ -1222,7 +1222,8 @@ int LUKS2_config_get_flags(struct crypt_device *cd, struct luks2_hdr *hdr, uint3
for (i = 0; i < (int) json_object_array_length(jobj_flags); i++) { for (i = 0; i < (int) json_object_array_length(jobj_flags); i++) {
jobj1 = json_object_array_get_idx(jobj_flags, i); jobj1 = json_object_array_get_idx(jobj_flags, i);
for (j = 0, found = 0; persistent_flags[j].description && !found; j++) found = 0;
for (j = 0; persistent_flags[j].description && !found; j++)
if (!strcmp(persistent_flags[j].description, if (!strcmp(persistent_flags[j].description,
json_object_get_string(jobj1))) { json_object_get_string(jobj1))) {
*flags |= persistent_flags[j].flag; *flags |= persistent_flags[j].flag;

View File

@@ -226,7 +226,8 @@ int VERITY_UUID_generate(struct crypt_device *cd, char **uuid_string)
{ {
uuid_t uuid; uuid_t uuid;
if (!(*uuid_string = malloc(40))) *uuid_string = malloc(40);
if (!*uuid_string)
return -ENOMEM; return -ENOMEM;
uuid_generate(uuid); uuid_generate(uuid);
uuid_unparse(uuid, *uuid_string); uuid_unparse(uuid, *uuid_string);

View File

@@ -303,7 +303,11 @@ static int create_empty_header(const char *new_file, const char *old_file,
log_dbg("Creating empty file %s of size %lu.", new_file, (unsigned long)size); log_dbg("Creating empty file %s of size %lu.", new_file, (unsigned long)size);
if (!size || !(buf = malloc(size))) if (!size)
return -EINVAL;
buf = malloc(size);
if (!buf)
return -ENOMEM; return -ENOMEM;
memset(buf, 0, size); memset(buf, 0, size);