signing: Add #define OSTREE_SIGN_NAME_ED25519
authorColin Walters <walters@verbum.org>
Sun, 3 May 2020 17:04:27 +0000 (17:04 +0000)
committerColin Walters <walters@verbum.org>
Sun, 3 May 2020 17:04:27 +0000 (17:04 +0000)
Using `#define` or constants instead of strings helps avoid
typos and encourages documentation.

src/libostree/ostree-sign.c
src/libostree/ostree-sign.h
src/ostree/ot-builtin-commit.c
src/ostree/ot-builtin-sign.c
src/ostree/ot-builtin-summary.c

index 281fabc86ece5425507c6d570971fe51a7890ff0..68447da67049f0ad32932c1dd4daf4d046ba7b8e 100644 (file)
@@ -62,7 +62,7 @@ typedef struct
 _sign_type sign_types[] =
 {
 #if defined(HAVE_LIBSODIUM)
-    {"ed25519", 0},
+    {OSTREE_SIGN_NAME_ED25519, 0},
 #endif
     {"dummy", 0}
 };
index 678f182ddbe0deb3757d6a6d6031d4607cb91d55..da10469b08675965bb9114e75e8670d334d66baa 100644 (file)
@@ -49,6 +49,12 @@ static inline gboolean OSTREE_IS_SIGN (gpointer ptr) { return G_TYPE_CHECK_INSTA
 static inline OstreeSignInterface *OSTREE_SIGN_GET_IFACE (gpointer ptr) { return G_TYPE_INSTANCE_GET_INTERFACE (ptr, ostree_sign_get_type (), OstreeSignInterface); }
 G_GNUC_END_IGNORE_DEPRECATIONS
 
+/**
+ * OSTREE_SIGN_NAME_ED25519:
+ * The name of the default ed25519 signing type.
+ */
+#define OSTREE_SIGN_NAME_ED25519 "ed25519"
+
 /* Have to use glib-2.44 for this
 _OSTREE_PUBLIC
 G_DECLARE_INTERFACE (OstreeSign, ostree_sign, OSTREE, SIGN, GObject)
index 72fa2841b52898e12c93cc038087c9a0fb73792a..88a5d4f4bf9e8079719ce8cd79dfb78231220661 100644 (file)
@@ -868,8 +868,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
       if (opt_key_ids)
         {
           /* Initialize crypto system */
-          if (!opt_sign_name)
-            opt_sign_name = "ed25519";
+          opt_sign_name = opt_sign_name ?: OSTREE_SIGN_NAME_ED25519;
 
           sign = ostree_sign_get_by_name (opt_sign_name, error);
           if (sign == NULL)
index 73561b437819554d6705e6918d127c8b8712f833..d6cc167ada46e7041cbd73851086775d369ea68b 100644 (file)
@@ -105,8 +105,7 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
     goto out;
 
   /* Initialize crypto system */
-  if (!opt_sign_name)
-    opt_sign_name = "ed25519";
+  opt_sign_name = opt_sign_name ?: OSTREE_SIGN_NAME_ED25519;
 
   sign = ostree_sign_get_by_name (opt_sign_name, error);
   if (sign == NULL)
index de6df835d8eae4f19662e42c242249c27e64baa7..0938f11ecb0e888641f8b6d8282e55e6551f7ef9 100644 (file)
@@ -103,8 +103,7 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
   /* Initialize crypto system */
   if (opt_key_ids)
     {
-      if (!opt_sign_name)
-        opt_sign_name = "ed25519";
+      opt_sign_name = opt_sign_name ?: OSTREE_SIGN_NAME_ED25519;
 
       sign = ostree_sign_get_by_name (opt_sign_name, error);
       if (sign == NULL)