From 4ae68d0430a391db9b338efe58be060f78045f17 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 27 Jun 2023 16:02:07 +0000 Subject: [PATCH] genprotimg: add `NAME` macro parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation for the next patch, add the parameter `NAME` to the `MUT_EXCL_BOOL_FLAG` macro. This is useful for the case when the command line flag has a different naming than the struct field. Reviewed-by: Steffen Eiden Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- genprotimg/src/pv/pv_args.c | 54 +++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/genprotimg/src/pv/pv_args.c b/genprotimg/src/pv/pv_args.c index ca06541e..661ff57b 100644 --- a/genprotimg/src/pv/pv_args.c +++ b/genprotimg/src/pv/pv_args.c @@ -238,29 +238,27 @@ static gboolean cb_remaining_values(const gchar *option G_GNUC_UNUSED, DEFINE_MUT_EXCL_BOOL_FLAG_CB(FLAG, PV_TRUE) \ DEFINE_MUT_EXCL_BOOL_FLAG_CB(FLAG, PV_FALSE) -#define MUT_EXCL_BOOL_FLAG(FLAG, ENABLE_DESC, DISABLE_DESC) \ - { \ - .long_name = "enable-" #FLAG, \ - .short_name = 0, \ - .flags = G_OPTION_FLAG_NO_ARG, \ - .arg = G_OPTION_ARG_CALLBACK, \ - .arg_data = MUT_EXCL_BOOL_FLAG_CB_NAME(FLAG, PV_TRUE), \ - .description = ENABLE_DESC, \ - }, \ - { \ - .long_name = "disable-" #FLAG, \ - .short_name = 0, \ - .flags = G_OPTION_FLAG_NO_ARG, \ - .arg = G_OPTION_ARG_CALLBACK, \ - .arg_data = MUT_EXCL_BOOL_FLAG_CB_NAME(FLAG, PV_FALSE), \ - .description = DISABLE_DESC, \ +#define MUT_EXCL_BOOL_FLAG(NAME, FLAG, ENABLE_DESC, DISABLE_DESC) \ + { \ + .long_name = "enable-" #NAME, \ + .short_name = 0, \ + .flags = G_OPTION_FLAG_NO_ARG, \ + .arg = G_OPTION_ARG_CALLBACK, \ + .arg_data = MUT_EXCL_BOOL_FLAG_CB_NAME(FLAG, PV_TRUE), \ + .description = ENABLE_DESC, \ + }, \ + { \ + .long_name = "disable-" #NAME, .short_name = 0, .flags = G_OPTION_FLAG_NO_ARG, \ + .arg = G_OPTION_ARG_CALLBACK, \ + .arg_data = MUT_EXCL_BOOL_FLAG_CB_NAME(FLAG, PV_FALSE), \ + .description = DISABLE_DESC, \ } #define INDENT " " /* Define the callbacks for mutually exclusive command line flags */ -DEFINE_MUT_EXCL_BOOL_FLAG_CBS(dump) -DEFINE_MUT_EXCL_BOOL_FLAG_CBS(pckmo) +DEFINE_MUT_EXCL_BOOL_FLAG_CBS(dump); +DEFINE_MUT_EXCL_BOOL_FLAG_CBS(pckmo); gint pv_args_parse_options(PvArgs *args, gint *argc, gchar **argv[], GError **err) @@ -326,17 +324,15 @@ gint pv_args_parse_options(PvArgs *args, gint *argc, gchar **argv[], .description = _("Use the kernel parameters stored in PARMFILE\n" INDENT "(optional)."), .arg_description = _("PARMFILE") }, - MUT_EXCL_BOOL_FLAG( - dump, - _("Enable PV guest dumps (optional). This option\n" INDENT - "requires the '--comm-key' option."), - _("Disable PV guest dumps (default).")), - MUT_EXCL_BOOL_FLAG( - pckmo, - _("Enable the support for the DEA, TDEA, AES, and\n" INDENT - "ECC PCKMO key encryption functions (default)."), - _("Disable the support for the DEA, TDEA, AES, and\n" INDENT - "ECC PCKMO key encryption functions (optional).")), + MUT_EXCL_BOOL_FLAG(dump, dump, + _("Enable PV guest dumps (optional). This option\n" INDENT + "requires the '--comm-key' option."), + _("Disable PV guest dumps (default).")), + MUT_EXCL_BOOL_FLAG(pckmo, pckmo, + _("Enable the support for the DEA, TDEA, AES, and\n" INDENT + "ECC PCKMO key encryption functions (default)."), + _("Disable the support for the DEA, TDEA, AES, and\n" INDENT + "ECC PCKMO key encryption functions (optional).")), { .long_name = "comm-key", .short_name = 0, .flags = G_OPTION_FLAG_FILENAME,