prepare-root: Check for empty string, not strlen > 0
authorColin Walters <walters@verbum.org>
Mon, 14 Aug 2023 18:30:42 +0000 (14:30 -0400)
committerColin Walters <walters@verbum.org>
Mon, 14 Aug 2023 18:30:42 +0000 (14:30 -0400)
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.

src/switchroot/ostree-prepare-root.c

index 39f8c5006ac26f90a05ea056f8ea80957b668493..2e4f66a4cbb947816ef1059f8c1156718c89a845 100644 (file)
@@ -332,13 +332,13 @@ load_composefs_config (GKeyFile *config, GError **error)
           for (char **iter = lines; *iter; iter++)
             {
               const char *line = *iter;
-              if (strlen (line) > 0)
-                {
-                  gsize pubkey_size;
-                  g_autofree guchar *pubkey = g_base64_decode (line, &pubkey_size);
-                  ret->pubkeys = g_list_append (
-                      ret->pubkeys, g_bytes_new_take (g_steal_pointer (&pubkey), pubkey_size));
-                }
+              if (!*line)
+                continue;
+
+              gsize pubkey_size;
+              g_autofree guchar *pubkey = g_base64_decode (line, &pubkey_size);
+              ret->pubkeys = g_list_append (
+                  ret->pubkeys, g_bytes_new_take (g_steal_pointer (&pubkey), pubkey_size));
             }
         }