]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: do some coding style cleanups
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 16 Jul 2024 06:34:27 +0000 (08:34 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 16 Jul 2024 07:44:51 +0000 (09:44 +0200)
Adjust coding style on some files to somewhat match the Kernel's
coding style, with the help of scripts/checkpatch.pl.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
16 files changed:
bitfield.h
non-standard-ampere.h
non-standard-jaguarmicro.h
non-standard-yitian.h
ras-arm-handler.c
ras-arm-handler.h
ras-events.h
ras-extlog-handler.h
ras-logger.h
ras-mce-handler.h
ras-page-isolation.h
ras-record.h
ras-report.h
rbtree.h
trigger.c
trigger.h

index fccbb361b3dfdf7c76350cdede1c5271f704f94d..2b75b4120b82c446b9fc7e140aa35e8795146ce5 100644 (file)
 /* Generic bitfield decoder */
 
 struct field {
-       unsigned start_bit;
+       unsigned int start_bit;
        char **str;
-       unsigned stringlen;
+       unsigned int stringlen;
 };
 
 struct numfield {
-       unsigned start, end;
+       unsigned int start, end;
        char *name;
        char *fmt;
        int force;
@@ -51,7 +51,7 @@ void decode_numfield(struct mce_event *e, uint64_t status,
                     struct numfield *fields);
 
 #define MASK(x) ((1ULL << (1 + (x))) - 1)
-#define EXTRACT(v, a, b) (((v) >> (a)) & MASK((b)-(a)))
+#define EXTRACT(v, a, b) (((v) >> (a)) & MASK((b) - (a)))
 
 static inline int test_prefix(int nr, uint32_t value)
 {
@@ -60,7 +60,7 @@ static inline int test_prefix(int nr, uint32_t value)
 
 /* Ancillary routines */
 
-unsigned bitfield_msg(char *buf, size_t len, const char **bitarray,
-                     unsigned array_len,
-                     unsigned bit_offset, unsigned ignore_bits,
-                     uint64_t status);
+unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+                         unsigned int array_len,
+                         unsigned int bit_offset, unsigned int ignore_bits,
+                         uint64_t status);
index 2db0db21a9ecb57f50dcc5d2ee849127fdc3350a..1bfe34466c44ee0c631e9471dca7e82af006378d 100644 (file)
@@ -8,7 +8,6 @@
  *
  */
 
-
 #ifndef __NON_STANDARD_AMPERE_H
 #define __NON_STANDARD_AMPERE_H
 
index eb61a25d63f37830b6c287a234464cd549bb57ef..d5db73deaa038e3b8625bb603d007904da62d7c4 100644 (file)
@@ -8,7 +8,6 @@
  *
  */
 
-
 #ifndef __NON_STANDARD_JAGUAR_H
 #define __NON_STANDARD_JAGUAR_H
 
@@ -129,7 +128,6 @@ struct jm_payload5_type_sec {
        struct jm_common_sec_tail common_tail;
 };
 
-
 /*GIC IP */
 struct jm_payload6_type_sec {
        struct jm_common_sec_head common_head;
@@ -168,6 +166,5 @@ enum {
        JM_PAYLOAD_FIELD_REGS_DUMP,
 };
 
-
 #define JM_SNPRINTF    mce_snprintf
 #endif
index 21401e6cb856f00437a69f3ae2d4146cac605752..e4f9db8999c51de2a225e391c3a81ae2217612ca 100644 (file)
@@ -8,7 +8,6 @@
  *
  */
 
-
 #ifndef __NON_STANDARD_YITIAN_H
 #define __NON_STANDARD_YITIAN_H
 
@@ -65,9 +64,9 @@ struct ras_yitian_ddr_payload_event {
 };
 
 int record_yitian_ddr_reg_dump_event(struct ras_ns_ev_decoder *ev_decoder,
-                              struct ras_yitian_ddr_payload_event *ev);
+                                    struct ras_yitian_ddr_payload_event *ev);
 void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                               struct trace_seq *s,
-                               const struct yitian_ddr_payload_type_sec *err,
-                               struct ras_events *ras);
+                                       struct trace_seq *s,
+                                       const struct yitian_ddr_payload_type_sec *err,
+                                       struct ras_events *ras);
 #endif
index e1355b5ac99f1dc066208159f2eb4b829ac1ea51..c07d957048003f35d842e68dfc2a83daefa9035a 100644 (file)
@@ -30,7 +30,7 @@
 
 void display_raw_data(struct trace_seq *s,
                      const uint8_t *buf,
-               uint32_t datalen)
+                     uint32_t datalen)
 {
        int i = 0, line_count = 0;
 
@@ -209,7 +209,6 @@ int ras_arm_event_handler(struct trace_seq *s,
 
        // Upstream kKernels up to version 6.10 don't decode UEFI 2.6+ N.17 table
        if (tep_get_field_val(s, event, "pei_len", record, &val, 1) >= 0) {
-
                ev.pei_len = val;
                trace_seq_printf(s, " ARM Processor Err Info data len: %d\n",
                                 ev.pei_len);
@@ -251,7 +250,6 @@ int ras_arm_event_handler(struct trace_seq *s,
                if (ras_handle_cpu_error(s, record, event, &ev, now) < 0)
                        printf("Can't do CPU fault isolation!\n");
 #endif
-
        }
 
        /* Insert data into the SGBD */
index 8721501581323d4801ba3c20e106e50ced2ff74f..5b2fd47b1d4bc277fbdd8c1ed5a9c657846acf7c 100644 (file)
@@ -33,6 +33,7 @@ struct ras_arm_err_info {
        uint64_t virt_fault_addr;
        uint64_t physical_fault_addr;
 };
+
 #pragma pack()
 
 int ras_arm_event_handler(struct trace_seq *s,
index cc03006d8fada9e48f34fc4120209f46c4cb9c33..f3c53cae5bf54988ea1856ceaa9ab0349caa077a 100644 (file)
@@ -84,7 +84,6 @@ struct pthread_data {
        int                     cpu;
 };
 
-
 /* Should match the code at Kernel's include/linux/edac.c */
 enum hw_event_mc_err_type {
        HW_EVENT_ERR_CORRECTED,
index 2f92c86dddc717b49eb1f7726538cfe7e0e904c2..ce72b4ad746ccb1c225620f5f868657fa50a390b 100644 (file)
@@ -24,9 +24,8 @@
 #include "ras-events.h"
 #include <traceevent/event-parse.h>
 
-extern int ras_extlog_mem_event_handler(struct trace_seq *s,
-                                       struct tep_record *record,
-                                       struct tep_event *event,
-                                       void *context);
-
+int ras_extlog_mem_event_handler(struct trace_seq *s,
+                                struct tep_record *record,
+                                struct tep_event *event,
+                                void *context);
 #endif
index 343fcc2ed8cad7ebe84e28a06ae6c1a9fab993b0..8cab83e67b1de5178c27bc6fb102c54d9e36c0ed 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <syslog.h>
 
+#include "ras-record.h"
+
 /*
  * Logging macros
  */
@@ -28,8 +30,8 @@
        #define TOOL_NAME "rasdaemon"
 #endif
 
-#define SYSLOG (1 << 0)
-#define TERM   (1 << 1)
+#define SYSLOG BIT(0)
+#define TERM   BIT(1)
 #define ALL    (SYSLOG | TERM)
 /* TODO: global logging limit mask */
 
index 694bd414ba246ab209a7714c37fa92b766859f68..407ee45a1832c07790cf1c74a0f1780edcfed0c2 100644 (file)
@@ -75,7 +75,7 @@ struct mce_event {
        uint8_t         cpuvendor;
        uint64_t        synd;   /* MCA_SYND MSR: only valid on SMCA systems */
        uint64_t        ipid;   /* MCA_IPID MSR: only valid on SMCA systems */
-       uint64_t        ppin;
+       uint64_t        ppin;
        uint32_t        microcode;
        int32_t         vdata_len;
        const uint64_t  *vdata;
@@ -103,8 +103,8 @@ struct mce_priv {
 };
 
 #define mce_snprintf(buf, fmt, arg...) do {                    \
-       unsigned __n = strlen(buf);                             \
-       unsigned __len = sizeof(buf) - __n;                     \
+       unsigned int __n = strlen(buf);                         \
+       unsigned int __len = sizeof(buf) - __n;                 \
        if (!__len)                                             \
                break;                                          \
        if (__n) {                                              \
@@ -116,13 +116,13 @@ struct mce_priv {
 } while (0)
 
 /* register and handling routines */
-int register_mce_handler(struct ras_events *ras, unsigned ncpus);
+int register_mce_handler(struct ras_events *ras, unsigned int ncpus);
 int ras_mce_event_handler(struct trace_seq *s,
                          struct tep_record *record,
                          struct tep_event *event, void *context);
 
 /* enables intel iMC logs */
-int set_intel_imc_log(enum cputype cputype, unsigned ncpus);
+int set_intel_imc_log(enum cputype cputype, unsigned int ncpus);
 
 /* Undertake AMD SMCA Error Decoding */
 void decode_smca_error(struct mce_event *e, struct mce_priv *m);
@@ -151,29 +151,29 @@ void decode_amd_errcode(struct mce_event *e);
 /* Software defined banks */
 #define MCE_EXTENDED_BANK      128
 
-#define MCI_THRESHOLD_OVER  (1ULL<<48)  /* threshold error count overflow */
+#define MCI_THRESHOLD_OVER  BIT_ULL(48)  /* threshold error count overflow */
 
-#define MCI_STATUS_VAL   (1ULL<<63)  /* valid error */
-#define MCI_STATUS_OVER  (1ULL<<62)  /* previous errors lost */
-#define MCI_STATUS_UC    (1ULL<<61)  /* uncorrected error */
-#define MCI_STATUS_EN    (1ULL<<60)  /* error enabled */
-#define MCI_STATUS_MISCV (1ULL<<59)  /* misc error reg. valid */
-#define MCI_STATUS_ADDRV (1ULL<<58)  /* addr reg. valid */
-#define MCI_STATUS_PCC   (1ULL<<57)  /* processor context corrupt */
-#define MCI_STATUS_S    (1ULL<<56)  /* signalled */
-#define MCI_STATUS_AR   (1ULL<<55)  /* action-required */
+#define MCI_STATUS_VAL   BIT_ULL(63)  /* valid error */
+#define MCI_STATUS_OVER  BIT_ULL(62)  /* previous errors lost */
+#define MCI_STATUS_UC    BIT_ULL(61)  /* uncorrected error */
+#define MCI_STATUS_EN    BIT_ULL(60)  /* error enabled */
+#define MCI_STATUS_MISCV BIT_ULL(59)  /* misc error reg. valid */
+#define MCI_STATUS_ADDRV BIT_ULL(58)  /* addr reg. valid */
+#define MCI_STATUS_PCC   BIT_ULL(57)  /* processor context corrupt */
+#define MCI_STATUS_S    BIT_ULL(56)  /* signalled */
+#define MCI_STATUS_AR   BIT_ULL(55)  /* action-required */
 
 /* AMD-specific bits */
-#define MCI_STATUS_TCC          (1ULL<<55)  /* Task context corrupt */
-#define MCI_STATUS_SYNDV        (1ULL<<53)  /* synd reg. valid */
+#define MCI_STATUS_TCC          BIT_ULL(55)  /* Task context corrupt */
+#define MCI_STATUS_SYNDV        BIT_ULL(53)  /* synd reg. valid */
 /* uncorrected error,deferred exception */
-#define MCI_STATUS_DEFERRED     (1ULL<<44)
-#define MCI_STATUS_POISON       (1ULL<<43)  /* access poisonous data */
+#define MCI_STATUS_DEFERRED     BIT_ULL(44)
+#define MCI_STATUS_POISON       BIT_ULL(43)  /* access poisonous data */
 
-#define MCG_STATUS_RIPV  (1ULL<<0)   /* restart ip valid */
-#define MCG_STATUS_EIPV  (1ULL<<1)   /* eip points to correct instruction */
-#define MCG_STATUS_MCIP  (1ULL<<2)   /* machine check in progress */
-#define MCG_STATUS_LMCE  (1ULL<<3)   /* local machine check signaled */
+#define MCG_STATUS_RIPV  BIT_ULL(0)   /* restart ip valid */
+#define MCG_STATUS_EIPV  BIT_ULL(1)   /* eip points to correct instruction */
+#define MCG_STATUS_MCIP  BIT_ULL(2)   /* machine check in progress */
+#define MCG_STATUS_LMCE  BIT_ULL(3)   /* local machine check signaled */
 
 /* Those functions are defined on per-cpu vendor C files */
 int parse_intel_event(struct ras_events *ras, struct mce_event *e);
index 3d03cef82309d808a19f626d71a9d34d998df1fd..0482e1e6985b8df055a2df3a8eccae4647e2a68d 100644 (file)
 #ifndef __RAS_PAGE_ISOLATION_H
 #define __RAS_PAGE_ISOLATION_H
 
-#include <time.h>
 #include <stdbool.h>
+#include <time.h>
+
+#include "ras-record.h"
 #include "rbtree.h"
 
 #define PAGE_SHIFT             12
-#define PAGE_SIZE              (1 << PAGE_SHIFT)
-#define PAGE_MASK              (~(PAGE_SIZE-1))
+#define PAGE_SIZE              BIT(PAGE_SHIFT)
+#define PAGE_MASK              (~(PAGE_SIZE - 1))
 
 struct config {
        char                    *name;
@@ -61,6 +63,7 @@ struct isolation {
 };
 
 void ras_page_account_init(void);
-void ras_record_page_error(unsigned long long addr, unsigned count, time_t time);
+void ras_record_page_error(unsigned long long addr,
+                          unsigned int count, time_t time);
 
 #endif
index 2b2231c122c0deb1a875eac3f6ce1e6a42a304e4..c3738baf048832d68352bfba039cc05b1380dc53 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdbool.h>
 #include "config.h"
 
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 
 #define BIT(nr)                 (1UL << (nr))
 #define BIT_ULL(nr)             (1ULL << (nr))
@@ -313,7 +313,7 @@ struct db_table_descriptor {
        size_t                  num_fields;
 };
 
-int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras);
+int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras);
 int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras);
 int ras_mc_add_vendor_table(struct ras_events *ras, sqlite3_stmt **stmt,
                            const struct db_table_descriptor *db_tab);
@@ -337,7 +337,7 @@ int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *
 int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev);
 
 #else
-static inline int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) { return 0; };
+static inline int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras) { return 0; };
 static inline int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras) { return 0; };
 static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
 static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
index e401850a85423d37c3fb76fc9e84837d39d5fa9f..1cddc92dc68ed174739bc0f13d3b4cac001a1cc1 100644 (file)
 #include "ras-aer-handler.h"
 
 /* Maximal length of backtrace. */
-#define MAX_BACKTRACE_SIZE (1024*1024)
+#define MAX_BACKTRACE_SIZE (1024 * 1024)
 /* Amount of data received from one client for a message before reporting error. */
-#define MAX_MESSAGE_SIZE (4*MAX_BACKTRACE_SIZE)
+#define MAX_MESSAGE_SIZE (4 * MAX_BACKTRACE_SIZE)
 /* Maximal number of characters read from socket at once. */
-#define INPUT_BUFFER_SIZE (8*1024)
+#define INPUT_BUFFER_SIZE (8 * 1024)
 /* ABRT socket file */
 #define ABRT_SOCKET "/var/run/abrt/abrt.socket"
 
index a8a0459f17dae33b8156c41dfc1803914d4b9423..e8c38de04d1d9ab11edc10f7e1a74dbdece4addf 100644 (file)
--- a/rbtree.h
+++ b/rbtree.h
@@ -101,8 +101,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
 
-struct rb_node
-{
+struct rb_node {
        unsigned long  rb_parent_color;
 #define        RB_RED          0
 #define        RB_BLACK        1
@@ -111,12 +110,10 @@ struct rb_node
 } __attribute__((aligned(sizeof(long))));
     /* The alignment might seem pointless, but allegedly CRIS needs it */
 
-struct rb_root
-{
+struct rb_root {
        struct rb_node *rb_node;
 };
 
-
 #define rb_parent(r)   ((struct rb_node *)((r)->rb_parent_color & ~3))
 #define rb_color(r)   ((r)->rb_parent_color & 1)
 #define rb_is_red(r)   (!rb_color(r))
@@ -128,6 +125,7 @@ static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
 {
        rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
 }
+
 static inline void rb_set_color(struct rb_node *rb, int color)
 {
        rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
@@ -136,28 +134,29 @@ static inline void rb_set_color(struct rb_node *rb, int color)
 #define RB_ROOT        (struct rb_root) { NULL, }
 #define        rb_entry(ptr, type, member) container_of(ptr, type, member)
 
-#define RB_EMPTY_ROOT(root)    ((root)->rb_node == NULL)
+#define RB_EMPTY_ROOT(root)    ((root)->!rb_node)
 #define RB_EMPTY_NODE(node)    (rb_parent(node) == node)
 #define RB_CLEAR_NODE(node)    (rb_set_parent(node, node))
 
-extern void rb_insert_color(struct rb_node *, struct rb_root *);
-extern void rb_erase(struct rb_node *, struct rb_root *);
+void rb_insert_color(struct rb_node *node, struct rb_root *rb_root);
+void rb_erase(struct rb_node *node, struct rb_root *rb_root);
 
 /* Find logical next and previous nodes in a tree */
-extern struct rb_node *rb_next(const struct rb_node *);
-extern struct rb_node *rb_prev(const struct rb_node *);
-extern struct rb_node *rb_first(const struct rb_root *);
-extern struct rb_node *rb_last(const struct rb_root *);
+struct rb_node *rb_next(const struct rb_node *node);
+struct rb_node *rb_prev(const struct rb_node *node);
+struct rb_node *rb_first(const struct rb_root *rb_root);
+struct rb_node *rb_last(const struct rb_root *rb_root);
 
 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
-extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
-                           struct rb_root *root);
+void rb_replace_node(struct rb_node *victim, struct rb_node *new,
+                    struct rb_root *root);
 
-static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
-                               struct rb_node ** rb_link)
+static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
+                               struct rb_node **rb_link)
 {
-       node->rb_parent_color = (unsigned long )parent;
-       node->rb_left = node->rb_right = NULL;
+       node->rb_parent_color = (unsigned long)parent;
+       node->rb_left = NULL;
+       node->rb_right = NULL;
 
        *rb_link = node;
 }
index 0ee1a5e348f42798b33c5a7270246200eb609f53..3031f4b010e35798372b4c62840c27a80ccfb112 100644 (file)
--- a/trigger.c
+++ b/trigger.c
@@ -26,10 +26,10 @@ void run_trigger(const char *trigger, char *argv[], char **env, const char *repo
                waitpid(child, &status, 0);
                if (WIFEXITED(status) && WEXITSTATUS(status)) {
                        log(SYSLOG, LOG_INFO, "Trigger %s exited with status %d",
-                               trigger, WEXITSTATUS(status));
+                           trigger, WEXITSTATUS(status));
                } else if (WIFSIGNALED(status)) {
                        log(SYSLOG, LOG_INFO, "Trigger %s killed by signal %d",
-                               trigger, WTERMSIG(status));
+                           trigger, WTERMSIG(status));
                }
        }
 }
@@ -43,10 +43,10 @@ const char *trigger_check(const char *s)
        if (trigger_dir) {
                if (asprintf(&name, "%s/%s", trigger_dir, s) < 0)
                        return NULL;
-                s = name;
+               s = name;
        }
 
-       rc = access(s, R_OK|X_OK);
+       rc = access(s, R_OK | X_OK);
 
        if (!rc)
                return(s);
index aea29b5fd4e87753b8bedbff1ec457178216cef3..0cc9df5501a122d51d848c1af506ae5817d561d9 100644 (file)
--- a/trigger.h
+++ b/trigger.h
@@ -2,11 +2,11 @@
 #define __TRIGGER_H__
 
 struct event_trigger {
-        const char *name;
-        void (*setup)(void);
+       const char *name;
+       void (*setup)(void);
 };
 
 const char *trigger_check(const char *s);
-void run_trigger(const char *trigger, char *argv[], char **env, const charreporter);
+void run_trigger(const char *trigger, char *argv[], char **env, const char *reporter);
 
 #endif