From c1290177a312d5f416d7afd43be2c1cfe1a3f7ad Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 5 May 2017 11:28:42 +0100 Subject: [PATCH] ostree: Use #defines for well-known metadata key names Rather than hard-coding the names as strings. This makes the code a little more maintainable. Signed-off-by: Philip Withnall Closes: #826 Approved by: cgwalters --- src/ostree/ot-builtin-gpg-sign.c | 7 ++++--- src/ostree/ot-dump.c | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ostree/ot-builtin-gpg-sign.c b/src/ostree/ot-builtin-gpg-sign.c index 0ef2be8b..e14eba68 100644 --- a/src/ostree/ot-builtin-gpg-sign.c +++ b/src/ostree/ot-builtin-gpg-sign.c @@ -26,6 +26,7 @@ #include "ot-builtins.h" #include "ostree.h" #include "otutil.h" +#include "ostree-core-private.h" static gboolean opt_delete; static char *opt_gpg_homedir; @@ -85,7 +86,7 @@ delete_signatures (OstreeRepo *repo, g_variant_dict_init (&metadata_dict, old_metadata); signature_data = g_variant_dict_lookup_value (&metadata_dict, - "ostree.gpgsigs", + _OSTREE_METADATA_GPGSIGS_NAME, G_VARIANT_TYPE ("aay")); /* Taking the approach of deleting whatever matches we find for the @@ -154,7 +155,7 @@ delete_signatures (OstreeRepo *repo, /* Update the metadata dictionary. */ if (g_queue_is_empty (&signatures)) { - g_variant_dict_remove (&metadata_dict, "ostree.gpgsigs"); + g_variant_dict_remove (&metadata_dict, _OSTREE_METADATA_GPGSIGS_NAME); } else { @@ -170,7 +171,7 @@ delete_signatures (OstreeRepo *repo, } g_variant_dict_insert_value (&metadata_dict, - "ostree.gpgsigs", + _OSTREE_METADATA_GPGSIGS_NAME, g_variant_builder_end (&signature_builder)); } diff --git a/src/ostree/ot-dump.c b/src/ostree/ot-dump.c index 7cbc2945..b24003c7 100644 --- a/src/ostree/ot-dump.c +++ b/src/ostree/ot-dump.c @@ -26,6 +26,8 @@ #include +#include "ostree-repo-private.h" +#include "ostree-repo-static-delta-private.h" #include "ot-dump.h" #include "otutil.h" #include "ot-admin-functions.h" @@ -268,17 +270,17 @@ ot_dump_summary_bytes (GBytes *summary_bytes, g_autofree gchar *value_str = NULL; const gchar *pretty_key = NULL; - if (g_strcmp0 (key, "ostree.static-deltas") == 0) + if (g_strcmp0 (key, OSTREE_SUMMARY_STATIC_DELTAS) == 0) { pretty_key = "Static Deltas"; value_str = g_variant_print (value, FALSE); } - else if (g_strcmp0 (key, "ostree.summary.last-modified") == 0) + else if (g_strcmp0 (key, OSTREE_SUMMARY_LAST_MODIFIED) == 0) { pretty_key = "Last-Modified"; value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value))); } - else if (g_strcmp0 (key, "ostree.summary.expires") == 0) + else if (g_strcmp0 (key, OSTREE_SUMMARY_EXPIRES) == 0) { pretty_key = "Expires"; value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));