]> sourceware.org Git - lvm2.git/commitdiff
cov: replace enum report_type_t with unsigned
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 May 2024 13:10:58 +0000 (15:10 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 May 2024 14:35:23 +0000 (16:35 +0200)
Another enum used as bitfield mask.

lib/report/report.c
lib/report/report.h
tools/reporter.c
tools/toollib.c
tools/toollib.h

index 23f16342ab01b410d1a6d55f35e232dc6df59c97..1f2de23f05fa7e136dd4e0778182d73b3d384a63 100644 (file)
@@ -4446,7 +4446,7 @@ report_headings_t report_headings_str_to_type(const char *str)
 }
 
 void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
-                 report_type_t *report_type, const char *separator,
+                 unsigned *report_type, const char *separator,
                  int aligned, int buffered, report_headings_t headings,
                  int field_prefixes, int quoted, int columns_as_rows,
                  const char *selection, int multiple_output)
@@ -4507,7 +4507,7 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
 }
 
 void *report_init_for_selection(struct cmd_context *cmd,
-                               report_type_t *report_type,
+                               unsigned *report_type,
                                const char *selection_criteria)
 {
        return dm_report_init_with_selection(report_type, _report_types, _fields,
@@ -4518,7 +4518,7 @@ void *report_init_for_selection(struct cmd_context *cmd,
                                             cmd);
 }
 
-int report_get_prefix_and_desc(report_type_t report_type_id,
+int report_get_prefix_and_desc(unsigned report_type_id,
                               const char **report_prefix,
                               const char **report_desc)
 {
index 67d7605c31c1118f82430cf878b55b071b90e4f0..c2b38a501ee9d8f1746bbd6fd4f6b0df603c1359 100644 (file)
@@ -20,7 +20,7 @@
 #include "lib/label/label.h"
 #include "lib/activate/activate.h"
 
-typedef enum {
+enum {
        CMDLOG          = 1,
        FULL            = 2,
        LVS             = 4,
@@ -33,7 +33,7 @@ typedef enum {
        PVSEGS          = 512,
        LABEL           = 1024,
        DEVTYPES        = 2048
-} report_type_t;
+};
 
 typedef enum {
        REPORT_HEADINGS_UNKNOWN  = -1,
@@ -62,8 +62,8 @@ typedef enum {
  */
 struct selection_handle {
        struct dm_report *selection_rh;
-       report_type_t orig_report_type;
-       report_type_t report_type;
+       unsigned orig_report_type;
+       unsigned report_type;
        int selected;
 };
 
@@ -93,14 +93,14 @@ report_headings_t report_headings_str_to_type(const char *str);
 int report_format_init(struct cmd_context *cmd);
 
 void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
-                 report_type_t *report_type, const char *separator,
+                 unsigned *report_type, const char *separator,
                  int aligned, int buffered, report_headings_t headings,
                  int field_prefixes, int quoted, int columns_as_rows,
                  const char *selection, int multiple_output);
-int report_get_single_selection(struct cmd_context *cmd, report_type_t report_type, const char **selection);
-void *report_init_for_selection(struct cmd_context *cmd, report_type_t *report_type,
+int report_get_single_selection(struct cmd_context *cmd, unsigned report_type, const char **selection);
+void *report_init_for_selection(struct cmd_context *cmd, unsigned *report_type,
                                const char *selection);
-int report_get_prefix_and_desc(report_type_t report_type_id,
+int report_get_prefix_and_desc(unsigned report_type_id,
                               const char **report_prefix,
                               const char **report_desc);
 int report_for_selection(struct cmd_context *cmd,
index 50fe3e552e072696ac2e8bc90eed2674dedd6171..6bba239f06105a5d278adc57a07989a43247eaf2 100644 (file)
@@ -32,10 +32,10 @@ typedef enum {
 #define REPORT_IDX_FULL_START REPORT_IDX_FULL_VGS
 
 struct single_report_args {
-       report_type_t report_type;
+       unsigned report_type;
+       int args_are_pvs;
        char report_prefix[32];
        const char *report_name;
-       int args_are_pvs;
        const char *keys;
        const char *options;
        const char *fields_to_compact;
@@ -47,7 +47,7 @@ struct report_args {
        int argc;
        char **argv;
        dm_report_group_type_t report_group_type;
-       report_type_t report_type;
+       unsigned report_type;
        report_headings_t headings;
        int aligned;
        int buffered;
@@ -495,10 +495,10 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
 
 static int _get_final_report_type(struct report_args *args,
                                  struct single_report_args *single_args,
-                                 report_type_t report_type,
+                                 unsigned report_type,
                                  int *lv_info_needed,
                                  int *lv_segment_status_needed,
-                                 report_type_t *final_report_type)
+                                 unsigned *final_report_type)
 {
        /* Do we need to acquire LV device info in addition? */
        *lv_info_needed = (report_type & (LVSINFO | LVSINFOSTATUS)) ? 1 : 0;
@@ -546,12 +546,12 @@ static int _get_final_report_type(struct report_args *args,
 }
 
 static int _report_all_in_vg(struct cmd_context *cmd, struct processing_handle *handle,
-                            struct volume_group *vg, report_type_t type,
+                            struct volume_group *vg, unsigned report_type,
                             int do_lv_info, int do_lv_seg_status)
 {
        int r = ECMD_FAILED;
 
-       switch (type) {
+       switch (report_type) {
                case VGS:
                        r = _vgs_single(cmd, vg->name, vg, handle);
                        break;
@@ -580,7 +580,8 @@ static int _report_all_in_vg(struct cmd_context *cmd, struct processing_handle *
                                                                                   &_pvsegs_single);
                        break;
                default:
-                       log_error(INTERNAL_ERROR "_report_all_in_vg: incorrect report type");
+                       log_error(INTERNAL_ERROR "_report_all_in_vg: incorrect report type %u.",
+                                 report_type);
                        break;
        }
 
@@ -588,12 +589,12 @@ static int _report_all_in_vg(struct cmd_context *cmd, struct processing_handle *
 }
 
 static int _report_all_in_lv(struct cmd_context *cmd, struct processing_handle *handle,
-                            struct logical_volume *lv, report_type_t type,
+                            struct logical_volume *lv, unsigned report_type,
                             int do_lv_info, int do_lv_seg_status)
 {
        int r = ECMD_FAILED;
 
-       switch (type) {
+       switch (report_type) {
                case LVS:
                        r = _do_lvs_with_info_and_status_single(cmd, lv, do_lv_info, do_lv_seg_status, handle);
                        break;
@@ -605,7 +606,8 @@ static int _report_all_in_lv(struct cmd_context *cmd, struct processing_handle *
                                                                                                &_segs_single);
                        break;
                default:
-                       log_error(INTERNAL_ERROR "_report_all_in_lv: incorrect report type");
+                       log_error(INTERNAL_ERROR "_report_all_in_lv: incorrect report type %u.",
+                                 report_type);
                        break;
        }
 
@@ -613,7 +615,7 @@ static int _report_all_in_lv(struct cmd_context *cmd, struct processing_handle *
 }
 
 static int _report_all_in_pv(struct cmd_context *cmd, struct processing_handle *handle,
-                            struct physical_volume *pv, report_type_t type,
+                            struct physical_volume *pv, unsigned report_type,
                             int do_lv_info, int do_lv_seg_status)
 {
        int r = ECMD_FAILED;
@@ -623,7 +625,7 @@ static int _report_all_in_pv(struct cmd_context *cmd, struct processing_handle *
                return r;
        }
 
-       switch (type) {
+       switch (report_type) {
                case PVS:
                        r = _pvs_single(cmd, pv->vg, pv, handle);
                        break;
@@ -635,7 +637,8 @@ static int _report_all_in_pv(struct cmd_context *cmd, struct processing_handle *
                                                                                        &_pvsegs_sub_single);
                        break;
                default:
-                       log_error(INTERNAL_ERROR "_report_all_in_pv: incorrect report type");
+                       log_error(INTERNAL_ERROR "_report_all_in_pv: incorrect report type %u.",
+                                 report_type);
                        break;
        }
 
@@ -649,7 +652,7 @@ int report_for_selection(struct cmd_context *cmd,
                         struct logical_volume *lv)
 {
        struct selection_handle *sh = parent_handle->selection_handle;
-       report_type_t initial_report_type = sh->report_type;
+       unsigned initial_report_type = sh->report_type;
        struct report_args args = {0};
        struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
        int do_lv_info, do_lv_seg_status;
@@ -710,7 +713,8 @@ int report_for_selection(struct cmd_context *cmd,
                        r = _report_all_in_pv(cmd, handle, pv, sh->report_type, do_lv_info, do_lv_seg_status);
                        break;
                default:
-                       log_error(INTERNAL_ERROR "report_for_selection: incorrect report type");
+                       log_error(INTERNAL_ERROR "report_for_selection: incorrect report type %u",
+                                 sh->orig_report_type);
                        break;
        }
 
@@ -790,7 +794,7 @@ static void _del_option_from_list(struct dm_list *sll, const char *prefix,
 #define _get_report_idx(report_type,single_report_type) \
        ((((report_type) != FULL) && ((report_type) == single_report_type)) ? REPORT_IDX_SINGLE : REPORT_IDX_FULL_ ## single_report_type)
 
-static report_idx_t _get_report_idx_from_name(report_type_t report_type, const char *name)
+static report_idx_t _get_report_idx_from_name(unsigned report_type, const char *name)
 {
        report_idx_t idx;
 
@@ -819,14 +823,14 @@ static report_idx_t _get_report_idx_from_name(report_type_t report_type, const c
                                            : _get_report_idx(report_type, LVS);
        else {
                idx = REPORT_IDX_NULL;
-               log_error("Unknonwn report specifier in "
-                         "report option list: %s.", name);
+               log_error("Unknown report specifier in report option list: %s.",
+                         name);
        }
 
        return idx;
 }
 
-static int _should_process_report_idx(report_type_t report_type, int allow_single, report_idx_t idx)
+static int _should_process_report_idx(unsigned report_type, int allow_single, report_idx_t idx)
 {
        if (((idx == REPORT_IDX_LOG) && (report_type != CMDLOG)) ||
            ((idx == REPORT_IDX_SINGLE) && !allow_single) ||
@@ -992,7 +996,7 @@ out:
 }
 
 static int _do_report_get_selection(struct cmd_context *cmd,
-                                   report_type_t report_type,
+                                   unsigned report_type,
                                    int allow_single,
                                    struct report_args *args,
                                    const char **last_selection)
@@ -1035,7 +1039,7 @@ static int _get_report_selection(struct cmd_context *cmd,
                                        args, NULL) ? ECMD_PROCESSED : ECMD_FAILED;
 }
 
-int report_get_single_selection(struct cmd_context *cmd, report_type_t report_type, const char **selection)
+int report_get_single_selection(struct cmd_context *cmd, unsigned report_type, const char **selection)
 {
        return _do_report_get_selection(cmd, report_type, 1, NULL, selection);
 }
@@ -1082,7 +1086,7 @@ static int _do_report(struct cmd_context *cmd, struct processing_handle *handle,
                      struct report_args *args, struct single_report_args *single_args)
 {
        void *orig_custom_handle = handle->custom_handle;
-       report_type_t report_type = single_args->report_type;
+       unsigned report_type = single_args->report_type;
        void *report_handle = NULL;
        int lv_info_needed;
        int lv_segment_status_needed;
@@ -1381,7 +1385,7 @@ static int _config_report(struct cmd_context *cmd, struct report_args *args, str
        return 1;
 }
 
-static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type)
+static int _report(struct cmd_context *cmd, int argc, char **argv, unsigned report_type)
 {
        struct report_args args = {0};
        struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
@@ -1438,12 +1442,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t
 
 int lvs(struct cmd_context *cmd, int argc, char **argv)
 {
-       report_type_t type;
-
-       if (arg_is_set(cmd, segments_ARG))
-               type = SEGS;
-       else
-               type = LVS;
+       unsigned type = (arg_is_set(cmd, segments_ARG)) ? SEGS : LVS;
 
        return _report(cmd, argc, argv, type);
 }
@@ -1455,7 +1454,7 @@ int vgs(struct cmd_context *cmd, int argc, char **argv)
 
 int pvs(struct cmd_context *cmd, int argc, char **argv)
 {
-       report_type_t type;
+       unsigned type = (arg_is_set(cmd, segments_ARG)) ? PVSEGS : LABEL;
 
        /*
         * Without -a, command only looks at PVs and can use hints,
@@ -1469,11 +1468,6 @@ int pvs(struct cmd_context *cmd, int argc, char **argv)
                cmd->use_hints = 0;
        }
 
-       if (arg_is_set(cmd, segments_ARG))
-               type = PVSEGS;
-       else
-               type = LABEL;
-
        return _report(cmd, argc, argv, type);
 }
 
index b751539e28cc433e49555abd9b5694228471446a..6e9113b0d9e0dd6dc376938eaf36021afba7d89f 100644 (file)
@@ -2038,7 +2038,7 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct
 }
 
 int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle,
-                         report_type_t initial_report_type)
+                         unsigned initial_report_type)
 {
        struct selection_handle *sh;
        const char *selection;
index cce0b2d3d25cc49459ff0ce2e90063fb189b4903..abf3726a3ff46b0539cb31b55b81fe8a23ec5626 100644 (file)
@@ -159,7 +159,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
 
 struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct processing_handle *parent_handle);
 int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle,
-                         report_type_t initial_report_type);
+                         unsigned initial_report_type);
 void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle *handle);
 
 int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle,
This page took 0.055401 seconds and 5 git commands to generate.