]> granicus.if.org Git - sysstat/commitdiff
Cosmetic changes (enumerate values in header files when applicable)
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 23 Dec 2022 14:25:36 +0000 (15:25 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 23 Dec 2022 14:25:36 +0000 (15:25 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
14 files changed:
common.h
iostat.h
json_stats.c
pr_stats.c
sa.h
sa_common.c
sadf.c
sadf.h
sadf_misc.c
sar.c
svg_stats.c
svg_stats.h
tapestat.h
xml_stats.c

index fcf1189647d265b2d84d74b7f619edb3abe9ca18..2c37fcec56677285868a4987183be3be02dff651 100644 (file)
--- a/common.h
+++ b/common.h
 
 /* Index in units array (see common.c) */
 #define NO_UNIT                -1
-#define UNIT_SECTOR    0
-#define UNIT_BYTE      1
-#define UNIT_KILOBYTE  2
+
+enum {
+       UNIT_SECTOR     = 0,
+       UNIT_BYTE       = 1,
+       UNIT_KILOBYTE   = 2
+};
 
 #define NR_UNITS       8
 
@@ -211,18 +214,22 @@ extern char persistent_name_type[MAX_FILE_LEN];
 #define PERCENT_LIMIT_LOW      25.0
 #define PERCENT_LIMIT_XLOW     10.0
 
-#define XHIGH  1
-#define XLOW   2
-#define XLOW0  3
+enum {
+       XHIGH   = 1,
+       XLOW    = 2,
+       XLOW0   = 3
+};
 
 #define MAX_SGR_LEN    16
 
-#define IS_INT         0
-#define IS_STR         1
-#define IS_RESTART     2
-#define IS_DEBUG       IS_RESTART
-#define IS_COMMENT     3
-#define IS_ZERO                4
+enum {
+       IS_INT          = 0,
+       IS_STR          = 1,
+       IS_RESTART      = 2,
+       IS_COMMENT      = 3,
+       IS_ZERO         = 4,
+       IS_DEBUG        = IS_RESTART
+};
 
 /*
  ***************************************************************************
index 380263c2eba33df85e602916015a0c6e210cc4b2..26eed2315a41b299954541ed198173ab68c5dcef 100644 (file)
--- a/iostat.h
+++ b/iostat.h
 #define USE_ALL_DIR(m)                 (((m) & I_D_ALL_DIR)          == I_D_ALL_DIR)
 #define DISPLAY_COMPACT(m)             (((m) & I_D_COMPACT)          == I_D_COMPACT)
 
-#define T_PART         0
-#define T_DEV          1
-#define T_PART_DEV     2
-#define T_GROUP                3
+enum {
+       T_PART          = 0,
+       T_DEV           = 1,
+       T_PART_DEV      = 2,
+       T_GROUP         = 3
+};
 
 #define UKWN_MAJ_NR    0
 
index 532ca100db4749b24e619d4cc5f61d365dbc6c3a..51a7e66cbbf707192d41e9edc644d44571f7faff 100644 (file)
@@ -46,7 +46,7 @@ extern uint64_t flags;
  * @action     Open or close action.
  ***************************************************************************
  */
-void json_markup_network(int tab, int action)
+void json_markup_network(int tab, enum json_action action)
 {
        static int markup_state = CLOSE_JSON_MARKUP;
 
@@ -74,7 +74,7 @@ void json_markup_network(int tab, int action)
  * @action     Open or close action.
  ***************************************************************************
  */
-void json_markup_power_management(int tab, int action)
+void json_markup_power_management(int tab, enum json_action action)
 {
        static int markup_state = CLOSE_JSON_MARKUP;
 
@@ -102,7 +102,7 @@ void json_markup_power_management(int tab, int action)
  * @action     Open or close action.
  ***************************************************************************
  */
-void json_markup_psi(int tab, int action)
+void json_markup_psi(int tab, enum json_action action)
 {
        static int markup_state = CLOSE_JSON_MARKUP;
 
index 0040f94f410d566aaee7e6ad6121a993baa0fae5..cbd9800e7124b076cc709aec75a0711392f444da 100644 (file)
@@ -48,7 +48,7 @@ extern unsigned long avg_count;
  * IN:
  * @p_timestamp                Timestamp for previous stat sample.
  * @a                  Activity structure.
- * @pos                        Header to display, 0 being the first header (headers
+ * @pos                        Header to display, FIRST being the first header (headers
  *                     are delimited by the '|' character).
  * @iwidth             First column width (generally this is the item name).
  *                     A negative value means that the corresponding field
diff --git a/sa.h b/sa.h
index 14d82c49563ab90f28180182e55371223a20c3e9..e59a7281b9b1aa041bee28be50a2438f0b8f156e 100644 (file)
--- a/sa.h
+++ b/sa.h
 #define NR_F_COUNT     13
 
 /* Activities */
-#define A_CPU          1
-#define A_PCSW         2
-#define A_IRQ          3
-#define A_SWAP         4
-#define A_PAGE         5
-#define A_IO           6
-#define A_MEMORY       7
-#define A_KTABLES      8
-#define A_QUEUE                9
-#define A_SERIAL       10
-#define A_DISK         11
-#define A_NET_DEV      12
-#define A_NET_EDEV     13
-#define A_NET_NFS      14
-#define A_NET_NFSD     15
-#define A_NET_SOCK     16
-#define A_NET_IP       17
-#define A_NET_EIP      18
-#define A_NET_ICMP     19
-#define A_NET_EICMP    20
-#define A_NET_TCP      21
-#define A_NET_ETCP     22
-#define A_NET_UDP      23
-#define A_NET_SOCK6    24
-#define A_NET_IP6      25
-#define A_NET_EIP6     26
-#define A_NET_ICMP6    27
-#define A_NET_EICMP6   28
-#define A_NET_UDP6     29
-#define A_PWR_CPU      30
-#define A_PWR_FAN      31
-#define A_PWR_TEMP     32
-#define A_PWR_IN       33
-#define A_HUGE         34
-#define A_PWR_FREQ     35
-#define A_PWR_USB      36
-#define A_FS           37
-#define A_NET_FC       38
-#define A_NET_SOFT     39
-#define A_PSI_CPU      40
-#define A_PSI_IO       41
-#define A_PSI_MEM      42
-
+enum {
+       A_CPU           = 1,
+       A_PCSW          = 2,
+       A_IRQ           = 3,
+       A_SWAP          = 4,
+       A_PAGE          = 5,
+       A_IO            = 6,
+       A_MEMORY        = 7,
+       A_KTABLES       = 8,
+       A_QUEUE         = 9,
+       A_SERIAL        = 10,
+       A_DISK          = 11,
+       A_NET_DEV       = 12,
+       A_NET_EDEV      = 13,
+       A_NET_NFS       = 14,
+       A_NET_NFSD      = 15,
+       A_NET_SOCK      = 16,
+       A_NET_IP        = 17,
+       A_NET_EIP       = 18,
+       A_NET_ICMP      = 19,
+       A_NET_EICMP     = 20,
+       A_NET_TCP       = 21,
+       A_NET_ETCP      = 22,
+       A_NET_UDP       = 23,
+       A_NET_SOCK6     = 24,
+       A_NET_IP6       = 25,
+       A_NET_EIP6      = 26,
+       A_NET_ICMP6     = 27,
+       A_NET_EICMP6    = 28,
+       A_NET_UDP6      = 29,
+       A_PWR_CPU       = 30,
+       A_PWR_FAN       = 31,
+       A_PWR_TEMP      = 32,
+       A_PWR_IN        = 33,
+       A_HUGE          = 34,
+       A_PWR_FREQ      = 35,
+       A_PWR_USB       = 36,
+       A_FS            = 37,
+       A_NET_FC        = 38,
+       A_NET_SOFT      = 39,
+       A_PSI_CPU       = 40,
+       A_PSI_IO        = 41,
+       A_PSI_MEM       = 42
+};
 
 /* Macro used to flag an activity that should be collected */
 #define COLLECT_ACTIVITY(m)    act[get_activity_position(act, m, EXIT_IF_NOT_FOUND)]->options |= AO_COLLECTED
 #define EXIT_IF_NOT_FOUND      1
 #define RESUME_IF_NOT_FOUND    0
 
-#define SOFT_SIZE      0
-#define HARD_SIZE      1
+enum size_mode {
+       SOFT_SIZE = 0,
+       HARD_SIZE = 1
+};
 
-#define FIRST  0
-#define SECOND 1
+enum {
+       FIRST   = 0,
+       SECOND  = 1
+};
 
-#define END_OF_DATA_UNEXPECTED 1
-#define INCONSISTENT_INPUT_DATA        2
+enum sa_err_codes {
+       END_OF_DATA_UNEXPECTED  = 1,
+       INCONSISTENT_INPUT_DATA = 2
+};
 
-#define UEOF_STOP      0
-#define UEOF_CONT      1
+enum on_eof {
+       UEOF_STOP = 0,
+       UEOF_CONT = 1
+};
 
-#define CLOSE_XML_MARKUP       0
-#define OPEN_XML_MARKUP                1
+enum xml_action {
+       CLOSE_XML_MARKUP = 0,
+       OPEN_XML_MARKUP  = 1
+};
 
-#define CLOSE_JSON_MARKUP      0
-#define OPEN_JSON_MARKUP       1
+enum json_action {
+       CLOSE_JSON_MARKUP = 0,
+       OPEN_JSON_MARKUP  = 1
+};
 
-#define COUNT_ACTIVITIES       0
-#define COUNT_OUTPUTS          1
+enum count_mode {
+       COUNT_ACTIVITIES = 0,
+       COUNT_OUTPUTS    = 1
+};
 
 /* Type for all functions reading statistics */
 #define __read_funct_t void
 
 /*
  ***************************************************************************
- * Output formats for sadf
+ * Output formats for sadfsize_mode
  ***************************************************************************
  */
 
 #define NR_FMT 9
 
 /* Output formats */
-#define F_SAR_OUTPUT   0
-#define F_DB_OUTPUT    1
-#define F_HEADER_OUTPUT        2
-#define F_PPC_OUTPUT   3
-#define F_XML_OUTPUT   4
-#define F_JSON_OUTPUT  5
-#define F_CONV_OUTPUT  6
-#define F_SVG_OUTPUT   7
-#define F_RAW_OUTPUT   8
-#define F_PCP_OUTPUT   9
-
+enum {
+       F_SAR_OUTPUT    = 0,
+       F_DB_OUTPUT     = 1,
+       F_HEADER_OUTPUT = 2,
+       F_PPC_OUTPUT    = 3,
+       F_XML_OUTPUT    = 4,
+       F_JSON_OUTPUT   = 5,
+       F_CONV_OUTPUT   = 6,
+       F_SVG_OUTPUT    = 7,
+       F_RAW_OUTPUT    = 8,
+       F_PCP_OUTPUT    = 9
+};
 
 /* Structure for SVG specific parameters */
 struct svg_parm {
@@ -716,33 +732,35 @@ struct extra_desc {
 #define MAX_EXTRA_SIZE         1024
 
 /* Record type */
-/*
- * R_STATS means that this is a record of statistics.
- */
-#define R_STATS                1
-/*
- * R_RESTART means that this is a special record containing
- * a LINUX RESTART message.
- */
-#define R_RESTART      2
-/*
- * R_LAST_STATS warns sar that this is the last record to be written
- * to file before a file rotation, and that the next data to come will
- * be a header file.
- * Such a record is tagged R_STATS anyway before being written to file.
- */
-#define R_LAST_STATS   3
-/*
- * R_COMMENT means that this is a special record containing
- * a comment.
- */
-#define R_COMMENT      4
-/*
- * R_EXTRA* records means that extra structures are following current
- * record_header structure, but no statistics structures.
- */
-#define R_EXTRA_MIN    5
-#define R_EXTRA_MAX    15
+enum {
+       /*
+        * R_STATS means that this is a record of statistics.
+       */
+       R_STATS         = 1,
+       /*
+        * R_RESTART means that this is a special record containing
+        * a LINUX RESTART message.
+       */
+       R_RESTART       = 2,
+       /*
+        * R_LAST_STATS warns sar that this is the last record to be written
+        * to file before a file rotation, and that the next data to come will
+        * be a header file.
+        * Such a record is tagged R_STATS anyway before being written to file.
+        */
+       R_LAST_STATS    = 3,
+       /*
+        * R_COMMENT means that this is a special record containing
+        * a comment.
+        */
+       R_COMMENT       = 4,
+       /*
+        * R_EXTRA* records means that extra structures are following current
+        * record_header structure, but no statistics structures.
+       */
+       R_EXTRA_MIN     = 5,
+       R_EXTRA_MAX     = 15
+};
 
 /* Maximum length of a comment */
 #define MAX_COMMENT_LEN        64
@@ -1277,8 +1295,10 @@ struct report_format {
 /* Maximum number of views on a single row */
 #define MAX_VIEWS_ON_A_ROW     6
 
-#define SVG_LINE_GRAPH 1
-#define SVG_BAR_GRAPH  2
+enum svg_graph_type {
+       SVG_LINE_GRAPH  = 1,
+       SVG_BAR_GRAPH   = 2
+};
 
 /* Maximum number of horizontal lines for the background grid */
 #define MAX_HLINES_NR  10
@@ -1296,9 +1316,11 @@ struct report_format {
 #define SVG_COL_HEADER_IDX     22
 #define SVG_COL_ERROR_IDX      23
 
-#define SVG_DEFAULT_COL_PALETTE        0
-#define SVG_CUSTOM_COL_PALETTE 1
-#define SVG_BW_COL_PALETTE     2
+enum {
+       SVG_DEFAULT_COL_PALETTE = 0,
+       SVG_CUSTOM_COL_PALETTE  = 1,
+       SVG_BW_COL_PALETTE      = 2
+};
 
 #define MAYBE  0x80
 
@@ -1484,7 +1506,7 @@ int check_alt_sa_dir
 void enum_version_nr
        (struct file_magic *);
 int get_activity_nr
-       (struct activity * [], unsigned int, int);
+       (struct activity * [], unsigned int, enum count_mode);
 int get_activity_position
        (struct activity * [], unsigned int, int);
 void handle_invalid_sa_file
@@ -1573,7 +1595,7 @@ int print_special_record
         struct file_header *, struct activity * [], struct report_format *, int, int);
 int read_file_stat_bunch
        (struct activity * [], int, int, int, struct file_activity *, int, int,
-        char *, struct file_magic *, int);
+        char *, struct file_magic *, enum on_eof);
 __nr_t read_nr_value
        (int, char *, struct file_magic *, int, int, int);
 int read_record_hdr
@@ -1584,7 +1606,7 @@ void reallocate_all_buffers
 void replace_nonprintable_char
        (int, char *);
 int sa_fread
-       (int, void *, size_t, int, int);
+       (int, void *, size_t, enum size_mode, enum on_eof);
 int sa_get_record_timestamp_struct
        (uint64_t, struct record_header *, struct tm *);
 int sa_open_read_magic
index 0ca8b039a8500fcd27ed616fd366f3b39eb55490..5b4aeac2ebf1b1b3ed00c7e30b90979f5a1e007c 100644 (file)
@@ -91,17 +91,17 @@ int get_activity_position(struct activity *act[], unsigned int act_flag, int sto
  * Count number of activities with given option.
  *
  * IN:
- * @act                        Array of activities.
- * @option             Option that activities should have to be counted
- *                     (eg. AO_COLLECTED...)
- * @count_outputs      TRUE if each output should be counted for activities with
- *                     multiple outputs.
+ * @act                Array of activities.
+ * @option     Option that activities should have to be counted
+ *             (eg. AO_COLLECTED...)
+ * @count      Set to COUNT_OUTPUTS if each output should be counted for
+ *             activities with multiple outputs.
  *
  * RETURNS:
  * Number of selected activities
  ***************************************************************************
  */
-int get_activity_nr(struct activity *act[], unsigned int option, int count_outputs)
+int get_activity_nr(struct activity *act[], unsigned int option, enum count_mode count)
 {
        int i, n = 0;
        unsigned int msk;
@@ -109,7 +109,7 @@ int get_activity_nr(struct activity *act[], unsigned int option, int count_outpu
        for (i = 0; i < NR_ACT; i++) {
                if ((act[i]->options & option) == option) {
 
-                       if (HAS_MULTIPLE_OUTPUTS(act[i]->options) && count_outputs) {
+                       if (HAS_MULTIPLE_OUTPUTS(act[i]->options) && (count == COUNT_OUTPUTS)) {
                                for (msk = 1; msk < 0x100; msk <<= 1) {
                                        if ((act[i]->opt_flags & 0xff) & msk) {
                                                n++;
@@ -1373,7 +1373,7 @@ int remap_struct(unsigned int gtypes_nr[], unsigned int ftypes_nr[],
  * 0 otherwise.
  ***************************************************************************
  */
-int sa_fread(int ifd, void *buffer, size_t size, int mode, int oneof)
+int sa_fread(int ifd, void *buffer, size_t size, enum size_mode mode, enum on_eof oneof)
 {
        ssize_t n;
 
@@ -1649,7 +1649,7 @@ __nr_t read_nr_value(int ifd, char *file, struct file_magic *file_magic,
 int read_file_stat_bunch(struct activity *act[], int curr, int ifd, int act_nr,
                         struct file_activity *file_actlst, int endian_mismatch,
                         int arch_64, char *dfile, struct file_magic *file_magic,
-                        int oneof)
+                        enum on_eof oneof)
 {
        int i, j, p;
        struct file_activity *fal = file_actlst;
diff --git a/sadf.c b/sadf.c
index dede7871e718a5ce945caccda412c1ca156006fc..29fdc5d1d6d895911aa69014e275e059877e6a03 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -241,7 +241,7 @@ void check_format_options(void)
  */
 int read_next_sample(int ifd, int action, int curr, char *file, int *rtype, int tab,
                     struct file_magic *file_magic, struct file_activity *file_actlst,
-                    struct tm *rectime, int oneof)
+                    struct tm *rectime, enum on_eof oneof)
 {
        int rc;
        char rec_hdr_tmp[MAX_RECORD_HEADER_SIZE];
diff --git a/sadf.h b/sadf.h
index 582659cbecad10d40e5fcfa834b5812a551276f2..3989f2e0b9c3c786358a3a4df0ccfd2f81a8e01f 100644 (file)
--- a/sadf.h
+++ b/sadf.h
 #define XML_DTD_VERSION        "3.12"
 
 /* Various constants */
-#define DO_SAVE                0
-#define DO_RESTORE     1
+enum {
+       DO_SAVE         = 0,
+       DO_RESTORE      = 1
+};
 
 #define IGNORE_NOTHING         0
 #define IGNORE_RESTART         1
index 3fef6bcf39641a0881a4efb0977a03eb2197374f..432fda04f0e10709c62d09092b2c5ab6d6d0c1f3 100644 (file)
@@ -868,14 +868,14 @@ char *print_dbppc_timestamp(int fmt, struct file_header *file_hdr, char *cur_dat
  * @itv                Interval of time with preceding record.
  * @record_hdr Record header for current sample (unused here).
  * @file_hdr   System activity file standard header.
- * @flags      Flags for common options.
+ * @flags      Flags for common options (unused here).
  *
  * RETURNS:
  * Pointer on the "timestamp" string.
  ***************************************************************************
  */
 __tm_funct_t print_ppc_timestamp(void *parm, int action, char *cur_date,
-                                char *cur_time, char * my_tz, unsigned long long itv,
+                                char *cur_time, char *my_tz, unsigned long long itv,
                                 struct record_header *record_hdr,
                                 struct file_header *file_hdr, unsigned int flags)
 {
diff --git a/sar.c b/sar.c
index 0bc291078b913fdb62fb3133cb1fdbb95b57a486..c66c3b1f778b20adf61502f1f742ef362788f610 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -278,7 +278,7 @@ void salloc(int i, char *ltemp)
  * @error_code Code of error message to display.
  ***************************************************************************
  */
-void print_read_error(int error_code)
+void print_read_error(enum sa_err_codes error_code)
 {
        switch (error_code) {
 
index e1d88a9d1c6371e8954c6196dc3fd2e53f91031d..f5b1b4e18f3fc8bfe089708ab5c1f816d990d53e 100644 (file)
@@ -596,8 +596,8 @@ void compute_next_graduation_timestamp(struct record_header *stamp, long int xpo
  * @asfactor   Autoscale factors (one for each graph).
  ***************************************************************************
  */
-void gr_autoscaling(unsigned int asfactor[], int asf_nr, int group, int g_type, int pos,
-                   double gmax, double *spmax)
+void gr_autoscaling(unsigned int asfactor[], int asf_nr, int group, enum svg_graph_type g_type,
+                   int pos, double gmax, double *spmax)
 {
        int j;
        char val[32];
index a64d2d0456e6c5731d3f2a5dc8acac482ba9ad22..634bbf7541cb9cb053dc424b42d8b8b1333df333 100644 (file)
@@ -6,7 +6,6 @@
 #ifndef _SVG_STATS_H
 #define _SVG_STATS_H
 
-
 /*
  ***************************************************************************
  * Prototypes for functions used to display system statistics in SVG.
index 9e4110254b06eade6408d56f9bd74da113534f61..49162bce20d2cf2509d4299fdc82e66d4060c763 100644 (file)
 #define DISPLAY_ZERO_OMIT(m)           (((m) & T_D_ZERO_OMIT)       == T_D_ZERO_OMIT)
 #define DISPLAY_UNIT(m)                        (((m) & T_D_UNIT)            == T_D_UNIT)
 
-#define TAPE_STATS_VALID 1
-#define TAPE_STATS_INVALID 0
+enum {
+       TAPE_STATS_INVALID = 0,
+       TAPE_STATS_VALID   = 1
+};
 
 #define SYSFS_CLASS_TAPE_DIR   PRE "/sys/class/scsi_tape"
 #define TAPE_STAT_PATH         PRE "/sys/class/scsi_tape/st%i/stats/"
index 48654929076121194955857edd290ce9761e6489..d48524fab17683690cf6fbec91b36ad1be7d970d 100644 (file)
@@ -46,7 +46,7 @@ extern uint64_t flags;
  * @action     Open or close action.
  ***************************************************************************
  */
-void xml_markup_network(int tab, int action)
+void xml_markup_network(int tab, enum xml_action action)
 {
        static int markup_state = CLOSE_XML_MARKUP;
 
@@ -73,7 +73,7 @@ void xml_markup_network(int tab, int action)
  * @action     Open or close action.
  ***************************************************************************
  */
-void xml_markup_power_management(int tab, int action)
+void xml_markup_power_management(int tab, enum xml_action action)
 {
        static int markup_state = CLOSE_XML_MARKUP;
 
@@ -100,7 +100,7 @@ void xml_markup_power_management(int tab, int action)
  * @action     Open or close action.
  ***************************************************************************
  */
-void xml_markup_psi(int tab, int action)
+void xml_markup_psi(int tab, enum xml_action action)
 {
        static int markup_state = CLOSE_XML_MARKUP;