tools: reporter: cleanup: setting of cmd->report_strict_type_mode
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 11 Jun 2025 11:06:07 +0000 (13:06 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Thu, 12 Jun 2025 08:18:52 +0000 (10:18 +0200)
Make setting of cmd->report_string_type_mode easier to follow.

tools/reporter.c

index c23a9ebe281e9575e5ab208265a5d5b9e5bba677..5cc6a248737b1d94fcf7de98a236ebd4a5424f0c 100644 (file)
@@ -1505,13 +1505,22 @@ int report_format_init(struct cmd_context *cmd)
        if (!format_str || !strcmp(format_str, REPORT_FORMAT_NAME_BASIC)) {
                args.report_group_type = (report_command_log && !args.log_only) ? DM_REPORT_GROUP_BASIC
                                                                                : DM_REPORT_GROUP_SINGLE;
+               cmd->report_strict_type_mode = 0;
        } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON)) {
                args.report_group_type = DM_REPORT_GROUP_JSON;
                if (!report_command_log_config_set)
                        report_command_log = 1;
+               cmd->report_strict_type_mode = 0;
        } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON_STD)) {
                args.report_group_type = DM_REPORT_GROUP_JSON_STD;
 
+               /*
+                * json_std requires strict type mode. That means all NUM and BIN
+                * fields are always reported as numeric values and not strings which
+                * are synonyms to these numeric values.
+                */
+               cmd->report_strict_type_mode = 1;
+
                /* For json_std, the radix character must be '.'. */
                const char * radixchar = nl_langinfo(RADIXCHAR);
                if (radixchar && strcmp(radixchar, ".")) {
@@ -1540,16 +1549,6 @@ int report_format_init(struct cmd_context *cmd)
                return 0;
        }
 
-       /*
-        * JSON_STD requires strict type mode. That means all NUM and BIN
-        * fields are always reported as numeric values and not strings which
-        * are synonyms to these numeric values.
-        */
-       if (args.report_group_type == DM_REPORT_GROUP_JSON_STD)
-               cmd->report_strict_type_mode = 1;
-       else
-               cmd->report_strict_type_mode = 0;
-
        if (report_command_log) {
                single_args = &args.single_args[REPORT_IDX_LOG];
                single_args->report_type = CMDLOG;
This page took 0.08186 seconds and 5 git commands to generate.