prepare-root: Check for empty string, not strlen > 0

No point in doing a full strlen, we can just check the first byte.
Also, invert the conditional using `continue` to avoid another
level of indentation.
This commit is contained in:
Colin Walters 2023-08-14 14:30:42 -04:00
parent bea5d897a8
commit 678bfcd934

View File

@ -332,15 +332,15 @@ load_composefs_config (GKeyFile *config, GError **error)
for (char **iter = lines; *iter; iter++) for (char **iter = lines; *iter; iter++)
{ {
const char *line = *iter; const char *line = *iter;
if (strlen (line) > 0) if (!*line)
{ continue;
gsize pubkey_size; gsize pubkey_size;
g_autofree guchar *pubkey = g_base64_decode (line, &pubkey_size); g_autofree guchar *pubkey = g_base64_decode (line, &pubkey_size);
ret->pubkeys = g_list_append ( ret->pubkeys = g_list_append (
ret->pubkeys, g_bytes_new_take (g_steal_pointer (&pubkey), pubkey_size)); ret->pubkeys, g_bytes_new_take (g_steal_pointer (&pubkey), pubkey_size));
} }
} }
}
if (ret->pubkeys == NULL) if (ret->pubkeys == NULL)
return glnx_null_throw (error, "public key file specified, but no public keys found"); return glnx_null_throw (error, "public key file specified, but no public keys found");