]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
C files: cleanup coding style
authorMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 22 Jan 2024 07:36:47 +0000 (08:36 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 22 Jan 2024 07:57:33 +0000 (08:57 +0100)
The rasdaemon conding style follows Linux Kernel where it makes sense.

Yet, changes made overtime ended with some coding style non-compliances.

Adjust rasdaemon coding style by using:

   scripts/checkpatch.pl --fix-inplace --strict *.c --ignore PREFER_KERNEL_TYPES

And doing some manual fixups where the script didn't work.
As a bonus, some typos were also fixed on some rasdaemon messages.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
39 files changed:
bitfield.c
mce-amd-k8.c
mce-amd-smca.c
mce-amd.c
mce-intel-broadwell-de.c
mce-intel-broadwell-epex.c
mce-intel-dunnington.c
mce-intel-haswell.c
mce-intel-ivb.c
mce-intel-knl.c
mce-intel-nehalem.c
mce-intel-p4-p6.c
mce-intel-sb.c
mce-intel-skylake-xeon.c
mce-intel-tulsa.c
mce-intel.c
non-standard-ampere.c
non-standard-hisi_hip08.c
non-standard-hisilicon.c
non-standard-jaguarmicro.c
non-standard-yitian.c
queue.c
ras-aer-handler.c
ras-arm-handler.c
ras-cpu-isolation.c
ras-cxl-handler.c
ras-devlink-handler.c
ras-diskerror-handler.c
ras-events.c
ras-extlog-handler.c
ras-mc-handler.c
ras-mce-handler.c
ras-memory-failure-handler.c
ras-non-standard-handler.c
ras-page-isolation.c
ras-record.c
ras-report.c
rasdaemon.c
rbtree.c

index f0047551a2414cad4e2ba8eb4f4ca8a0bab6ed72..2076683d1d0dc20004ee90e023a897becc867219 100644 (file)
 #include "ras-mce-handler.h"
 #include "bitfield.h"
 
-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)
 {
        int i, n;
        char *p = buf;
@@ -64,6 +64,7 @@ unsigned bitfield_msg(char *buf, size_t len, const char **bitarray,
 static uint64_t bitmask(uint64_t i)
 {
        uint64_t mask = 1;
+
        while (mask < i)
                mask = (mask << 1) | 1;
        return mask;
@@ -77,6 +78,7 @@ void decode_bitfield(struct mce_event *e, uint64_t status,
        for (f = fields; f->str; f++) {
                uint64_t v = (status >> f->start_bit) & bitmask(f->stringlen - 1);
                char *s = NULL;
+
                if (v < f->stringlen)
                        s = f->str[v];
                if (!s) {
@@ -93,11 +95,14 @@ void decode_numfield(struct mce_event *e, uint64_t status,
                     struct numfield *fields)
 {
        struct numfield *f;
+
        for (f = fields; f->name; f++) {
                uint64_t mask = (1ULL << (f->end - f->start + 1)) - 1;
                uint64_t v = (status >> f->start) & mask;
+
                if (v > 0 || f->force) {
                        char fmt[32] = {0};
+
                        snprintf(fmt, 32, "%%s: %s\n", f->fmt ? f->fmt : "%Lu");
                        mce_snprintf(e->error_msg, fmt, f->name, v);
                }
index dc772c2e150dd8a5978e9ab8598b8a3b9df0104b..f27b823dc28cfa86db43c4326b245207487027fe 100644 (file)
@@ -43,7 +43,7 @@ static const char *k8bank[] = {
 };
 
 static const char *k8threshold[] = {
-       [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknow threshold counter",
+       [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknown threshold counter",
        [K8_MCELOG_THRESHOLD_DRAM_ECC] = "MC4_MISC0 DRAM threshold",
        [K8_MCELOG_THRESHOLD_LINK] = "MC4_MISC1 Link threshold",
        [K8_MCELOG_THRESHOLD_L3_CACHE] = "MC4_MISC2 L3 Cache threshold",
@@ -56,25 +56,31 @@ static const char *k8threshold[] = {
 static const char *transaction[] = {
        "instruction", "data", "generic", "reserved"
 };
+
 static const char *cachelevel[] = {
        "0", "1", "2", "generic"
 };
+
 static const char *memtrans[] = {
        "generic error", "generic read", "generic write", "data read",
        "data write", "instruction fetch", "prefetch", "evict", "snoop",
        "?", "?", "?", "?", "?", "?", "?"
 };
+
 static const char *partproc[] = {
        "local node origin", "local node response",
        "local node observed", "generic participation"
 };
+
 static const char *timeout[] = {
        "request didn't time out",
        "request timed out"
 };
+
 static const char *memoryio[] = {
        "memory", "res.", "i/o", "generic"
 };
+
 static const char *nbextendederr[] = {
        "RAM ECC error",
        "CRC error",
@@ -96,6 +102,7 @@ static const char *nbextendederr[] = {
        "L3 Cache Tag Error",
        "L3 Cache LRU Error"
 };
+
 static const char *highbits[32] = {
        [31] = "valid",
        [30] = "error overflow (multiple errors)",
@@ -164,7 +171,7 @@ static void decode_k8_dc_mc(struct mce_event *e)
        if (e->status & (3ULL << 45)) {
                mce_snprintf(e->error_msg,
                             "Data cache ECC error (syndrome %x)",
-                             (uint32_t) (e->status >> 47) & 0xff);
+                            (uint32_t)(e->status >> 47) & 0xff);
                if (e->status & (1ULL << 40))
                        mce_snprintf(e->error_msg, "found by scrubber");
        }
@@ -185,7 +192,7 @@ static void decode_k8_ic_mc(struct mce_event *e)
 
        if ((errcode & 0xfff0) == 0x0010)
                mce_snprintf(e->error_msg, "TLB parity error in %s array",
-                           (exterrcode == 0) ? "physical" : "virtual");
+                            (exterrcode == 0) ? "physical" : "virtual");
 }
 
 static void decode_k8_bu_mc(struct mce_event *e)
@@ -196,10 +203,10 @@ static void decode_k8_bu_mc(struct mce_event *e)
                mce_snprintf(e->error_msg, "L2 cache ECC error");
 
        mce_snprintf(e->error_msg, "%s array error",
-                   !exterrcode ? "Bus or cache" : "Cache tag");
+                    !exterrcode ? "Bus or cache" : "Cache tag");
 }
 
-static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
+static void decode_k8_nb_mc(struct mce_event *e, unsigned int *memerr)
 {
        unsigned short exterrcode = (e->status >> 16) & 0x0f;
 
@@ -209,13 +216,13 @@ static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
        case 0:
                *memerr = 1;
                mce_snprintf(e->error_msg, "ECC syndrome = %x",
-                           (uint32_t) (e->status >> 47) & 0xff);
+                            (uint32_t)(e->status >> 47) & 0xff);
                break;
        case 8:
                *memerr = 1;
                mce_snprintf(e->error_msg, "Chipkill ECC syndrome = %x",
-                           (uint32_t) ((((e->status >> 24) & 0xff) << 8)
-                           | ((e->status >> 47) & 0xff)));
+                            (uint32_t)((((e->status >> 24) & 0xff) << 8)
+                            | ((e->status >> 47) & 0xff)));
                break;
        case 1:
        case 2:
@@ -223,7 +230,7 @@ static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
        case 4:
        case 6:
                mce_snprintf(e->error_msg, "link number = %x",
-                            (uint32_t) (e->status >> 36) & 0xf);
+                            (uint32_t)(e->status >> 36) & 0xf);
                break;
        }
 }
@@ -251,11 +258,12 @@ static void bank_name(struct mce_event *e)
 
 int parse_amd_k8_event(struct ras_events *ras, struct mce_event *e)
 {
-       unsigned ismemerr = 0;
+       unsigned int ismemerr = 0;
 
        /* Don't handle GART errors */
        if (e->bank == 4) {
                unsigned short exterrcode = (e->status >> 16) & 0x0f;
+
                if (exterrcode == 5 && (e->status & (1ULL << 61))) {
                        return -1;
                }
index 6b2b92bfddb19db34001f656274f59cb24da866d..45cf67d70814ab689939241467c91ddd241340d0 100644 (file)
@@ -74,10 +74,10 @@ enum smca_bank_types {
        SMCA_PCIE,      /* PCI Express Unit */
        SMCA_PCIE_V2,
        SMCA_XGMI_PCS,  /* xGMI PCS Unit */
-       SMCA_NBIF,              /*NBIF Unit */
-       SMCA_SHUB,              /* System Hub Unit */
-       SMCA_SATA,              /* SATA Unit */
-       SMCA_USB,               /* USB Unit */
+       SMCA_NBIF,      /* NBIF Unit */
+       SMCA_SHUB,      /* System Hub Unit */
+       SMCA_SATA,      /* SATA Unit */
+       SMCA_USB,       /* USB Unit */
        SMCA_USR_DP,    /* Ultra Short Reach Data Plane Controller */
        SMCA_USR_CP,    /* Ultra Short Reach Control Plane Controller */
        SMCA_GMI_PCS,   /* GMI PCS Unit */
@@ -799,7 +799,7 @@ static struct smca_bank_name smca_names[] = {
        [SMCA_PSP ... SMCA_PSP_V2]      = { "Platform Security Processor" },
        [SMCA_SMU ... SMCA_SMU_V2]      = { "System Management Unit" },
        [SMCA_MP5]                      = { "Microprocessor 5 Unit" },
-       [SMCA_MPDMA]            = { "MPDMA Unit" },
+       [SMCA_MPDMA]                    = { "MPDMA Unit" },
        [SMCA_NBIO]                     = { "Northbridge IO Unit" },
        [SMCA_PCIE ... SMCA_PCIE_V2]    = { "PCI Express Unit" },
        [SMCA_XGMI_PCS]                 = { "Ext Global Memory Interconnect PCS Unit" },
@@ -817,7 +817,6 @@ static struct smca_bank_name smca_names[] = {
 
 void amd_decode_errcode(struct mce_event *e)
 {
-
        decode_amd_errcode(e);
 
        if (e->status & MCI_STATUS_POISON)
@@ -825,8 +824,8 @@ void amd_decode_errcode(struct mce_event *e)
 
        if (e->status & MCI_STATUS_TCC)
                mce_snprintf(e->mcistatus_msg, "Task_context_corrupt");
-
 }
+
 /*
  * To find the UMC channel represented by this bank we need to match on its
  * instance_id. The instance_id of a bank is held in the lower 32 bits of its
@@ -856,7 +855,7 @@ static int find_hbm_channel(struct mce_event *e)
        return (umc % 2) ? tmp + 4 : tmp;
 }
 
-static inline void fixup_hwid(struct mce_privm, uint32_t *hwid_mcatype)
+static inline void fixup_hwid(struct mce_priv *m, uint32_t *hwid_mcatype)
 {
        if (m->family == 0x19) {
                switch (m->model) {
@@ -965,7 +964,6 @@ void decode_smca_error(struct mce_event *e, struct mce_priv *m)
                             channel, csrow);
        }
 
-
        if (e->vdata_len) {
                uint64_t smca_config = e->vdata[2];
 
@@ -976,7 +974,6 @@ void decode_smca_error(struct mce_event *e, struct mce_priv *m)
                if (smca_config & BIT(9))
                        memcpy(e->frutext, e->vdata, 16);
        }
-
 }
 
 int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e)
@@ -984,7 +981,7 @@ int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e)
        uint64_t mcgstatus = e->mcgstatus;
 
        mce_snprintf(e->mcgstatus_msg, "mcgstatus=%lld",
-                   (long long)e->mcgstatus);
+                    (long long)e->mcgstatus);
 
        if (mcgstatus & MCG_STATUS_RIPV)
                mce_snprintf(e->mcgstatus_msg, "RIPV");
index 116df11b187d8a50718681ab8c9633fee51f4e1b..ac0dbac9c6f8ad66b41c67cb4b90c2c6bb405ea4 100644 (file)
--- a/mce-amd.c
+++ b/mce-amd.c
 static char *transaction[] = {
        "instruction", "data", "generic", "reserved"
 };
+
 /* Error codes: cache level (LL) */
 static char *cachelevel[] = {
        "reserved", "L1", "L2", "L3/generic"
 };
+
 /* Error codes: memory transaction type (RRRR) */
 static char *memtrans[] = {
        "generic", "generic read", "generic write", "data read",
        "data write", "instruction fetch", "prefetch", "evict", "snoop",
        "?", "?", "?", "?", "?", "?", "?"
 };
+
 /* Participation Processor */
 static char *partproc[] = {
        "local node origin", "local node response",
        "local node observed", "generic participation"
 };
+
 /* Timeout */
 static char *timeout[] = {
        "request didn't time out",
        "request timed out"
 };
+
 /* internal unclassified error code */
 static char *internal[] = { "reserved",
                            "reserved",
@@ -118,5 +123,4 @@ void decode_amd_errcode(struct mce_event *e)
                             PP_MSG(ec), TO_MSG(ec),
                             R4_MSG(ec), LL_MSG(ec));
        return;
-
 }
index d52c82e198fe5f727121fc47730005956322a03c..8210782a52b1286470d3b60750f3167d04d9fd43 100644 (file)
@@ -78,7 +78,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -115,7 +115,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
-               !test_prefix(7, status & 0xefff))
+           !test_prefix(7, status & 0xefff))
                return;
 
        /*
@@ -140,7 +140,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 != -1 && rank1 != -1)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 != -1)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
 }
index f7cd3b63e2dbef8af52c9a8f45938b738047eb3e..9c863d9b186f73d5e5098d79c397a836c90435f0 100644 (file)
@@ -91,7 +91,7 @@ static char *qpi[] = {
        [0x22] = "Phy detected in-band reset (no width change)",
        [0x23] = "Link failover clock failover",
        [0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
-       [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+       [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
 };
 
 static struct field qpi_mc[] = {
@@ -118,7 +118,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -160,7 +160,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
-               !test_prefix(7, status & 0xefff))
+           !test_prefix(7, status & 0xefff))
                return;
 
        /*
@@ -185,7 +185,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 != -1 && rank1 != -1)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 != -1)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
 }
index c695c620cf1a8b2b8367226bde625dea3a8bf811..71c3fb4490f74360c2d440c41f08f4be8f398458 100644 (file)
@@ -91,6 +91,7 @@ static void dunnington_decode_bus(struct mce_event *e, uint64_t status)
 static void dunnington_decode_internal(struct mce_event *e, uint64_t status)
 {
        uint32_t mca = (status >> 16) & 0xffff;
+
        if ((mca & 0xfff0) == 0)
                decode_bitfield(e, mca, dnt_front_status);
        else if ((mca & 0xf0ff) == 0)
@@ -104,6 +105,7 @@ static void dunnington_decode_internal(struct mce_event *e, uint64_t status)
 void dunnington_decode_model(struct mce_event *e)
 {
        uint64_t status = e->status;
+
        if ((status & 0xffff) == 0xe0f)
                dunnington_decode_bus(e, status);
        else if ((status & 0xffff) == (1 << 10))
index 1791a36d855f4fc688261bf0721375af2ee501c4..195f6ed8c9fbf631b2a7c4dc765cc06856c0efce 100644 (file)
@@ -23,7 +23,6 @@
 #include "ras-mce-handler.h"
 #include "bitfield.h"
 
-
 /* See IA32 SDM Vol3B Table 16-20 */
 
 static char *pcu_1[] = {
@@ -92,7 +91,7 @@ static char *qpi[] = {
        [0x22] = "Phy detected in-band reset (no width change)",
        [0x23] = "Link failover clock failover",
        [0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
-       [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+       [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
 };
 
 static struct field qpi_mc[] = {
@@ -120,7 +119,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -160,7 +159,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
-               !test_prefix(7, status & 0xefff))
+           !test_prefix(7, status & 0xefff))
                return;
 
        /*
@@ -185,7 +184,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 != -1 && rank1 != -1)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 != -1)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
 }
index 0c5bebc7fe1ce280bd0a95dbb991c135cf9d7fac..e5e6a7aaf46f154a10e132ee29c2ebd0949d670d 100644 (file)
@@ -90,7 +90,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
        struct mce_priv *mce = ras->mce_priv;
        uint64_t status = e->status;
        uint32_t mca    = status & 0xffff;
-       unsigned        rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -121,7 +121,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
-               !test_prefix(7, status & 0xefff))
+           !test_prefix(7, status & 0xefff))
                return;
 
        /*
@@ -146,7 +146,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 >= 0 && rank1 >= 0)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 >= 0)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
        else
@@ -162,7 +162,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
  * faling rank to a DIMM slot.
  */
 #if 0
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
 {
        switch (failrank) {
        case 0: case 1: case 2: case 3:
index 7062fbbd0ebfb28e37f908193225c83bfdd5966c..0e2ea809a127e419d323c393dcea32ca3d2dd6bd 100644 (file)
@@ -36,7 +36,7 @@ void knl_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan = 0;
+       unsigned int rank0 = -1, rank1 = -1, chan = 0;
 
        switch (e->bank) {
        case 5:
index ad4ce69a2890147d3cab7248e356152836e81056..18992d1b692440a33ca66d182008b385343d5a85 100644 (file)
@@ -112,9 +112,9 @@ void nehalem_decode_model(struct mce_event *e)
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
        uint64_t misc = e->misc;
-       unsigned channel, dimm;
+       unsigned int channel, dimm;
 
-       if ((mca >> 11) == 1) {         /* bus and interconnect QPI */
+       if ((mca >> 11) == 1) { /* bus and interconnect QPI */
                decode_bitfield(e, status, qpi_status);
                if (status & MCI_STATUS_MISCV) {
                        decode_numfield(e, misc, qpi_numbers);
@@ -143,6 +143,7 @@ void xeon75xx_decode_model(struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
+
        if (mca == 0x0001) { /* internal unspecified */
                decode_bitfield(e, status, internal_error_status);
                decode_numfield(e, status, internal_error_numbers);
index 5c6c3ffc949f2ce5c2cc4df7d1e8020abcaa665a..2751d342a5adf519e557934fe639726706d85434 100644 (file)
@@ -66,8 +66,8 @@ static struct field p6_shared_status[] = {
        FIELD(25, bus_queue_error_type),
        SBITFIELD(30, "internal BINIT"),
        SBITFIELD(36, "received parity error on response transaction"),
-       SBITFIELD(38, "timeout BINIT (ROB timeout)."
-                 " No micro-instruction retired for some time"),
+       SBITFIELD(38,
+                 "timeout BINIT (ROB timeout). No micro-instruction retired for some time"),
        FIELD_NULL(39),
        SBITFIELD(42, "bus transaction received hard error response"),
        SBITFIELD(43, "failure that caused IERR"),
@@ -86,7 +86,7 @@ static struct field p6old_status[] = {
        FIELD_NULL(31),
        FIELD_NULL(32),
        SBITFIELD(35, "BINIT received from external bus"),
-       SBITFIELD(37, "Received hard error reponse on split transaction (Bus BINIT)"),
+       SBITFIELD(37, "Received hard error response on split transaction (Bus BINIT)"),
        {}
 };
 
@@ -109,7 +109,7 @@ static struct numfield p6old_status_numbers[] = {
 static struct {
        int value;
        char *str;
-} p4_model []= {
+} p4_model[] = {
        {16, "FSB address parity"},
        {17, "Response hard fail"},
        {18, "Response parity"},
@@ -123,7 +123,7 @@ static struct {
 void p4_decode_model(struct mce_event *e)
 {
        uint32_t model = e->status & 0xffff0000L;
-       unsigned i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(p4_model); i++) {
                if (model & (1 << p4_model[i].value))
index e754496f0427488ce3d36df2f76468e907e1fca6..385b1254d6eb6046a2ec947039fdd07b9329e371 100644 (file)
@@ -82,7 +82,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        struct mce_priv *mce = ras->mce_priv;
        uint32_t mca = e->status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -113,7 +113,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 8 || e->bank > 11 || (e->status & MCI_STATUS_UC) ||
-               !test_prefix(7, e->status & 0xefff))
+           !test_prefix(7, e->status & 0xefff))
                return;
 
        /*
@@ -138,7 +138,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 >= 0 && rank1 >= 0)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 >= 0)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
        else
@@ -162,7 +162,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
  * can be converted to a DIMM number within a channel for systems with either
  * two or three DIMMs per channel.
  */
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
 {
        switch (failrank) {
        case 0: case 1: case 2: case 3:
index 680578a069dc21cfc1db96c16c7bdfe365f02151..37e5e11bc05e29a0bb359114435e2def89dbdf95 100644 (file)
@@ -170,7 +170,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
 {
        uint64_t status = e->status;
        uint32_t mca = status & 0xffff;
-       unsigned rank0 = -1, rank1 = -1, chan;
+       unsigned int rank0 = -1, rank1 = -1, chan;
 
        switch (e->bank) {
        case 4:
@@ -221,7 +221,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
 
        /* Ignore unless this is an corrected extended error from an iMC bank */
        if (e->bank < 13 || e->bank > 18 || (status & MCI_STATUS_UC) ||
-               !test_prefix(7, status & 0xefff))
+           !test_prefix(7, status & 0xefff))
                return;
 
        /*
@@ -246,7 +246,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
         */
        if (rank0 != -1 && rank1 != -1)
                mce_snprintf(e->mc_location, "ranks=%d and %d",
-                                    rank0, rank1);
+                            rank0, rank1);
        else if (rank0 != -1)
                mce_snprintf(e->mc_location, "rank=%d", rank0);
 }
index e59bf06a713fa2d9b09bef0b4750d9c8843493b2..f38d638eb12b876fc175d29dd42e0dcefc8819e1 100644 (file)
@@ -105,6 +105,7 @@ static void tulsa_decode_bus(struct mce_event *e, uint64_t status)
 static void tulsa_decode_internal(struct mce_event *e, uint64_t status)
 {
        uint32_t mca = (status >> 16) & 0xffff;
+
        if ((mca & 0xfff0) == 0)
                decode_bitfield(e, mca, tls_front_status);
        else if ((mca & 0xf0ff) == 0)
index 18a907285bf663bbf9fb5626c2c0cc81c4138451..7f48cc4b03750dc3cec47e840c12e6e0201d68f7 100644 (file)
@@ -57,8 +57,7 @@
 #define BUS_PP_MASK      0x600 /*bit 9, bit 10*/
 #define BUS_PP_SHIFT     0x9
 
-#define MCG_TES_P       (1ULL<<11)   /* Yellow bit cache threshold supported */
-
+#define MCG_TES_P       BIT_ULL(11)   /* Yellow bit cache threshold supported */
 
 static char *TT[] = {
        "Instruction",
@@ -76,8 +75,8 @@ static char *LL[] = {
 
 static struct {
        uint8_t value;
-       charstr;
-} RRRR [] = {
+       char *str;
+} RRRR[] = {
        {0, "Generic"},
        {1, "Read"},
        {2, "Write" },
@@ -121,7 +120,7 @@ static char *mca_msg[] = {
 static char *tracking_msg[] = {
        [1] = "green",
        [2] = "yellow",
-       [3] ="res3"
+       [3] = "res3"
 };
 
 static const char *arstate[4] = {
@@ -157,9 +156,9 @@ static void decode_memory_controller(struct mce_event *e, uint32_t status)
                sprintf(channel, "%u", status & 0xf);
 
        mce_snprintf(e->error_msg, "MEMORY CONTROLLER %s_CHANNEL%s_ERR",
-                   mmm_mnemonic[(status >> 4) & 7], channel);
+                    mmm_mnemonic[(status >> 4) & 7], channel);
        mce_snprintf(e->error_msg, "Transaction: %s",
-                   mmm_desc[(status >> 4) & 7]);
+                    mmm_desc[(status >> 4) & 7]);
 }
 
 static void decode_termal_bank(struct mce_event *e)
@@ -207,7 +206,7 @@ static void bank_name(struct mce_event *e)
 
 static char *get_RRRR_str(uint8_t rrrr)
 {
-       unsigned i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(RRRR); i++) {
                if (RRRR[i].value == rrrr) {
@@ -220,7 +219,7 @@ static char *get_RRRR_str(uint8_t rrrr)
 
 #define decode_attr(arr, val) ({                               \
        char *__str;                                            \
-       if ((unsigned)(val) >= ARRAY_SIZE(arr))                 \
+       if ((unsigned int)(val) >= ARRAY_SIZE(arr))                     \
                __str = "UNKNOWN";                              \
        else                                                    \
                __str = (arr)[val];                             \
@@ -248,17 +247,17 @@ static void decode_mca(struct mce_event *e, uint64_t track, int *ismemerr)
                             decode_attr(LL, mca & 3));
        } else if (test_prefix(4, mca)) {
                mce_snprintf(e->mcastatus_msg, "%s TLB %s Error",
-                               decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
-                               decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
+                            decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
+                            decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
        } else if (test_prefix(8, mca)) {
-               unsigned typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
-               unsigned levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
+               unsigned int typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
+               unsigned int levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
                char *type = decode_attr(TT, typenum);
                char *level = decode_attr(LL, levelnum);
+
                mce_snprintf(e->mcastatus_msg,
                             "%s CACHE %s %s Error", type, level,
-                            get_RRRR_str((mca & CACHE_RRRR_MASK) >>
-                                             CACHE_RRRR_SHIFT));
+                            get_RRRR_str((mca & CACHE_RRRR_MASK) >> CACHE_RRRR_SHIFT));
 #if 0
                /* FIXME: We shouldn't mix parsing with actions */
                if (track == 2)
@@ -313,15 +312,13 @@ static void decode_mci(struct mce_event *e, int *ismemerr)
        else
                mce_snprintf(e->mcistatus_msg, "Corrected_error");
 
-
        if (e->status & MCI_STATUS_EN)
                mce_snprintf(e->mcistatus_msg, "Error_enabled");
 
-
        if (e->status & MCI_STATUS_PCC)
                mce_snprintf(e->mcistatus_msg, "Processor_context_corrupt");
 
-       if (e->status & (MCI_STATUS_S|MCI_STATUS_AR))
+       if (e->status & (MCI_STATUS_S | MCI_STATUS_AR))
                mce_snprintf(e->mcistatus_msg, "%s",
                             arstate[(e->status >> 55) & 3]);
 
@@ -350,14 +347,14 @@ int parse_intel_event(struct ras_events *ras, struct mce_event *e)
 
        /* Check if the error is at the memory controller */
        if (((e->status & 0xffff) >> 7) == 1) {
-               unsigned corr_err_cnt;
+               unsigned int corr_err_cnt;
 
                corr_err_cnt = EXTRACT(e->status, 38, 52);
                mce_snprintf(e->mc_location, "n_errors=%d", corr_err_cnt);
        }
 
        if (test_prefix(11, (e->status & 0xffffL))) {
-               switch(mce->cputype) {
+               switch (mce->cputype) {
                case CPU_P6OLD:
                        p6old_decode_model(e);
                        break;
@@ -375,7 +372,7 @@ int parse_intel_event(struct ras_events *ras, struct mce_event *e)
                        break;
                }
        }
-       switch(mce->cputype) {
+       switch (mce->cputype) {
        case CPU_NEHALEM:
                nehalem_decode_model(e);
                break;
@@ -447,18 +444,18 @@ static int domsr(int cpu, int msr, int bit)
                        return -EINVAL;
                }
        }
-       if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+       if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
                log(ALL, LOG_ERR,
                    "Cannot read MSR_ERROR_CONTROL from %s\n", fpath);
                return -EINVAL;
        }
        data |= bit;
-       if (pwrite(fd, &data, sizeof data, msr) != sizeof data) {
+       if (pwrite(fd, &data, sizeof(data), msr) != sizeof(data)) {
                log(ALL, LOG_ERR,
                    "Cannot write MSR_ERROR_CONTROL to %s\n", fpath);
                return -EINVAL;
        }
-       if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+       if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
                log(ALL, LOG_ERR,
                    "Cannot re-read MSR_ERROR_CONTROL from %s\n", fpath);
                return -EINVAL;
@@ -472,7 +469,7 @@ static int domsr(int cpu, int msr, int bit)
        return 0;
 }
 
-int set_intel_imc_log(enum cputype cputype, unsigned ncpus)
+int set_intel_imc_log(enum cputype cputype, unsigned int ncpus)
 {
        int cpu, msr, bit, rc;
 
index 21331a182978af3d236d27fb5afd3037df81ff6a..905e0c57cf9418e03f169ee7c26c4acd7ec69cea 100644 (file)
@@ -31,6 +31,7 @@ static const char * const disp_payload0_err_reg_name[] = {
        "MISC2:",
        "MISC3:",
 };
+
 /*PCIe AER Error Payload Type 1*/
 static const char * const disp_payload1_err_reg_name[] = {
        "Error Type:",
@@ -86,7 +87,6 @@ static const char * const err_cpm_sub_type[] = {
        "ARMv8 Core 1",
 };
 
-
 static const char * const err_mcu_sub_type[] = {
        "ERR0",
        "ERR1",
@@ -155,8 +155,6 @@ static char *err_smmu_sub_type(int etype)
        return "unknown error";
 }
 
-
-
 static const char * const err_pcie_aer_sub_type[] = {
        "Root Port",
        "Device",
@@ -173,7 +171,6 @@ static char *err_peci_rasdp_sub_type(int etype)
        return "unknown error";
 }
 
-
 static const char * const err_ocm_sub_type[] = {
        "ERR0",
        "ERR1",
@@ -327,7 +324,7 @@ static const struct amp_ras_type_info amp_payload_error_type[] = {
 
 /*get the error type name*/
 static const char *oem_type_name(const struct amp_ras_type_info *info,
-                               uint8_t type_id)
+                                uint8_t type_id)
 {
        const struct amp_ras_type_info *type = &info[0];
 
@@ -350,7 +347,7 @@ static const char *oem_subtype_name(const struct amp_ras_type_info *info,
 
                if (type->id != type_id)
                        continue;
-               if (type->sub == NULL)
+               if (!type->sub)
                        return type->name;
                if (sub_type_id >= type->sub_num)
                        return "unknown";
@@ -477,7 +474,7 @@ static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
 }
 
 static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *name)
+                             const char *name)
 {
        int rc;
 
@@ -502,37 +499,37 @@ static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
 
 /*save all Ampere Specific Error Payload type 0 to sqlite3 database*/
 static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
+                                   const char *type_str, const char *subtype_str,
                                const struct amp_payload0_type_sec *err)
 {
-       if (ev_decoder != NULL) {
+       if (ev_decoder) {
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
+                               AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
+                               AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
 
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
+                               AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
 
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD0_FIELD_SOCKET_NUM,
+                               AMP_PAYLOAD0_FIELD_SOCKET_NUM,
                        SOCKET_NUM(err->instance), NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
+                               AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD0_FIELD_ADDR_REG,
+                               AMP_PAYLOAD0_FIELD_ADDR_REG,
                        err->err_addr, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD0_FIELD_MISC0,
+                               AMP_PAYLOAD0_FIELD_MISC0,
                        err->err_misc_0, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD0_FIELD_MISC1,
+                               AMP_PAYLOAD0_FIELD_MISC1,
                        err->err_misc_1, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD0_FIELD_MISC2,
+                               AMP_PAYLOAD0_FIELD_MISC2,
                        err->err_misc_2, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD0_FIELD_MISC3,
+                               AMP_PAYLOAD0_FIELD_MISC3,
                        err->err_misc_3, NULL);
                store_amp_err_data(ev_decoder, "amp_payload0_event_tab");
        }
@@ -540,10 +537,10 @@ static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
 
 /*save all Ampere Specific Error Payload type 1 to sqlite3 database*/
 static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
+                                   const char *type_str, const char *subtype_str,
                                const struct amp_payload1_type_sec *err)
 {
-       if (ev_decoder != NULL) {
+       if (ev_decoder) {
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
                                AMP_PAYLOAD1_FIELD_TYPE, 0, type_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
@@ -590,45 +587,45 @@ static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
 
 /*save all Ampere Specific Error Payload type 2 to sqlite3 database*/
 static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
-                               const struct amp_payload2_type_sec *err)
+                                   const char *type_str, const char *subtype_str,
+                                   const struct amp_payload2_type_sec *err)
 {
-       if (ev_decoder != NULL) {
+       if (ev_decoder) {
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
+                               AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
+                               AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
+                               AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_SOCKET_NUM,
+                               AMP_PAYLOAD2_FIELD_SOCKET_NUM,
                        SOCKET_NUM(err->instance), NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
+                               AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
                        err->ce_register, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_CE_LOACATION,
+                               AMP_PAYLOAD2_FIELD_CE_LOACATION,
                        err->ce_location, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_CE_ADDR,
+                               AMP_PAYLOAD2_FIELD_CE_ADDR,
                        err->ce_addr, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
+                               AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
                        err->ue_register, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_UE_LOCATION,
+                               AMP_PAYLOAD2_FIELD_UE_LOCATION,
                        err->ue_location, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_UE_ADDR,
+                               AMP_PAYLOAD2_FIELD_UE_ADDR,
                        err->ue_addr, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD2_FIELD_RESERVED1,
+                               AMP_PAYLOAD2_FIELD_RESERVED1,
                        err->reserved1, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD2_FIELD_RESERVED2,
+                               AMP_PAYLOAD2_FIELD_RESERVED2,
                        err->reserved2, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD2_FIELD_RESERVED3,
+                               AMP_PAYLOAD2_FIELD_RESERVED3,
                        err->reserved3, NULL);
                store_amp_err_data(ev_decoder, "amp_payload2_event_tab");
        }
@@ -636,36 +633,36 @@ static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
 
 /*save all Ampere Specific Error Payload type 3 to sqlite3 database*/
 static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
+                                   const char *type_str, const char *subtype_str,
                                const struct amp_payload3_type_sec *err)
 {
-       if (ev_decoder != NULL) {
+       if (ev_decoder) {
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
+                               AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                       AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
+                               AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
+                               AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD3_FIELD_SOCKET_NUM,
+                               AMP_PAYLOAD3_FIELD_SOCKET_NUM,
                        SOCKET_NUM(err->instance), NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
                        err->fw_speci_data0, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
                        err->fw_speci_data1, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
                        err->fw_speci_data2, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
                        err->fw_speci_data3, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
                        err->fw_speci_data4, NULL);
                record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
-                       AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
+                               AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
                        err->fw_speci_data5, NULL);
                store_amp_err_data(ev_decoder, "amp_payload3_event_tab");
        }
@@ -679,26 +676,26 @@ static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
 }
 
 static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
-                               const struct amp_payload0_type_sec *err)
+                                   const char *type_str, const char *subtype_str,
+                                   const struct amp_payload0_type_sec *err)
 {
 }
 
 static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
-                               const struct amp_payload1_type_sec *err)
+                                   const char *type_str, const char *subtype_str,
+                                   const struct amp_payload1_type_sec *err)
 {
 }
 
 static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
-                               const struct amp_payload2_type_sec *err)
+                                   const char *type_str, const char *subtype_str,
+                                   const struct amp_payload2_type_sec *err)
 {
 }
 
 static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *type_str, const char *subtype_str,
-                               const struct amp_payload3_type_sec *err)
+                                   const char *type_str, const char *subtype_str,
+                                   const struct amp_payload3_type_sec *err)
 {
 }
 
@@ -711,7 +708,7 @@ static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder, char *name)
 /*decode ampere specific error payload type 0, the CPU's data is save*/
 /*to sqlite by ras-arm-handler, others are saved by this function.*/
 void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                               struct trace_seq *s,
+                                 struct trace_seq *s,
                                const struct amp_payload0_type_sec *err)
 {
        char buf[AMP_PAYLOAD0_BUF_LEN];
@@ -798,8 +795,8 @@ void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
 
 /*decode ampere specific error payload type 1 and save to sqlite db*/
 static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                                       struct trace_seq *s,
-                                       const struct amp_payload1_type_sec *err)
+                                        struct trace_seq *s,
+                                        const struct amp_payload1_type_sec *err)
 {
        char buf[AMP_PAYLOAD0_BUF_LEN];
        char *p = buf;
@@ -882,8 +879,8 @@ static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
 
 /*decode ampere specific error payload type 2 and save to sqlite db*/
 static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                                       struct trace_seq *s,
-                                       const struct amp_payload2_type_sec *err)
+                                        struct trace_seq *s,
+                                        const struct amp_payload2_type_sec *err)
 {
        char buf[AMP_PAYLOAD0_BUF_LEN];
        char *p = buf;
@@ -898,7 +895,7 @@ static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
                subtype_str = err_peci_rasdp_sub_type(err->subtype);
        else
                subtype_str  = oem_subtype_name(amp_payload_error_type,
-                                              TYPE(err->type), err->subtype);
+                                               TYPE(err->type), err->subtype);
        //display error type
        p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
        p += snprintf(p, end - p, " %s\n", type_str);
@@ -967,8 +964,8 @@ static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
 
 /*decode ampere specific error payload type 3 and save to sqlite db*/
 static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                                       struct trace_seq *s,
-                                       const struct amp_payload3_type_sec *err)
+                                        struct trace_seq *s,
+                                        const struct amp_payload3_type_sec *err)
 {
        char buf[AMP_PAYLOAD0_BUF_LEN];
        char *p = buf;
@@ -984,7 +981,6 @@ static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
        p += snprintf(p, end - p, " %s\n", type_str);
 
-
        //display error subtype
        p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
        p += snprintf(p, end - p, " %s\n", subtype_str);
@@ -1069,13 +1065,13 @@ static int decode_amp_oem_type_error(struct ras_events *ras,
                if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
                                            &db_tab) != SQLITE_OK) {
                        trace_seq_printf(s,
-                                       "create sql %s fail\n",
-                                       sqlite3_table_list[payload_type]);
+                                        "create sql %s fail\n",
+                                        sqlite3_table_list[payload_type]);
                        return -1;
                }
        }
        record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
-                          id, 0, event->timestamp);
+                       id, 0, event->timestamp);
 #endif
 
        if (payload_type == PAYLOAD_TYPE_0) {
index 08998125de58353b78840aa5b8cbb04e9a9b560a..e482a7adcf7409912a2b215b8de1d19557b97b5a 100644 (file)
@@ -453,7 +453,7 @@ static const char *oem_submodule_name(const struct hisi_module_info *info,
                if (module->id != module_id)
                        continue;
 
-               if (module->sub == NULL)
+               if (!module->sub)
                        return module->name;
 
                if (sub_module_id >= module->sub_num)
@@ -675,7 +675,7 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
                                        struct ras_non_standard_event *event)
 {
        const struct hisi_oem_type1_err_sec *err =
-                       (struct hisi_oem_type1_err_sec*)event->error;
+                       (struct hisi_oem_type1_err_sec *)event->error;
 
        if (err->val_bits == 0) {
                trace_seq_printf(s, "%s: no valid error information\n",
index 7296d280307370d4ca2255602369bb23a2f6c934..e9ea5df80d4b6f20a823b1ff98ab02835c2cb0c5 100644 (file)
@@ -88,10 +88,10 @@ struct hisi_event {
 
 #ifdef HAVE_SQLITE3
 void record_vendor_data(struct ras_ns_ev_decoder *ev_decoder,
-                              enum hisi_oem_data_type data_type,
+                       enum hisi_oem_data_type data_type,
                               int id, int64_t data, const char *text)
 {
-       if (ev_decoder->stmt_dec_record == NULL)
+       if (!ev_decoder->stmt_dec_record)
                return;
 
        switch (data_type) {
@@ -111,7 +111,7 @@ int step_vendor_data_tab(struct ras_ns_ev_decoder *ev_decoder, const char *name)
 {
        int rc;
 
-       if (ev_decoder->stmt_dec_record == NULL)
+       if (!ev_decoder->stmt_dec_record)
                return 0;
 
        rc = sqlite3_step(ev_decoder->stmt_dec_record);
@@ -171,13 +171,13 @@ static const struct db_table_descriptor hisi_common_section_tab = {
 };
 #endif
 
-static const charsoc_desc[] = {
+static const char *soc_desc[] = {
        "Kunpeng916",
        "Kunpeng920",
        "Kunpeng930",
 };
 
-static const charmodule_name[] = {
+static const char *module_name[] = {
        "MN",
        "PLL",
        "SLLC",
@@ -221,9 +221,9 @@ static const char* module_name[] = {
        "HBMC",
 };
 
-static const charget_soc_desc(uint8_t soc_id)
+static const char *get_soc_desc(uint8_t soc_id)
 {
-       if (soc_id >= sizeof(soc_desc)/sizeof(char *))
+       if (soc_id >= sizeof(soc_desc) / sizeof(char *))
                return "unknown";
 
        return soc_desc[soc_id];
@@ -232,7 +232,7 @@ static const char* get_soc_desc(uint8_t soc_id)
 static void decode_module(struct ras_ns_ev_decoder *ev_decoder,
                          struct hisi_event *event, uint8_t module_id)
 {
-       if (module_id >= sizeof(module_name)/sizeof(char *)) {
+       if (module_id >= sizeof(module_name) / sizeof(char *)) {
                HISI_SNPRINTF(event->error_msg, "module=unknown(id=%hhu) ", module_id);
                record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_TEXT,
                                   HISI_COMMON_FIELD_MODULE_ID,
@@ -246,7 +246,7 @@ static void decode_module(struct ras_ns_ev_decoder *ev_decoder,
 }
 
 static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder,
-                                         const struct hisi_common_error_section *err,
+                                          const struct hisi_common_error_section *err,
                                          struct hisi_event *event)
 {
        HISI_SNPRINTF(event->error_msg, "[ table_version=%hhu", err->version);
index d909d7a4236de76bbc2f98920cb2b96e8d46f8c7..cb0a78d5224e8caaff5a9daa51f39ddcb9c8cf41 100644 (file)
@@ -24,7 +24,7 @@
 #define JM_SNPRINTF    mce_snprintf
 
 static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
-                               enum jm_oem_data_type data_type,
+                          enum jm_oem_data_type data_type,
                                int id, int64_t data, const char *text);
 
 struct jm_event {
@@ -168,7 +168,6 @@ static const char * const iosub_module_desc[] = {
        "OTHER",
 };
 
-
 static const char * const scp_module_desc[] = {
        "SRAM",
        "WDT",
@@ -184,6 +183,7 @@ static const char * const imu_module_desc[] = {
        "SRAM",
        "WDT",
 };
+
 /* JaguarMicro DPE sub system module definitions */
 #define JM_SUBSYS_DPE_MOD_EPG          0
 #define JM_SUBSYS_DPE_MOD_PIPE         1
@@ -301,7 +301,7 @@ static const char * const default_dev_desc[] = {
 
 static const char *get_jm_soc_desc(uint8_t soc_id)
 {
-       if (soc_id >= sizeof(soc_desc)/sizeof(char *))
+       if (soc_id >= sizeof(soc_desc) / sizeof(char *))
                return "unknown";
 
        return soc_desc[soc_id];
@@ -309,7 +309,7 @@ static const char *get_jm_soc_desc(uint8_t soc_id)
 
 static const char *get_jm_subsystem_desc(uint8_t subsys_id)
 {
-       if (subsys_id >= sizeof(subsystem_desc)/sizeof(char *))
+       if (subsys_id >= sizeof(subsystem_desc) / sizeof(char *))
                return "unknown";
 
        return subsystem_desc[subsys_id];
@@ -323,54 +323,54 @@ static const char *get_jm_module_desc(uint8_t subsys_id, uint8_t mod_id)
        switch (subsys_id) {
        case JM_SUB_SYS_CMN:
                module = cmn_module_desc;
-               tbl_size = sizeof(cmn_module_desc)/sizeof(char *);
+               tbl_size = sizeof(cmn_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_DDRH:
        case JM_SUB_SYS_DDRV:
                module = ddr_module_desc;
-               tbl_size = sizeof(ddr_module_desc)/sizeof(char *);
+               tbl_size = sizeof(ddr_module_desc) / sizeof(char *);
                break;
 
        case JM_SUB_SYS_GIC:
                module = gic_module_desc;
-               tbl_size = sizeof(gic_module_desc)/sizeof(char *);
+               tbl_size = sizeof(gic_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_IOSUB:
                module = iosub_module_desc;
-               tbl_size = sizeof(iosub_module_desc)/sizeof(char *);
+               tbl_size = sizeof(iosub_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_SCP:
                module = scp_module_desc;
-               tbl_size = sizeof(scp_module_desc)/sizeof(char *);
+               tbl_size = sizeof(scp_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_MCP:
                module = mcp_module_desc;
-               tbl_size = sizeof(mcp_module_desc)/sizeof(char *);
+               tbl_size = sizeof(mcp_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_IMU0:
        case JM_SUB_SYS_IMU1:
                module = imu_module_desc;
-               tbl_size = sizeof(imu_module_desc)/sizeof(char *);
+               tbl_size = sizeof(imu_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_DPE:
                module = dpe_module_desc;
-               tbl_size = sizeof(dpe_module_desc)/sizeof(char *);
+               tbl_size = sizeof(dpe_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_RPE:
                module = rpe_module_desc;
-               tbl_size = sizeof(rpe_module_desc)/sizeof(char *);
+               tbl_size = sizeof(rpe_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_PSUB:
                module = psub_module_desc;
-               tbl_size = sizeof(psub_module_desc)/sizeof(char *);
+               tbl_size = sizeof(psub_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_HAC:
                module = hac_module_desc;
-               tbl_size = sizeof(hac_module_desc)/sizeof(char *);
+               tbl_size = sizeof(hac_module_desc) / sizeof(char *);
                break;
        case JM_SUB_SYS_TCM:
                module = tcm_module_desc;
-               tbl_size = sizeof(tcm_module_desc)/sizeof(char *);
+               tbl_size = sizeof(tcm_module_desc) / sizeof(char *);
                break;
 
        default:
@@ -378,7 +378,7 @@ static const char *get_jm_module_desc(uint8_t subsys_id, uint8_t mod_id)
                break;
        }
 
-       if ((module == NULL) || (mod_id >= tbl_size))
+       if ((!module) || (mod_id >= tbl_size))
                return "unknown";
 
        return module[mod_id];
@@ -391,43 +391,42 @@ static const char *get_jm_submod_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t
 
        if (subsys_id == JM_SUB_SYS_IOSUB && mod_id == JM_SUBSYS_IOSUB_MOD_SMMU) {
                sub_module = iosub_smmu_sub_desc;
-               tbl_size = sizeof(iosub_smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(iosub_smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_IOSUB && mod_id == JM_SUBSYS_IOSUB_MOD_OTHER) {
                sub_module = iosub_other_sub_desc;
-               tbl_size = sizeof(iosub_other_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(iosub_other_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_DPE && mod_id == JM_SUBSYS_DPE_MOD_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_RPE && mod_id == JM_SUBSYS_RPE_MOD_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_PCIE0) {
                sub_module = psub_pcie0_sub_desc;
-               tbl_size = sizeof(psub_pcie0_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(psub_pcie0_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_X2RC_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_X16RC_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_SDMA_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else if (subsys_id == JM_SUB_SYS_TCM && mod_id == JM_SUBSYS_TCM_MOD_SMMU) {
                sub_module = smmu_sub_desc;
-               tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+               tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
        } else {
                sub_module = NULL;
                tbl_size = 0;
        }
 
-       if ((sub_module == NULL) || (sub_id >= tbl_size))
+       if ((!sub_module) || (sub_id >= tbl_size))
                return "unknown";
 
        return sub_module[sub_id];
 }
 
-
 static const char *get_jm_dev_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t sub_id)
 {
        if (subsys_id == JM_SUB_SYS_CSUB)
@@ -440,7 +439,6 @@ static const char *get_jm_dev_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t su
                return default_dev_desc[0];
 }
 
-
 #define JM_ERR_SEVERITY_NFE            0
 #define JM_ERR_SEVERITY_FE             1
 #define JM_ERR_SEVERITY_CE             2
@@ -461,82 +459,78 @@ static inline char *jm_err_severity(uint8_t err_sev)
 }
 
 static void decode_jm_common_sec_head(struct ras_ns_ev_decoder *ev_decoder,
-                                       const struct jm_common_sec_head *err,
+                                     const struct jm_common_sec_head *err,
                                        struct jm_event *event)
 {
        if (err->val_bits & BIT(JM_COMMON_VALID_SOC_ID)) {
                JM_SNPRINTF(event->error_msg, "[ table_version=%hhu decode_version:%hhu",
-                                       err->version, PAYLOAD_VERSION);
+                           err->version, PAYLOAD_VERSION);
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                                       JM_PAYLOAD_FIELD_VERSION,
+                              JM_PAYLOAD_FIELD_VERSION,
                                        err->version, NULL);
        }
 
        if (err->val_bits & BIT(JM_COMMON_VALID_SOC_ID)) {
                JM_SNPRINTF(event->error_msg, " soc=%s", get_jm_soc_desc(err->soc_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                               JM_PAYLOAD_FIELD_SOC_ID,
+                              JM_PAYLOAD_FIELD_SOC_ID,
                                err->soc_id, NULL);
        }
 
        if (err->val_bits & BIT(JM_COMMON_VALID_SUBSYSTEM_ID)) {
                JM_SNPRINTF(event->error_msg, " sub system=%s",
-                                       get_jm_subsystem_desc(err->subsystem_id));
+                           get_jm_subsystem_desc(err->subsystem_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                                       JM_PAYLOAD_FIELD_SUB_SYS,
+                              JM_PAYLOAD_FIELD_SUB_SYS,
                                        0, get_jm_subsystem_desc(err->subsystem_id));
        }
 
        if (err->val_bits & BIT(JM_COMMON_VALID_MODULE_ID)) {
                JM_SNPRINTF(event->error_msg, " module=%s",
-                               get_jm_module_desc(err->subsystem_id, err->module_id));
+                           get_jm_module_desc(err->subsystem_id, err->module_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                               JM_PAYLOAD_FIELD_MODULE,
+                              JM_PAYLOAD_FIELD_MODULE,
                                0, get_jm_module_desc(err->subsystem_id, err->module_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                               JM_PAYLOAD_FIELD_MODULE_ID,
+                              JM_PAYLOAD_FIELD_MODULE_ID,
                                err->module_id, NULL);
        }
 
        if (err->val_bits & BIT(JM_COMMON_VALID_SUBMODULE_ID)) {
                JM_SNPRINTF(event->error_msg, " sub module=%s",
-                       get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
+                           get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                       JM_PAYLOAD_FIELD_SUB_MODULE,
+                              JM_PAYLOAD_FIELD_SUB_MODULE,
                        0,
                        get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                       JM_PAYLOAD_FIELD_MODULE_ID,
+                              JM_PAYLOAD_FIELD_MODULE_ID,
                        err->submodule_id, NULL);
        }
 
-
        if (err->val_bits & BIT(JM_COMMON_VALID_DEV_ID)) {
                JM_SNPRINTF(event->error_msg, " dev=%s",
-                       get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
+                           get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                       JM_PAYLOAD_FIELD_DEV,
+                              JM_PAYLOAD_FIELD_DEV,
                        0, get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                                       JM_PAYLOAD_FIELD_DEV_ID,
+                              JM_PAYLOAD_FIELD_DEV_ID,
                                        err->dev_id, NULL);
-
        }
 
-
        if (err->val_bits & BIT(JM_COMMON_VALID_ERR_TYPE)) {
                JM_SNPRINTF(event->error_msg, " err_type=%hu", err->err_type);
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
-                                       JM_PAYLOAD_FIELD_ERR_TYPE,
+                              JM_PAYLOAD_FIELD_ERR_TYPE,
                                        err->err_type, NULL);
        }
 
-
        if (err->val_bits & BIT(JM_COMMON_VALID_ERR_SEVERITY)) {
                JM_SNPRINTF(event->error_msg, " err_severity=%s",
-                                       jm_err_severity(err->err_severity));
+                           jm_err_severity(err->err_severity));
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                                       JM_PAYLOAD_FIELD_ERR_SEVERITY,
+                              JM_PAYLOAD_FIELD_ERR_SEVERITY,
                                        0, jm_err_severity(err->err_severity));
        }
 
@@ -544,7 +538,7 @@ static void decode_jm_common_sec_head(struct ras_ns_ev_decoder *ev_decoder,
 }
 
 static void decode_jm_common_sec_tail(struct ras_ns_ev_decoder *ev_decoder,
-                                       const struct jm_common_sec_tail *err,
+                                     const struct jm_common_sec_tail *err,
                                        struct jm_event *event, uint32_t val_bits)
 {
        if (val_bits & BIT(JM_COMMON_VALID_REG_ARRAY_SIZE) && err->reg_array_size > 0) {
@@ -553,7 +547,7 @@ static void decode_jm_common_sec_tail(struct ras_ns_ev_decoder *ev_decoder,
                JM_SNPRINTF(event->reg_msg, "Extended Register Dump:");
                for (i = 0; i < err->reg_array_size; i++) {
                        JM_SNPRINTF(event->reg_msg, "reg%02d=0x%08x",
-                                       i, err->reg_array[i]);
+                                   i, err->reg_array[i]);
                }
        }
 }
@@ -586,7 +580,7 @@ static const struct db_table_descriptor jm_payload0_event_tab = {
 
 /*Save data with different type into sqlite3 db*/
 static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
-                               enum jm_oem_data_type data_type, int id,
+                          enum jm_oem_data_type data_type, int id,
                                int64_t data, const char *text)
 {
        switch (data_type) {
@@ -598,7 +592,7 @@ static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
                break;
        case JM_OEM_DATA_TYPE_TEXT:
                sqlite3_bind_text(ev_decoder->stmt_dec_record, id, text,
-                                               -1, NULL);
+                                 -1, NULL);
                break;
        default:
                break;
@@ -606,62 +600,60 @@ static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
 }
 
 static int store_jm_err_data(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *tab_name)
+                            const char *tab_name)
 {
        int rc;
 
        rc = sqlite3_step(ev_decoder->stmt_dec_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
                log(TERM, LOG_ERR,
-                       "Failed to do step on sqlite. Table = %s error = %d\n",
+                   "Failed to do step on sqlite. Table = %s error = %d\n",
                        tab_name, rc);
 
        rc = sqlite3_reset(ev_decoder->stmt_dec_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
                log(TERM, LOG_ERR,
-                       "Failed to reset on sqlite. Table = %s error = %d\n",
+                   "Failed to reset on sqlite. Table = %s error = %d\n",
                        tab_name, rc);
 
        rc = sqlite3_clear_bindings(ev_decoder->stmt_dec_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
                log(TERM, LOG_ERR,
-                       "Failed to clear bindings on sqlite. Table = %s error = %d\n",
+                   "Failed to clear bindings on sqlite. Table = %s error = %d\n",
                        tab_name, rc);
 
        return rc;
 }
 
-
 /*save all JaguarMicro Specific Error Payload type 0 to sqlite3 database*/
 static void record_jm_payload_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *reg_str)
+                                 const char *reg_str)
 {
-       if (ev_decoder != NULL) {
+       if (ev_decoder) {
                record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                       JM_PAYLOAD_FIELD_REGS_DUMP, 0, reg_str);
+                              JM_PAYLOAD_FIELD_REGS_DUMP, 0, reg_str);
                store_jm_err_data(ev_decoder, "jm_payload0_event_tab");
        }
 }
 
 #else
 static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
-                               enum jm_oem_data_type data_type,
+                          enum jm_oem_data_type data_type,
                                int id, int64_t data, const char *text)
 {
 }
 
 static void record_jm_payload_err(struct ras_ns_ev_decoder *ev_decoder,
-                               const char *reg_str)
+                                 const char *reg_str)
 {
 }
 
 #endif
 
-
 /*decode JaguarMicro specific error payload type 0, the CPU's data is save*/
 /*to sqlite by ras-arm-handler, others are saved by this function.*/
 static void decode_jm_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                               struct trace_seq *s,
+                                       struct trace_seq *s,
                                const struct jm_payload0_type_sec *err)
 {
        int i = 0;
@@ -781,11 +773,9 @@ static void decode_jm_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        JM_SNPRINTF(jmevent.reg_msg, " %s", disp_payload1_err_reg_name[i++]);
        JM_SNPRINTF(jmevent.reg_msg, " 0x%x\n", err->errgen);
 
-
        trace_seq_printf(s, "Register Dump:\n");
        decode_jm_common_sec_tail(ev_decoder, common_tail, &jmevent, common_head->val_bits);
 
-
        record_jm_payload_err(ev_decoder, jmevent.reg_msg);
 
        trace_seq_printf(s, "%s\n", jmevent.reg_msg);
@@ -808,7 +798,6 @@ static void decode_jm_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        decode_jm_common_sec_head(ev_decoder, common_head, &jmevent);
        trace_seq_printf(s, "%s\n", jmevent.error_msg);
 
-
        //display ecc_1bit_error_interrupt_low
        JM_SNPRINTF(jmevent.reg_msg,  " %s", disp_payload2_err_reg_name[i++]);
        JM_SNPRINTF(jmevent.reg_msg,  " 0x%x; ", err->ecc_1bit_int_low);
@@ -825,7 +814,6 @@ static void decode_jm_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        JM_SNPRINTF(jmevent.reg_msg,  " %s", disp_payload2_err_reg_name[i++]);
        JM_SNPRINTF(jmevent.reg_msg,  " 0x%x\n", err->ecc_2bit_int_high);
 
-
        trace_seq_printf(s, "Register Dump:\n");
        decode_jm_common_sec_tail(ev_decoder, common_tail, &jmevent, common_head->val_bits);
 
@@ -915,7 +903,6 @@ static void decode_jm_payload5_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        trace_seq_printf(s, "%s\n", jmevent.reg_msg);
 }
 
-
 /*decode JaguarMicro specific error payload type 6 and save to sqlite db*/
 static void decode_jm_payload6_err_regs(struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
@@ -973,7 +960,7 @@ static void decode_jm_payload6_err_regs(struct ras_ns_ev_decoder *ev_decoder,
 
 /* error data decoding functions */
 static int decode_jm_oem_type_error(struct ras_events *ras,
-                                       struct ras_ns_ev_decoder *ev_decoder,
+                                   struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event,
                                        int payload_type)
@@ -981,7 +968,7 @@ static int decode_jm_oem_type_error(struct ras_events *ras,
        int id = JM_PAYLOAD_FIELD_TIMESTAMP;
 
        record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
-                          id, 0, event->timestamp);
+                      id, 0, event->timestamp);
 
        if (payload_type == PAYLOAD_TYPE_0) {
                const struct jm_payload0_type_sec *err =
@@ -1013,7 +1000,7 @@ static int decode_jm_oem_type_error(struct ras_events *ras,
 
 /* error type0 data decoding functions */
 static int decode_jm_oem_type0_error(struct ras_events *ras,
-                                       struct ras_ns_ev_decoder *ev_decoder,
+                                    struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event)
 {
@@ -1022,15 +1009,16 @@ static int decode_jm_oem_type0_error(struct ras_events *ras,
 
 /* error type1 data decoding functions */
 static int decode_jm_oem_type1_error(struct ras_events *ras,
-                                       struct ras_ns_ev_decoder *ev_decoder,
+                                    struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event)
 {
        return decode_jm_oem_type_error(ras, ev_decoder, s, event, PAYLOAD_TYPE_1);
 }
+
 /* error type2 data decoding functions */
 static int decode_jm_oem_type2_error(struct ras_events *ras,
-                                       struct ras_ns_ev_decoder *ev_decoder,
+                                    struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event)
 {
@@ -1039,7 +1027,7 @@ static int decode_jm_oem_type2_error(struct ras_events *ras,
 
 /* error type5 data decoding functions */
 static int decode_jm_oem_type5_error(struct ras_events *ras,
-                                        struct ras_ns_ev_decoder *ev_decoder,
+                                    struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event)
 {
@@ -1048,7 +1036,7 @@ static int decode_jm_oem_type5_error(struct ras_events *ras,
 
 /* error type6 data decoding functions */
 static int decode_jm_oem_type6_error(struct ras_events *ras,
-                                       struct ras_ns_ev_decoder *ev_decoder,
+                                    struct ras_ns_ev_decoder *ev_decoder,
                                        struct trace_seq *s,
                                        struct ras_non_standard_event *event)
 {
@@ -1060,7 +1048,7 @@ static int add_jm_oem_type0_table(struct ras_events *ras, struct ras_ns_ev_decod
 #ifdef HAVE_SQLITE3
        if (ras->record_events && !ev_decoder->stmt_dec_record) {
                if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
-                                               &jm_payload0_event_tab) != SQLITE_OK) {
+                                           &jm_payload0_event_tab) != SQLITE_OK) {
                        log(TERM, LOG_WARNING, "Failed to create sql jm_payload0_event_tab\n");
                        return -1;
                }
@@ -1069,7 +1057,6 @@ static int add_jm_oem_type0_table(struct ras_events *ras, struct ras_ns_ev_decod
        return 0;
 }
 
-
 struct ras_ns_ev_decoder jm_ns_oem_type_decoder[] = {
        {
                .sec_type = "82d78ba3-fa14-407a-ba0e-f3ba8170013c",
@@ -1106,4 +1093,3 @@ static void __attribute__((constructor)) jm_init(void)
                register_ns_ev_decoder(&jm_ns_oem_type_decoder[i]);
 }
 
-
index 4c30514b49527edf3f07d394af7c7d702f17ee7f..daadb95ef340c607e109da9a584082898c173731 100644 (file)
@@ -86,25 +86,25 @@ static const struct db_table_descriptor yitian_ddr_payload_section_tab = {
 };
 
 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)
 {
        int rc;
        struct sqlite3_stmt *stmt = ev_decoder->stmt_dec_record;
 
        log(TERM, LOG_INFO, "yitian_ddr_reg_dump_event store: %p\n", stmt);
 
-       sqlite3_bind_text (stmt,  1, ev->timestamp, -1, NULL);
-       sqlite3_bind_int64 (stmt,  2, ev->address);
-       sqlite3_bind_text (stmt,  3, ev->reg_msg, -1, NULL);
+       sqlite3_bind_text(stmt,  1, ev->timestamp, -1, NULL);
+       sqlite3_bind_int64(stmt,  2, ev->address);
+       sqlite3_bind_text(stmt,  3, ev->reg_msg, -1, NULL);
 
        rc = sqlite3_step(stmt);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
                log(TERM, LOG_ERR,
-                               "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
+                   "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
        rc = sqlite3_reset(stmt);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
                log(TERM, LOG_ERR,
-                               "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
+                   "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
        log(TERM, LOG_INFO, "register inserted at db\n");
 
        return rc;
@@ -112,7 +112,7 @@ int record_yitian_ddr_reg_dump_event(struct ras_ns_ev_decoder *ev_decoder,
 #endif
 
 static const char *oem_type_name(const struct yitian_ras_type_info *info,
-                               uint8_t type_id)
+                                uint8_t type_id)
 {
        const struct yitian_ras_type_info *type = &info[0];
 
@@ -134,7 +134,7 @@ static const char *oem_subtype_name(const struct yitian_ras_type_info *info,
 
                if (type->id != type_id)
                        continue;
-               if (type->sub == NULL)
+               if (!type->sub)
                        return type->name;
                if (sub_type_id >= type->sub_num)
                        return "unknown";
@@ -144,7 +144,7 @@ static const char *oem_subtype_name(const struct yitian_ras_type_info *info,
 }
 
 void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
-                               struct trace_seq *s,
+                                       struct trace_seq *s,
                                const struct yitian_ddr_payload_type_sec *err,
                                struct ras_events *ras)
 {
@@ -168,7 +168,7 @@ void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        tm = localtime(&now);
        if (tm)
                strftime(ev.timestamp, sizeof(ev.timestamp),
-                               "%Y-%m-%d %H:%M:%S %z", tm);
+                        "%Y-%m-%d %H:%M:%S %z", tm);
        //display error type
        p += snprintf(p, end - p, " %s", yitian_ddr_payload_err_reg_name[i++]);
        p += snprintf(p, end - p, " %s,", type_str);
@@ -204,18 +204,17 @@ void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
 #ifdef HAVE_SQLITE3
        record_yitian_ddr_reg_dump_event(ev_decoder, &ev);
 #endif
-
 }
 
 static int add_yitian_common_table(struct ras_events *ras,
-                                struct ras_ns_ev_decoder *ev_decoder)
+                                  struct ras_ns_ev_decoder *ev_decoder)
 {
 #ifdef HAVE_SQLITE3
        if (ras->record_events && !ev_decoder->stmt_dec_record) {
                if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
-                               &yitian_ddr_payload_section_tab) != SQLITE_OK) {
+                                           &yitian_ddr_payload_section_tab) != SQLITE_OK) {
                        log(TERM, LOG_WARNING,
-                               "Failed to create sql yitian_ddr_payload_section_tab\n");
+                           "Failed to create sql yitian_ddr_payload_section_tab\n");
                        return -1;
                }
        }
@@ -253,6 +252,7 @@ struct ras_ns_ev_decoder yitian_ns_oem_decoder[] = {
 static void __attribute__((constructor)) yitian_ns_init(void)
 {
        int i;
+
        for (i = 0; i < ARRAY_SIZE(yitian_ns_oem_decoder); i++)
                register_ns_ev_decoder(&yitian_ns_oem_decoder[i]);
 }
diff --git a/queue.c b/queue.c
index 65b6fb8b8ae912e1b383b1821ec6499b009c7dc0..a90ed6a9e9fd9732ad5bf1b5d36a706e4a51635e 100644 (file)
--- a/queue.c
+++ b/queue.c
@@ -29,7 +29,7 @@ struct link_queue *init_queue(void)
        struct link_queue *queue = NULL;
 
        queue = (struct link_queue *)malloc(sizeof(struct link_queue));
-       if (queue == NULL) {
+       if (!queue) {
                log(TERM, LOG_ERR, "Failed to allocate memory for queue.\n");
                return NULL;
        }
@@ -43,13 +43,13 @@ struct link_queue *init_queue(void)
 
 void clear_queue(struct link_queue *queue)
 {
-       if (queue == NULL)
+       if (!queue)
                return;
 
        struct queue_node *node = queue->head;
        struct queue_node *tmp = NULL;
 
-       while (node != NULL) {
+       while (node) {
                tmp = node;
                node = node->next;
                free(tmp);
@@ -72,7 +72,7 @@ void free_queue(struct link_queue *queue)
 void push(struct link_queue *queue, struct queue_node *node)
 {
        /* there is no element in the queue */
-       if (queue->head == NULL)
+       if (!queue->head)
                queue->head = node;
        else
                queue->tail->next = node;
@@ -85,7 +85,7 @@ int pop(struct link_queue *queue)
 {
        struct queue_node *tmp = NULL;
 
-       if (queue == NULL || is_empty(queue))
+       if (!queue || is_empty(queue))
                return -1;
 
        tmp = queue->head;
@@ -98,7 +98,7 @@ int pop(struct link_queue *queue)
 
 struct queue_node *front(struct link_queue *queue)
 {
-       if (queue == NULL)
+       if (!queue)
                return NULL;
 
        return queue->head;
@@ -109,7 +109,7 @@ struct queue_node *node_create(time_t time, unsigned int value)
        struct queue_node *node = NULL;
 
        node = (struct queue_node *)malloc(sizeof(struct queue_node));
-       if (node != NULL) {
+       if (node) {
                node->time = time;
                node->value = value;
                node->next = NULL;
index 1aa086762b7f24441d001530c811b850183e1a78..bb1a6f6150c243a62165ad00acce61bf61298ce0 100644 (file)
@@ -81,7 +81,7 @@ int ras_aer_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -176,7 +176,7 @@ int ras_aer_event_handler(struct trace_seq *s,
        sel_data[4] = (((dev & 0x1f) << 3) | (fn & 0x7));
 
        sprintf(ipmi_add_sel,
-         "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
+               "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
          sel_data[0], sel_data[1], sel_data[2], sel_data[3], sel_data[4]);
 
        system(ipmi_add_sel);
index bab428572bf3b7a3ba2321052eaa094f4a655102..0cff842060d793283ea260b86d74a20262f1e7fe 100644 (file)
@@ -29,7 +29,7 @@
 #define BIT2 2
 
 void display_raw_data(struct trace_seq *s,
-               const uint8_t *buf,
+                     const uint8_t *buf,
                uint32_t datalen)
 {
        int i = 0, line_count = 0;
@@ -72,7 +72,7 @@ static int count_errors(struct ras_arm_event *ev, int sev)
 
        if (ev->pei_len % err_info_size != 0) {
                log(TERM, LOG_ERR,
-                       "The event data does not match to the ARM Processor Error Information Structure\n");
+                   "The event data does not match to the ARM Processor Error Information Structure\n");
                return num;
        }
        num_pei = ev->pei_len / err_info_size;
@@ -172,7 +172,7 @@ int ras_arm_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -242,7 +242,7 @@ int ras_arm_event_handler(struct trace_seq *s,
 #ifdef HAVE_AMP_NS_DECODE
        //decode ampere specific error
        decode_amp_payload0_err_regs(NULL, s,
-                               (struct amp_payload0_type_sec *)ev.vsei_error);
+                                    (struct amp_payload0_type_sec *)ev.vsei_error);
 #else
        display_raw_data(s, ev.vsei_error, ev.oem_len);
 #endif
index 90633fdda78b62ff4349557430c958405ab20d64..8af31e9dc15173d7296f0173f1797f6574dcc500 100644 (file)
@@ -120,7 +120,7 @@ static int init_cpu_info(unsigned int cpus)
        cpu_infos = (struct cpu_info *)malloc(sizeof(*cpu_infos) * cpus);
        if (!cpu_infos) {
                log(TERM, LOG_ERR,
-                       "Failed to allocate memory for cpu infos in %s.\n", __func__);
+                   "Failed to allocate memory for cpu infos in %s.\n", __func__);
                return -1;
        }
 
@@ -130,9 +130,9 @@ static int init_cpu_info(unsigned int cpus)
                cpu_infos[i].state = get_cpu_status(i);
                cpu_infos[i].ce_queue = init_queue();
 
-               if (cpu_infos[i].ce_queue == NULL) {
+               if (!cpu_infos[i].ce_queue) {
                        log(TERM, LOG_ERR,
-                               "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
+                           "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
                        return -1;
                }
        }
@@ -147,7 +147,7 @@ static void check_config(struct isolation_param *config)
 {
        if (config->value > config->limit) {
                log(TERM, LOG_WARNING, "Value: %lu exceed limit: %lu, set to limit\n",
-                       config->value, config->limit);
+                   config->value, config->limit);
                config->value = config->limit;
        }
 }
@@ -173,7 +173,7 @@ static int parse_ul_config(struct isolation_param *config, char *env, unsigned l
        for (int i = 0; i < env_size; ++i) {
                if (isdigit(env[i])) {
                        if (*value > ULONG_MAX / DEC_CHECK ||
-                               (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
+                           (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
                                log(TERM, LOG_ERR, "%s is out of range: %lu\n", env, ULONG_MAX);
                                return -1;
                        }
@@ -208,7 +208,7 @@ static void init_config(struct isolation_param *config)
 
        if (parse_ul_config(config, env, &value) < 0) {
                log(TERM, LOG_ERR, "Invalid %s: %s! Use default value %lu.\n",
-                       config->name, env, config->value);
+                   config->name, env, config->value);
                return;
        }
 
@@ -220,7 +220,7 @@ static int check_config_status(void)
 {
        char *env = getenv("CPU_ISOLATION_ENABLE");
 
-       if (env == NULL || strcasecmp(env, "yes"))
+       if (!env || strcasecmp(env, "yes"))
                return -1;
 
        return 0;
@@ -295,12 +295,12 @@ static int do_ce_handler(unsigned int cpu)
                        cpu_infos[cpu].ce_nums -= tmp;
        }
        log(TERM, LOG_INFO,
-               "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
+           "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
                cpu, cpu_infos[cpu].ce_nums);
 
        if (cpu_infos[cpu].ce_nums >= threshold.value) {
                log(TERM, LOG_INFO,
-                       "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
+                   "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
                        threshold.value, cpu);
                return do_cpu_offline(cpu);
        }
@@ -341,7 +341,7 @@ static void record_error_info(unsigned int cpu, struct error_info *err_info)
        {
                struct queue_node *node = node_create(err_info->time, err_info->nums);
 
-               if (node == NULL) {
+               if (!node) {
                        log(TERM, LOG_ERR, "Fail to allocate memory for queue node\n");
                        return;
                }
@@ -366,7 +366,7 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
 
        if (cpu >= ncores || cpu < 0) {
                log(TERM, LOG_ERR,
-                       "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
+                   "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
                return;
        }
 
@@ -385,7 +385,7 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
         */
        if (ncores - sysconf(_SC_NPROCESSORS_ONLN) >= cpu_limit.value) {
                log(TERM, LOG_WARNING,
-                       "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
+                   "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
                        cpu_limit.value);
                return;
        }
@@ -395,11 +395,11 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
                log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu);
        else if (ret == HANDLE_SUCCEED) {
                log(TERM, LOG_INFO, "Offline cpu%d succeed, the state is %s\n",
-                       cpu, cpu_state[cpu_infos[cpu].state]);
+                   cpu, cpu_state[cpu_infos[cpu].state]);
                clear_queue(cpu_infos[cpu].ce_queue);
                cpu_infos[cpu].ce_nums = 0;
                cpu_infos[cpu].uce_nums = 0;
        } else
                log(TERM, LOG_WARNING, "Offline cpu%d fail, the state is %s\n",
-                       cpu, cpu_state[cpu_infos[cpu].state]);
+                   cpu, cpu_state[cpu_infos[cpu].state]);
 }
index a0b6780d64d65b1a2979889c3a7f3cdfe4d55156..16a5f76b0001b19ea0d1014b2dce34e677d201dd 100644 (file)
@@ -83,7 +83,7 @@ static char *uuid_be(const char *uu)
        static const unsigned char be[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
        for (i = 0; i < 16; i++) {
-               p += sprintf(p, "%.2x", (unsigned char) uu[be[i]]);
+               p += sprintf(p, "%.2x", (unsigned char)uu[be[i]]);
                switch (i) {
                case 3:
                case 5:
@@ -99,7 +99,7 @@ static char *uuid_be(const char *uu)
        return uuid;
 }
 
-static const char* get_cxl_type_str(const char** type_array, uint8_t num_elems, uint8_t type)
+static const char *get_cxl_type_str(const char **type_array, uint8_t num_elems, uint8_t type)
 {
        if (type >= num_elems)
                return "Unknown";
@@ -244,7 +244,7 @@ int ras_cxl_poison_event_handler(struct trace_seq *s,
        if (ev.flags & CXL_POISON_FLAG_OVERFLOW) {
                if (tep_get_field_val(s,  event, "overflow_ts", record, &val, 1) < 0)
                        return -1;
-               convert_timestamp(val, ev.overflow_ts, sizeof(ev.overflow_ts));         
+               convert_timestamp(val, ev.overflow_ts, sizeof(ev.overflow_ts));
        } else
                strncpy(ev.overflow_ts, "1970-01-01 00:00:00 +0000", sizeof(ev.overflow_ts));
        if (trace_seq_printf(s, "overflow timestamp:%s\n", ev.overflow_ts) <= 0)
@@ -491,7 +491,6 @@ enum cxl_event_log_type {
 
 static char *cxl_event_log_type_str(uint32_t log_type)
 {
-
        switch (log_type) {
        case CXL_EVENT_TYPE_INFO:
                return "Informational";
@@ -701,7 +700,7 @@ int ras_cxl_generic_event_handler(struct trace_seq *s,
                        if (trace_seq_printf(s, "\n  %08x: ", i) <= 0)
                                break;
                if (trace_seq_printf(s, "%02x%02x%02x%02x ",
-                                    buf[i], buf[i+1], buf[i+2], buf[i+3]) <= 0)
+                                    buf[i], buf[i + 1], buf[i + 2], buf[i + 3]) <= 0)
                        break;
        }
 
@@ -745,13 +744,13 @@ static const struct cxl_event_flags cxl_gmer_event_desc_flags[] = {
 #define CXL_GMER_VALID_DEVICE                  BIT(2)
 #define CXL_GMER_VALID_COMPONENT               BIT(3)
 
-static const charcxl_gmer_mem_event_type[] = {
+static const char *cxl_gmer_mem_event_type[] = {
        "ECC Error",
        "Invalid Address",
        "Data Path Error",
 };
 
-static const charcxl_gmer_trans_type[] = {
+static const char *cxl_gmer_trans_type[] = {
        "Unknown",
        "Host Read",
        "Host Write",
@@ -801,7 +800,7 @@ int ras_cxl_general_media_event_handler(struct trace_seq *s,
                return -1;
        ev.type = val;
        if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
-                            ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+                                                            ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
                return -1;
 
        if (tep_get_field_val(s,  event, "transaction_type", record, &val, 1) < 0)
@@ -920,7 +919,7 @@ int ras_cxl_dram_event_handler(struct trace_seq *s,
                return -1;
        ev.type = val;
        if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
-                            ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+                                                            ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
                return -1;
 
        if (tep_get_field_val(s,  event, "transaction_type", record, &val, 1) < 0)
@@ -1022,7 +1021,7 @@ int ras_cxl_dram_event_handler(struct trace_seq *s,
  *
  * CXL res 3.0 section 8.2.9.2.1.3; Table 8-45
  */
-static const charcxl_dev_evt_type[] = {
+static const char *cxl_dev_evt_type[] = {
        "Health Status Change",
        "Media Status Change",
        "Life Used Change",
@@ -1046,7 +1045,7 @@ static const struct cxl_event_flags cxl_health_status[] = {
        { .bit = CXL_DHI_HS_HW_REPLACEMENT_NEEDED, .flag = "REPLACEMENT_NEEDED" },
 };
 
-static const charcxl_media_status[] = {
+static const char *cxl_media_status[] = {
        "Normal",
        "Not Ready",
        "Write Persistency Lost",
@@ -1059,13 +1058,13 @@ static const char* cxl_media_status[] = {
        "All Data Loss Imminent",
 };
 
-static const charcxl_two_bit_status[] = {
+static const char *cxl_two_bit_status[] = {
        "Normal",
        "Warning",
        "Critical",
 };
 
-static const charcxl_one_bit_status[] = {
+static const char *cxl_one_bit_status[] = {
        "Normal",
        "Warning",
 };
@@ -1091,7 +1090,7 @@ int ras_cxl_memory_module_event_handler(struct trace_seq *s,
                return -1;
        ev.event_type = val;
        if (trace_seq_printf(s, "event_type:%s ", get_cxl_type_str(cxl_dev_evt_type,
-                            ARRAY_SIZE(cxl_dev_evt_type), ev.event_type)) <= 0)
+                                                                  ARRAY_SIZE(cxl_dev_evt_type), ev.event_type)) <= 0)
                return -1;
 
        if (tep_get_field_val(s, event, "health_status", record, &val, 1) < 0)
@@ -1107,26 +1106,26 @@ int ras_cxl_memory_module_event_handler(struct trace_seq *s,
                return -1;
        ev.media_status = val;
        if (trace_seq_printf(s, "media_status:%s ", get_cxl_type_str(cxl_media_status,
-                            ARRAY_SIZE(cxl_media_status), ev.media_status)) <= 0)
+                                                                    ARRAY_SIZE(cxl_media_status), ev.media_status)) <= 0)
                return -1;
 
        if (tep_get_field_val(s, event, "add_status", record, &val, 1) < 0)
                return -1;
        ev.add_status = val;
        if (trace_seq_printf(s, "as_life_used:%s ", get_cxl_type_str(cxl_two_bit_status,
-                            ARRAY_SIZE(cxl_two_bit_status),
+                                                                    ARRAY_SIZE(cxl_two_bit_status),
                             CXL_DHI_AS_LIFE_USED(ev.add_status))) <= 0)
                return -1;
        if (trace_seq_printf(s, "as_dev_temp:%s ", get_cxl_type_str(cxl_two_bit_status,
-                            ARRAY_SIZE(cxl_two_bit_status),
+                                                                   ARRAY_SIZE(cxl_two_bit_status),
                             CXL_DHI_AS_DEV_TEMP(ev.add_status))) <= 0)
                return -1;
        if (trace_seq_printf(s, "as_cor_vol_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
-                            ARRAY_SIZE(cxl_one_bit_status),
+                                                                          ARRAY_SIZE(cxl_one_bit_status),
                             CXL_DHI_AS_COR_VOL_ERR_CNT(ev.add_status))) <= 0)
                return -1;
        if (trace_seq_printf(s, "as_cor_per_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
-                            ARRAY_SIZE(cxl_one_bit_status),
+                                                                          ARRAY_SIZE(cxl_one_bit_status),
                             CXL_DHI_AS_COR_PER_ERR_CNT(ev.add_status))) <= 0)
                return -1;
 
index d68f9b07ad48f0f10097ef447573375ea0a99e2f..dcecc6de740cf5fe63213d80b92951b07ceec9d4 100644 (file)
@@ -38,7 +38,7 @@ int ras_net_xmit_timeout_handler(struct trace_seq *s,
        struct devlink_event ev;
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -78,7 +78,6 @@ int ras_net_xmit_timeout_handler(struct trace_seq *s,
 
        free(ev.msg);
        return 0;
-
 }
 
 int ras_devlink_event_handler(struct trace_seq *s,
@@ -104,7 +103,7 @@ int ras_devlink_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -125,7 +124,7 @@ int ras_devlink_event_handler(struct trace_seq *s,
                return -1;
 
        ev.driver_name = tep_get_field_raw(s, event, "driver_name",
-                                       record, &len, 1);
+                                          record, &len, 1);
        if (!ev.driver_name)
                return -1;
 
index 638cb4d9902ad7097d592a18a364eb8e1fb7d4c7..02bb5a7e3d947ef1830cdba37a07a5e0f3c0eec8 100644 (file)
@@ -30,7 +30,6 @@
 #include "ras-logger.h"
 #include "ras-report.h"
 
-
 static const struct {
        int             error;
        const char      *name;
@@ -82,7 +81,7 @@ int ras_diskerror_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
index f92c6a97545c28ddef5546beb2010487ca8ad522..a09723822bdfdb1904e686bcec3c2ca1710e702a 100644 (file)
@@ -60,7 +60,7 @@
        #define ENDIAN KBUFFER_ENDIAN_BIG
 #endif
 
-extern charchoices_disable;
+extern char *choices_disable;
 
 static int get_debugfs_dir(char *tracing_dir, size_t len)
 {
@@ -68,7 +68,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
        char line[MAX_PATH + 1 + 256];
        char *p, *type, *dir;
 
-       fp = fopen("/proc/mounts","r");
+       fp = fopen("/proc/mounts", "r");
        if (!fp) {
                log(ALL, LOG_INFO, "Can't open /proc/mounts");
                return errno;
@@ -96,7 +96,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
                        tracing_dir[len - 1] = '\0';
                        return 0;
                }
-       } while(1);
+       } while (1);
 
        fclose(fp);
        log(ALL, LOG_INFO, "Can't find debugfs\n");
@@ -141,7 +141,7 @@ static int get_tracing_dir(struct ras_events *ras)
        strcat(ras->tracing, "/tracing");
        if (has_instances) {
                strcat(ras->tracing, "/instances/" TOOL_NAME);
-               rc = mkdir(ras->tracing, S_IRWXU);
+               rc = mkdir(ras->tracing, 0700);
                if (rc < 0 && errno != EEXIST) {
                        log(ALL, LOG_INFO,
                            "Unable to create " TOOL_NAME " instance at %s\n",
@@ -152,13 +152,14 @@ static int get_tracing_dir(struct ras_events *ras)
        return 0;
 }
 
-static int is_disabled_event(char *group, char *event) {
+static int is_disabled_event(char *group, char *event)
+{
        char ras_event_name[MAX_PATH + 1];
 
        snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
-                       group, event);
+                group, event);
 
-       if (choices_disable != NULL && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
+       if (choices_disable && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
                return 1;
        }
        return 0;
@@ -172,6 +173,7 @@ static int __toggle_ras_mc_event(struct ras_events *ras,
 {
        int fd, rc;
        char fname[MAX_PATH + 1];
+
        enable = is_disabled_event(group, event) ? 0 : 1;
 
        snprintf(fname, sizeof(fname), "%s%s:%s\n",
@@ -185,7 +187,7 @@ static int __toggle_ras_mc_event(struct ras_events *ras,
                return errno;
        }
 
-       rc = write(fd, fname,strlen(fname));
+       rc = write(fd, fname, strlen(fname));
        if (rc < 0) {
                log(ALL, LOG_WARNING, "Can't write to set_event\n");
                close(fd);
@@ -248,7 +250,7 @@ int toggle_ras_mc_event(int enable)
 #endif
 
 #ifdef HAVE_DISKERROR
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
        rc |= __toggle_ras_mc_event(ras, "block", "block_rq_error", enable);
 #else
        rc |= __toggle_ras_mc_event(ras, "block", "block_rq_complete", enable);
@@ -275,7 +277,7 @@ free_ras:
        return rc;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
 /*
  * Set kernel filter. libtrace doesn't provide an API for setting filters
  * in kernel, we have to implement it here.
@@ -293,7 +295,7 @@ static int filter_ras_mc_event(struct ras_events *ras, char *group, char *event,
                return errno;
        }
 
-       rc = write(fd, filter_str ,strlen(filter_str));
+       rc = write(fd, filter_strstrlen(filter_str));
        if (rc < 0) {
                log(ALL, LOG_WARNING, "Can't write to filter file\n");
                close(fd);
@@ -331,7 +333,6 @@ static int get_pagesize(struct ras_events *ras, struct tep_handle *pevent)
 error:
        close(fd);
        return page_size;
-
 }
 
 static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
@@ -354,9 +355,9 @@ static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
        trace_seq_init(&s);
        tep_print_event(pdata->ras->pevent, &s, &record,
                        "%16s-%-5d [%03d] %s %6.1000d %s %s",
-                        TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
-                        TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME,
-                        TEP_PRINT_INFO);
+                       TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
+                       TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME,
+                       TEP_PRINT_INFO);
        trace_seq_do_printf(&s);
        printf("\n");
        fflush(stdout);
@@ -416,7 +417,7 @@ static int set_buffer_percent(struct ras_events *ras, int percent)
 }
 
 static int read_ras_event_all_cpus(struct pthread_data *pdata,
-                                  unsigned n_cpus)
+                                  unsigned int n_cpus)
 {
        ssize_t size;
        unsigned long long time_stamp;
@@ -467,7 +468,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 
                /* FIXME: use select to open for all CPUs */
                snprintf(pipe_raw, sizeof(pipe_raw),
-                       "per_cpu/cpu%d/trace_pipe_raw", i);
+                        "per_cpu/cpu%d/trace_pipe_raw", i);
 
                fds[i].fd = open_trace(pdata[0].ras, pipe_raw, O_RDONLY);
                if (fds[i].fd < 0) {
@@ -517,7 +518,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
                            fdsiginfo.ssi_signo == SIGTERM ||
                            fdsiginfo.ssi_signo == SIGHUP ||
                            fdsiginfo.ssi_signo == SIGQUIT) {
-                               log(TERM, LOG_INFO, "Recevied signal=%d\n",
+                               log(TERM, LOG_INFO, "Received signal=%d\n",
                                    fdsiginfo.ssi_signo);
                                goto  cleanup;
                        } else {
@@ -722,7 +723,7 @@ static int select_tracing_timestamp(struct ras_events *ras)
        int fd, rc;
        time_t uptime, now;
        size_t size;
-       unsigned j1;
+       unsigned int j1;
        char buf[4096];
 
        /* Check if uptime is supported (kernel 3.10-rc1 or upper) */
@@ -781,12 +782,12 @@ static int select_tracing_timestamp(struct ras_events *ras)
 }
 
 static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
-                            unsigned page_size, char *group, char *event,
+                            unsigned int page_size, char *group, char *event,
                             tep_event_handler_func func, char *filter_str, int id)
 {
        int fd, size, rc;
        char *page, fname[MAX_PATH + 1];
-       struct tep_event_filter * filter = NULL;
+       struct tep_event_filter *filter = NULL;
 
        snprintf(fname, sizeof(fname), "events/%s/%s/format", group, event);
 
@@ -856,7 +857,7 @@ static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
 
        if (is_disabled_event(group, event)) {
                log(ALL, LOG_INFO, "Disabled %s:%s tracing from config\n",
-                    group, event);
+                   group, event);
                return -EINVAL;
        }
 
@@ -879,7 +880,7 @@ int handle_ras_events(int record_events)
 {
        int rc, page_size, i;
        int num_events = 0;
-       unsigned cpus;
+       unsigned int cpus;
        struct tep_handle *pevent = NULL;
        struct pthread_data *data = NULL;
        struct ras_events *ras = NULL;
@@ -1013,7 +1014,7 @@ int handle_ras_events(int record_events)
 #endif
 
 #ifdef HAVE_DISKERROR
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
        rc = add_event_handler(ras, pevent, page_size, "block",
                               "block_rq_error", ras_diskerror_event_handler,
                                NULL, DISKERROR_EVENT);
@@ -1124,7 +1125,6 @@ int handle_ras_events(int record_events)
        if (!data)
                goto err;
 
-
        for (i = 0; i < cpus; i++) {
                data[i].ras = ras;
                data[i].cpu = i;
@@ -1139,14 +1139,14 @@ int handle_ras_events(int record_events)
                }
 
                log(SYSLOG, LOG_INFO,
-               "Opening one thread per cpu (%d threads)\n", cpus);
+                   "Opening one thread per cpu (%d threads)\n", cpus);
                for (i = 0; i < cpus; i++) {
                        rc = pthread_create(&data[i].thread, NULL,
-                                       handle_ras_events_cpu,
+                                           handle_ras_events_cpu,
                                        (void *)&data[i]);
                        if (rc) {
                                log(SYSLOG, LOG_INFO,
-                               "Failed to create thread for cpu %d. Aborting.\n",
+                                   "Failed to create thread for cpu %d. Aborting.\n",
                                i);
                                while (--i)
                                        pthread_cancel(data[i].thread);
index 49d01e248b4cebb3985be26e10f499a335c85e81..e9e79f5631669141d2f25cd75e0971fea29bdbfb 100644 (file)
@@ -139,7 +139,7 @@ static char *err_cper_data(const char *c)
                p += sprintf(p, "card_handle: %d ", cpd->mem_array_handle);
        if (cpd->validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
                p += sprintf(p, "module_handle: %d ", cpd->mem_dev_handle);
-       p += sprintf(p-1, ")");
+       p += sprintf(p - 1, ")");
 
        return buf;
 }
@@ -149,10 +149,10 @@ static char *uuid_le(const char *uu)
        static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
        char *p = uuid;
        int i;
-       static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+       static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
 
        for (i = 0; i < 16; i++) {
-               p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+               p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
                switch (i) {
                case 3:
                case 5:
@@ -168,14 +168,13 @@ static char *uuid_le(const char *uu)
        return uuid;
 }
 
-
 static void report_extlog_mem_event(struct ras_events *ras,
                                    struct tep_record *record,
                                    struct trace_seq *s,
                                    struct ras_extlog_event *ev)
 {
        trace_seq_printf(s, "%d %s error: %s physical addr: 0x%llx mask: 0x%llx%s %s %s",
-               ev->error_seq, err_severity(ev->severity),
+                        ev->error_seq, err_severity(ev->severity),
                err_type(ev->etype), ev->address,
                err_mask(ev->pa_mask_lsb),
                err_cper_data(ev->cper_data),
@@ -204,7 +203,7 @@ int ras_extlog_mem_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
index 1be9e7ef5f6dbae5e49485526d747b89a6d540b6..d93ba57c53c19653caf2f3edeecfdc278bfb45ab 100644 (file)
@@ -48,7 +48,7 @@ int ras_mc_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -121,22 +121,22 @@ int ras_mc_event_handler(struct trace_seq *s,
        if (tep_get_field_val(s,  event, "top_layer", record, &val, 1) < 0)
                goto parse_error;
        parsed_fields++;
-       ev.top_layer = (signed char) val;
+       ev.top_layer = (signed char)val;
 
        if (tep_get_field_val(s,  event, "middle_layer", record, &val, 1) < 0)
                goto parse_error;
        parsed_fields++;
-       ev.middle_layer = (signed char) val;
+       ev.middle_layer = (signed char)val;
 
        if (tep_get_field_val(s,  event, "lower_layer", record, &val, 1) < 0)
                goto parse_error;
        parsed_fields++;
-       ev.lower_layer = (signed char) val;
+       ev.lower_layer = (signed char)val;
 
        if (ev.top_layer >= 0 || ev.middle_layer >= 0 || ev.lower_layer >= 0) {
                if (ev.lower_layer >= 0)
                        trace_seq_printf(s, " location: %d:%d:%d",
-                                       ev.top_layer, ev.middle_layer, ev.lower_layer);
+                                        ev.top_layer, ev.middle_layer, ev.lower_layer);
                else if (ev.middle_layer >= 0)
                        trace_seq_printf(s, " location: %d:%d",
                                         ev.top_layer, ev.middle_layer);
@@ -159,7 +159,6 @@ int ras_mc_event_handler(struct trace_seq *s,
        ev.grain = val;
        trace_seq_printf(s, " grain: %lld", ev.grain);
 
-
        if (tep_get_field_val(s,  event, "syndrome", record, &val, 1) < 0)
                goto parse_error;
        parsed_fields++;
index 410541ea7b3033333dbba62723349a3dd7c98d55..93568e31a2f23bb33cabc822940e784682f5c38c 100644 (file)
@@ -114,11 +114,11 @@ static enum cputype select_intel_cputype(struct mce_priv *mce)
                else if (mce->model == 0x6a)
                        return CPU_ICELAKE_XEON;
                else if (mce->model == 0x6c)
-                        return CPU_ICELAKE_DE;
+                       return CPU_ICELAKE_DE;
                else if (mce->model == 0x86)
-                        return CPU_TREMONT_D;
+                       return CPU_TREMONT_D;
                else if (mce->model == 0x8f)
-                        return CPU_SAPPHIRERAPIDS;
+                       return CPU_SAPPHIRERAPIDS;
                else if (mce->model == 0xcf)
                        return CPU_EMERALDRAPIDS;
 
@@ -161,7 +161,7 @@ static int detect_cpu(struct mce_priv *mce)
        mce->mhz = 0;
        mce->vendor[0] = '\0';
 
-       f = fopen("/proc/cpuinfo","r");
+       f = fopen("/proc/cpuinfo", "r");
        if (!f) {
                log(ALL, LOG_INFO, "Can't open /proc/cpuinfo\n");
                return errno;
@@ -169,7 +169,7 @@ static int detect_cpu(struct mce_priv *mce)
 
        while (seen != CPU_ALL && getdelim(&line, &linelen, '\n', f) > 0) {
                if (sscanf(line, "vendor_id : %63[^\n]",
-                   (char *)&mce->vendor) == 1)
+                          (char *)&mce->vendor) == 1)
                        seen |= CPU_VENDOR;
                else if (sscanf(line, "cpu family : %d", &mce->family) == 1)
                        seen |= CPU_FAMILY;
@@ -189,7 +189,7 @@ static int detect_cpu(struct mce_priv *mce)
 
        if (seen != CPU_ALL) {
                log(ALL, LOG_INFO, "Can't parse /proc/cpuinfo: missing%s%s%s%s%s\n",
-                       (seen & CPU_VENDOR) ? "" : " [vendor_id]",
+                   (seen & CPU_VENDOR) ? "" : " [vendor_id]",
                        (seen & CPU_FAMILY) ? "" : " [cpu family]",
                        (seen & CPU_MODEL)  ? "" : " [model]",
                        (seen & CPU_MHZ)    ? "" : " [cpu MHz]",
@@ -215,12 +215,12 @@ static int detect_cpu(struct mce_priv *mce)
                        ret = EINVAL;
                }
                goto ret;
-       } else if (!strcmp(mce->vendor,"HygonGenuine")) {
+       } else if (!strcmp(mce->vendor, "HygonGenuine")) {
                if (mce->family == 24) {
                        mce->cputype = CPU_DHYANA;
                }
                goto ret;
-       } else if (!strcmp(mce->vendor,"GenuineIntel")) {
+       } else if (!strcmp(mce->vendor, "GenuineIntel")) {
                mce->cputype = select_intel_cputype(mce);
        } else {
                ret = EINVAL;
@@ -233,7 +233,7 @@ ret:
        return ret;
 }
 
-int register_mce_handler(struct ras_events *ras, unsigned ncpus)
+int register_mce_handler(struct ras_events *ras, unsigned int ncpus)
 {
        int rc;
        struct mce_priv *mce;
@@ -249,8 +249,8 @@ int register_mce_handler(struct ras_events *ras, unsigned ncpus)
        rc = detect_cpu(mce);
        if (rc) {
                if (mce->processor_flags)
-                       free (mce->processor_flags);
-               free (ras->mce_priv);
+                       free(mce->processor_flags);
+               free(ras->mce_priv);
                ras->mce_priv = NULL;
                return (rc);
        }
@@ -290,7 +290,7 @@ static void report_mce_event(struct ras_events *ras,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -378,13 +378,13 @@ static void report_mce_event(struct ras_events *ras,
        if (strlen(e->frutext)) {
                trace_seq_printf(s, ", FRU Text= %s", e->frutext);
                trace_seq_printf(s, ", Vendor Data= ");
-               for (int i = 2; i < e->vdata_len/8; i++) {
+               for (int i = 2; i < e->vdata_len / 8; i++) {
                        trace_seq_printf(s, "0x%lx", e->vdata[i]);
                        trace_seq_printf(s, " ");
                }
        } else {
                trace_seq_printf(s, ", Vendor Data= ");
-               for (int i = 0; i < e->vdata_len/8; i ++) {
+               for (int i = 0; i < e->vdata_len / 8; i++) {
                        trace_seq_printf(s, "0x%lx", e->vdata[i]);
                        trace_seq_printf(s, " ");
                }
@@ -477,7 +477,7 @@ int ras_offline_mce_event(struct ras_mc_offline_event *event)
                mce->ipid = event->ipid;
                if (!mce->ipid || !mce->status) {
                        log(TERM, LOG_ERR, "%s MSR required.\n",
-                                   mce->ipid ? "Status" : "Ipid");
+                           mce->ipid ? "Status" : "Ipid");
                        rc = -EINVAL;
                        goto free_mce;
                }
index c74541f4dca3e865b6caa5830cd75347a90247c8..97e8840a2f1356ef780c1f5f492e3a94666d54b7 100644 (file)
@@ -118,7 +118,6 @@ static const char *get_action_result(int result)
        return "unknown";
 }
 
-
 int ras_memory_failure_event_handler(struct trace_seq *s,
                                     struct tep_record *record,
                                     struct tep_event *event, void *context)
@@ -139,7 +138,7 @@ int ras_memory_failure_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
index 9bb9e2f61b8f3e6058e51a8bc4b90632f31f706d..f58e6a215abe742a3de8cd34ca5638a025d36cd0 100644 (file)
@@ -24,8 +24,9 @@
 
 static struct  ras_ns_ev_decoder *ras_ns_ev_dec_list;
 
-void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index) {
-       trace_seq_printf(s, "%02x%02x%02x%02x", buf[index+3], buf[index+2], buf[index+1], buf[index]);
+void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index)
+{
+       trace_seq_printf(s, "%02x%02x%02x%02x", buf[index + 3], buf[index + 2], buf[index + 1], buf[index]);
 }
 
 static char *uuid_le(const char *uu)
@@ -33,10 +34,10 @@ static char *uuid_le(const char *uu)
        static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
        char *p = uuid;
        int i;
-       static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+       static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
 
        for (i = 0; i < 16; i++) {
-               p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+               p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
                switch (i) {
                case 3:
                case 5:
@@ -167,7 +168,7 @@ int ras_non_standard_event_handler(struct trace_seq *s,
         */
 
        if (ras->use_uptime)
-               now = record->ts/user_hz + ras->uptime_diff;
+               now = record->ts / user_hz + ras->uptime_diff;
        else
                now = time(NULL);
 
@@ -197,12 +198,12 @@ int ras_non_standard_event_handler(struct trace_seq *s,
 
        ev.sec_type = tep_get_field_raw(s, event, "sec_type",
                                        record, &len, 1);
-       if(!ev.sec_type)
+       if (!ev.sec_type)
                return -1;
        if (strcmp(uuid_le(ev.sec_type),
                   "e8ed898d-df16-43cc-8ecc-54f060ef157f") == 0)
                trace_seq_printf(s, "\n section type: %s",
-               "Ampere Specific Error\n");
+                                "Ampere Specific Error\n");
        else
                trace_seq_printf(s, " section type: %s",
                                 uuid_le(ev.sec_type));
@@ -219,7 +220,7 @@ int ras_non_standard_event_handler(struct trace_seq *s,
        trace_seq_printf(s, " length: %d", ev.length);
 
        ev.error = tep_get_field_raw(s, event, "buf", record, &len, 1);
-       if(!ev.error)
+       if (!ev.error)
                return -1;
 
        if (!find_ns_ev_decoder(ev.sec_type, &ns_ev_decoder)) {
index caa8c31836617fa70795f1e097160b04cc9c7731..89f8c153b8887044340c7a18beb82878a960caf1 100644 (file)
@@ -116,7 +116,7 @@ static void parse_isolation_env(struct isolation *config)
        int unit_matched = 0;
        unsigned long value, tmp;
 
-       /* check if env is vaild */
+       /* check if env is valid */
        if (env && strlen(env)) {
                /* All the character before unit must be digit */
                for (i = 0; i < strlen(env) - 1; i++) {
@@ -125,7 +125,7 @@ static void parse_isolation_env(struct isolation *config)
                }
                if (sscanf(env, "%lu", &value) < 1 || !value)
                        goto parse;
-               /* check if the unit is vaild */
+               /* check if the unit is valid */
                unit = env + strlen(env) - 1;
                /* no unit, all the character are value character */
                if (isdigit(*unit)) {
@@ -151,7 +151,7 @@ parse:
                        config->unit = unit;
        } else {
                 log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
-                                config->name, config->env);
+                    config->name, config->env);
        }
 
        /* if env value string is greater than ulong_max, truncate the last digit */
@@ -177,10 +177,11 @@ static void parse_env_string(struct isolation *config, char *str, unsigned int s
 
        if (config->overflow) {
                /* when overflow, use basic unit */
-               for (i = 0; config->units[i].name; i++) ;
-               snprintf(str, size, "%lu%s", config->val, config->units[i-1].name);
+               for (i = 0; config->units[i].name; i++)
+                       ;
+               snprintf(str, size, "%lu%s", config->val, config->units[i - 1].name);
                log(TERM, LOG_INFO, "%s is set overflow(%s), truncate it\n",
-                               config->name, config->env);
+                   config->name, config->env);
        } else {
                snprintf(str, size, "%s%s", config->env, config->unit);
        }
@@ -202,7 +203,7 @@ static void page_isolation_init(void)
        parse_env_string(&threshold, threshold_string, sizeof(threshold_string));
        parse_env_string(&cycle, cycle_string, sizeof(cycle_string));
        log(TERM, LOG_INFO, "Threshold of memory Corrected Errors is %s / %s\n",
-                       threshold_string, cycle_string);
+           threshold_string, cycle_string);
 }
 
 void ras_page_account_init(void)
@@ -239,7 +240,7 @@ static void page_offline(struct page_record *pr)
        /* Offlining page is not required */
        if (offline <= OFFLINE_ACCOUNT) {
                log(TERM, LOG_INFO, "PAGE_CE_ACTION=%s, ignore to offline page at %#llx\n",
-                               offline_choice[offline].name, addr);
+                   offline_choice[offline].name, addr);
                return;
        }
 
@@ -264,7 +265,7 @@ static void page_offline(struct page_record *pr)
            addr, page_state[pr->offlined]);
 }
 
-static void page_record(struct page_record *pr, unsigned count, time_t time)
+static void page_record(struct page_record *pr, unsigned int count, time_t time)
 {
        unsigned long period = time - pr->start;
        unsigned long tolerate;
@@ -328,7 +329,7 @@ static struct page_record *page_lookup_insert(unsigned long long addr)
        return find;
 }
 
-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)
 {
        struct page_record *pr = NULL;
 
index 6b050bbe891e28d94fd10186ea5bcb8128a7966e..f3ffafbd8ae195d81cd225378623f3c7d9fac444 100644 (file)
  */
 
 static const struct db_fields mc_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="err_count",            .type="INTEGER" },
-               { .name="err_type",             .type="TEXT" },
-               { .name="err_msg",              .type="TEXT" },
-               { .name="label",                .type="TEXT" },
-               { .name="mc",                   .type="INTEGER" },
-               { .name="top_layer",            .type="INTEGER" },
-               { .name="middle_layer",         .type="INTEGER" },
-               { .name="lower_layer",          .type="INTEGER" },
-               { .name="address",              .type="INTEGER" },
-               { .name="grain",                .type="INTEGER" },
-               { .name="syndrome",             .type="INTEGER" },
-               { .name="driver_detail",        .type="TEXT" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "err_count",          .type = "INTEGER" },
+               { .name = "err_type",           .type = "TEXT" },
+               { .name = "err_msg",            .type = "TEXT" },
+               { .name = "label",              .type = "TEXT" },
+               { .name = "mc",                 .type = "INTEGER" },
+               { .name = "top_layer",          .type = "INTEGER" },
+               { .name = "middle_layer",               .type = "INTEGER" },
+               { .name = "lower_layer",                .type = "INTEGER" },
+               { .name = "address",            .type = "INTEGER" },
+               { .name = "grain",              .type = "INTEGER" },
+               { .name = "syndrome",           .type = "INTEGER" },
+               { .name = "driver_detail",      .type = "TEXT" },
 };
 
 static const struct db_table_descriptor mc_event_tab = {
@@ -82,9 +82,9 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
        sqlite3_bind_int (priv->stmt_mc_event,  7, ev->top_layer);
        sqlite3_bind_int (priv->stmt_mc_event,  8, ev->middle_layer);
        sqlite3_bind_int (priv->stmt_mc_event,  9, ev->lower_layer);
-       sqlite3_bind_int64 (priv->stmt_mc_event, 10, ev->address);
-       sqlite3_bind_int64 (priv->stmt_mc_event, 11, ev->grain);
-       sqlite3_bind_int64 (priv->stmt_mc_event, 12, ev->syndrome);
+       sqlite3_bind_int64(priv->stmt_mc_event, 10, ev->address);
+       sqlite3_bind_int64(priv->stmt_mc_event, 11, ev->grain);
+       sqlite3_bind_int64(priv->stmt_mc_event, 12, ev->syndrome);
        sqlite3_bind_text(priv->stmt_mc_event, 13, ev->driver_detail, -1, NULL);
        rc = sqlite3_step(priv->stmt_mc_event);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -106,11 +106,11 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
 
 #ifdef HAVE_AER
 static const struct db_fields aer_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="dev_name",             .type="TEXT" },
-               { .name="err_type",             .type="TEXT" },
-               { .name="err_msg",              .type="TEXT" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "dev_name",           .type = "TEXT" },
+               { .name = "err_type",           .type = "TEXT" },
+               { .name = "err_msg",            .type = "TEXT" },
 };
 
 static const struct db_table_descriptor aer_event_tab = {
@@ -154,13 +154,13 @@ int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
 
 #ifdef HAVE_NON_STANDARD
 static const struct db_fields non_standard_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="sec_type",             .type="BLOB" },
-               { .name="fru_id",               .type="BLOB" },
-               { .name="fru_text",             .type="TEXT" },
-               { .name="severity",             .type="TEXT" },
-               { .name="error",                .type="BLOB" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "sec_type",           .type = "BLOB" },
+               { .name = "fru_id",             .type = "BLOB" },
+               { .name = "fru_text",           .type = "TEXT" },
+               { .name = "severity",           .type = "TEXT" },
+               { .name = "error",              .type = "BLOB" },
 };
 
 static const struct db_table_descriptor non_standard_event_tab = {
@@ -178,12 +178,12 @@ int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standar
                return 0;
        log(TERM, LOG_INFO, "non_standard_event store: %p\n", priv->stmt_non_standard_record);
 
-       sqlite3_bind_text (priv->stmt_non_standard_record,  1, ev->timestamp, -1, NULL);
-       sqlite3_bind_blob (priv->stmt_non_standard_record,  2, ev->sec_type, -1, NULL);
-       sqlite3_bind_blob (priv->stmt_non_standard_record,  3, ev->fru_id, 16, NULL);
-       sqlite3_bind_text (priv->stmt_non_standard_record,  4, ev->fru_text, -1, NULL);
-       sqlite3_bind_text (priv->stmt_non_standard_record,  5, ev->severity, -1, NULL);
-       sqlite3_bind_blob (priv->stmt_non_standard_record,  6, ev->error, ev->length, NULL);
+       sqlite3_bind_text(priv->stmt_non_standard_record,  1, ev->timestamp, -1, NULL);
+       sqlite3_bind_blob(priv->stmt_non_standard_record,  2, ev->sec_type, -1, NULL);
+       sqlite3_bind_blob(priv->stmt_non_standard_record,  3, ev->fru_id, 16, NULL);
+       sqlite3_bind_text(priv->stmt_non_standard_record,  4, ev->fru_text, -1, NULL);
+       sqlite3_bind_text(priv->stmt_non_standard_record,  5, ev->severity, -1, NULL);
+       sqlite3_bind_blob(priv->stmt_non_standard_record,  6, ev->error, ev->length, NULL);
 
        rc = sqlite3_step(priv->stmt_non_standard_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -205,16 +205,16 @@ int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standar
 
 #ifdef HAVE_ARM
 static const struct db_fields arm_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="error_count",          .type="INTEGER" },
-               { .name="affinity",             .type="INTEGER" },
-               { .name="mpidr",                .type="INTEGER" },
-               { .name="running_state",        .type="INTEGER" },
-               { .name="psci_state",           .type="INTEGER" },
-               { .name="err_info",             .type="BLOB"    },
-               { .name="context_info",         .type="BLOB"    },
-               { .name="vendor_info",          .type="BLOB"    },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "error_count",                .type = "INTEGER" },
+               { .name = "affinity",           .type = "INTEGER" },
+               { .name = "mpidr",              .type = "INTEGER" },
+               { .name = "running_state",      .type = "INTEGER" },
+               { .name = "psci_state",         .type = "INTEGER" },
+               { .name = "err_info",           .type = "BLOB"  },
+               { .name = "context_info",               .type = "BLOB"  },
+               { .name = "vendor_info",                .type = "BLOB"  },
 };
 
 static const struct db_table_descriptor arm_event_tab = {
@@ -232,18 +232,18 @@ int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev)
                return 0;
        log(TERM, LOG_INFO, "arm_event store: %p\n", priv->stmt_arm_record);
 
-       sqlite3_bind_text (priv->stmt_arm_record,  1,  ev->timestamp, -1, NULL);
+       sqlite3_bind_text(priv->stmt_arm_record,  1,  ev->timestamp, -1, NULL);
        sqlite3_bind_int  (priv->stmt_arm_record,  2,  ev->error_count);
        sqlite3_bind_int  (priv->stmt_arm_record,  3,  ev->affinity);
-       sqlite3_bind_int64  (priv->stmt_arm_record,  4,  ev->mpidr);
+       sqlite3_bind_int64(priv->stmt_arm_record,  4,  ev->mpidr);
        sqlite3_bind_int  (priv->stmt_arm_record,  5,  ev->running_state);
        sqlite3_bind_int  (priv->stmt_arm_record,  6,  ev->psci_state);
-       sqlite3_bind_blob (priv->stmt_arm_record,  7,
-                           ev->pei_error, ev->pei_len, NULL);
-       sqlite3_bind_blob (priv->stmt_arm_record,  8,
-                           ev->ctx_error, ev->ctx_len, NULL);
-       sqlite3_bind_blob (priv->stmt_arm_record,  9,
-                           ev->vsei_error, ev->oem_len, NULL);
+       sqlite3_bind_blob(priv->stmt_arm_record,  7,
+                         ev->pei_error, ev->pei_len, NULL);
+       sqlite3_bind_blob(priv->stmt_arm_record,  8,
+                         ev->ctx_error, ev->ctx_len, NULL);
+       sqlite3_bind_blob(priv->stmt_arm_record,  9,
+                         ev->vsei_error, ev->oem_len, NULL);
 
        rc = sqlite3_step(priv->stmt_arm_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -262,15 +262,15 @@ int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev)
 
 #ifdef HAVE_EXTLOG
 static const struct db_fields extlog_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="etype",                .type="INTEGER" },
-               { .name="error_count",          .type="INTEGER" },
-               { .name="severity",             .type="INTEGER" },
-               { .name="address",              .type="INTEGER" },
-               { .name="fru_id",               .type="BLOB" },
-               { .name="fru_text",             .type="TEXT" },
-               { .name="cper_data",            .type="BLOB" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "etype",              .type = "INTEGER" },
+               { .name = "error_count",                .type = "INTEGER" },
+               { .name = "severity",           .type = "INTEGER" },
+               { .name = "address",            .type = "INTEGER" },
+               { .name = "fru_id",             .type = "BLOB" },
+               { .name = "fru_text",           .type = "TEXT" },
+               { .name = "cper_data",          .type = "BLOB" },
 };
 
 static const struct db_table_descriptor extlog_event_tab = {
@@ -288,14 +288,14 @@ int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event
                return 0;
        log(TERM, LOG_INFO, "extlog_record store: %p\n", priv->stmt_extlog_record);
 
-       sqlite3_bind_text  (priv->stmt_extlog_record,  1, ev->timestamp, -1, NULL);
+       sqlite3_bind_text(priv->stmt_extlog_record,  1, ev->timestamp, -1, NULL);
        sqlite3_bind_int   (priv->stmt_extlog_record,  2, ev->etype);
        sqlite3_bind_int   (priv->stmt_extlog_record,  3, ev->error_seq);
        sqlite3_bind_int   (priv->stmt_extlog_record,  4, ev->severity);
-       sqlite3_bind_int64 (priv->stmt_extlog_record,  5, ev->address);
-       sqlite3_bind_blob  (priv->stmt_extlog_record,  6, ev->fru_id, 16, NULL);
-       sqlite3_bind_text  (priv->stmt_extlog_record,  7, ev->fru_text, -1, NULL);
-       sqlite3_bind_blob  (priv->stmt_extlog_record,  8, ev->cper_data, ev->cper_data_length, NULL);
+       sqlite3_bind_int64(priv->stmt_extlog_record,  5, ev->address);
+       sqlite3_bind_blob(priv->stmt_extlog_record,  6, ev->fru_id, 16, NULL);
+       sqlite3_bind_text(priv->stmt_extlog_record,  7, ev->fru_text, -1, NULL);
+       sqlite3_bind_blob(priv->stmt_extlog_record,  8, ev->cper_data, ev->cper_data_length, NULL);
 
        rc = sqlite3_step(priv->stmt_extlog_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -318,34 +318,34 @@ int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event
 
 #ifdef HAVE_MCE
 static const struct db_fields mce_record_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
 
                /* MCE registers */
-               { .name="mcgcap",               .type="INTEGER" },
-               { .name="mcgstatus",            .type="INTEGER" },
-               { .name="status",               .type="INTEGER" },
-               { .name="addr",                 .type="INTEGER" }, // 5
-               { .name="misc",                 .type="INTEGER" },
-               { .name="ip",                   .type="INTEGER" },
-               { .name="tsc",                  .type="INTEGER" },
-               { .name="walltime",             .type="INTEGER" },
-               { .name="cpu",                  .type="INTEGER" }, // 10
-               { .name="cpuid",                .type="INTEGER" },
-               { .name="apicid",               .type="INTEGER" },
-               { .name="socketid",             .type="INTEGER" },
-               { .name="cs",                   .type="INTEGER" },
-               { .name="bank",                 .type="INTEGER" }, //15
-               { .name="cpuvendor",            .type="INTEGER" },
+               { .name = "mcgcap",             .type = "INTEGER" },
+               { .name = "mcgstatus",          .type = "INTEGER" },
+               { .name = "status",             .type = "INTEGER" },
+               { .name = "addr",                       .type = "INTEGER" }, // 5
+               { .name = "misc",                       .type = "INTEGER" },
+               { .name = "ip",                 .type = "INTEGER" },
+               { .name = "tsc",                        .type = "INTEGER" },
+               { .name = "walltime",           .type = "INTEGER" },
+               { .name = "cpu",                        .type = "INTEGER" }, // 10
+               { .name = "cpuid",              .type = "INTEGER" },
+               { .name = "apicid",             .type = "INTEGER" },
+               { .name = "socketid",           .type = "INTEGER" },
+               { .name = "cs",                 .type = "INTEGER" },
+               { .name = "bank",                       .type = "INTEGER" }, //15
+               { .name = "cpuvendor",          .type = "INTEGER" },
 
                /* Parsed data - will likely change */
-               { .name="bank_name",            .type="TEXT" },
-               { .name="error_msg",            .type="TEXT" },
-               { .name="mcgstatus_msg",        .type="TEXT" },
-               { .name="mcistatus_msg",        .type="TEXT" }, // 20
-               { .name="mcastatus_msg",        .type="TEXT" },
-               { .name="user_action",          .type="TEXT" },
-               { .name="mc_location",          .type="TEXT" },
+               { .name = "bank_name",          .type = "TEXT" },
+               { .name = "error_msg",          .type = "TEXT" },
+               { .name = "mcgstatus_msg",      .type = "TEXT" },
+               { .name = "mcistatus_msg",      .type = "TEXT" }, // 20
+               { .name = "mcastatus_msg",      .type = "TEXT" },
+               { .name = "user_action",                .type = "TEXT" },
+               { .name = "mc_location",                .type = "TEXT" },
 };
 
 static const struct db_table_descriptor mce_record_tab = {
@@ -363,15 +363,15 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
                return 0;
        log(TERM, LOG_INFO, "mce_record store: %p\n", priv->stmt_mce_record);
 
-       sqlite3_bind_text  (priv->stmt_mce_record,  1, ev->timestamp, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record,  1, ev->timestamp, -1, NULL);
        sqlite3_bind_int   (priv->stmt_mce_record,  2, ev->mcgcap);
        sqlite3_bind_int   (priv->stmt_mce_record,  3, ev->mcgstatus);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  4, ev->status);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  5, ev->addr);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  6, ev->misc);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  7, ev->ip);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  8, ev->tsc);
-       sqlite3_bind_int64 (priv->stmt_mce_record,  9, ev->walltime);
+       sqlite3_bind_int64(priv->stmt_mce_record,  4, ev->status);
+       sqlite3_bind_int64(priv->stmt_mce_record,  5, ev->addr);
+       sqlite3_bind_int64(priv->stmt_mce_record,  6, ev->misc);
+       sqlite3_bind_int64(priv->stmt_mce_record,  7, ev->ip);
+       sqlite3_bind_int64(priv->stmt_mce_record,  8, ev->tsc);
+       sqlite3_bind_int64(priv->stmt_mce_record,  9, ev->walltime);
        sqlite3_bind_int   (priv->stmt_mce_record, 10, ev->cpu);
        sqlite3_bind_int   (priv->stmt_mce_record, 11, ev->cpuid);
        sqlite3_bind_int   (priv->stmt_mce_record, 12, ev->apicid);
@@ -409,13 +409,13 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
 
 #ifdef HAVE_DEVLINK
 static const struct db_fields devlink_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="bus_name",             .type="TEXT" },
-               { .name="dev_name",             .type="TEXT" },
-               { .name="driver_name",          .type="TEXT" },
-               { .name="reporter_name",        .type="TEXT" },
-               { .name="msg",                  .type="TEXT" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "bus_name",           .type = "TEXT" },
+               { .name = "dev_name",           .type = "TEXT" },
+               { .name = "driver_name",                .type = "TEXT" },
+               { .name = "reporter_name",      .type = "TEXT" },
+               { .name = "msg",                        .type = "TEXT" },
 };
 
 static const struct db_table_descriptor devlink_event_tab = {
@@ -461,14 +461,14 @@ int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev)
 
 #ifdef HAVE_DISKERROR
 static const struct db_fields diskerror_event_fields[] = {
-               { .name="id",                   .type="INTEGER PRIMARY KEY" },
-               { .name="timestamp",            .type="TEXT" },
-               { .name="dev",                  .type="TEXT" },
-               { .name="sector",               .type="INTEGER" },
-               { .name="nr_sector",            .type="INTEGER" },
-               { .name="error",                .type="TEXT" },
-               { .name="rwbs",                 .type="TEXT" },
-               { .name="cmd",                  .type="TEXT" },
+               { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+               { .name = "timestamp",          .type = "TEXT" },
+               { .name = "dev",                        .type = "TEXT" },
+               { .name = "sector",             .type = "INTEGER" },
+               { .name = "nr_sector",          .type = "INTEGER" },
+               { .name = "error",              .type = "TEXT" },
+               { .name = "rwbs",                       .type = "TEXT" },
+               { .name = "cmd",                        .type = "TEXT" },
 };
 
 static const struct db_table_descriptor diskerror_event_tab = {
@@ -515,11 +515,11 @@ int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev
 
 #ifdef HAVE_MEMORY_FAILURE
 static const struct db_fields mf_event_fields[] = {
-       { .name="id",                   .type="INTEGER PRIMARY KEY" },
-       { .name="timestamp",            .type="TEXT" },
-       { .name="pfn",                  .type="TEXT" },
-       { .name="page_type",            .type="TEXT" },
-       { .name="action_result",        .type="TEXT" },
+       { .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+       { .name = "timestamp",          .type = "TEXT" },
+       { .name = "pfn",                .type = "TEXT" },
+       { .name = "page_type",          .type = "TEXT" },
+       { .name = "action_result",      .type = "TEXT" },
 };
 
 static const struct db_table_descriptor mf_event_tab = {
@@ -1167,7 +1167,7 @@ static int ras_mc_alter_table(struct sqlite3_priv *priv,
                found = 0;
                for (j = 0; j < col_count; j++) {
                        if (!strcmp(field->name,
-                           sqlite3_column_name(*stmt, j))) {
+                                   sqlite3_column_name(*stmt, j))) {
                                found = 1;
                                break;
                        }
@@ -1258,13 +1258,13 @@ int ras_mc_finalize_vendor_table(sqlite3_stmt *stmt)
        return rc;
 }
 
-int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
+int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras)
 {
        int rc;
        sqlite3 *db;
        struct sqlite3_priv *priv;
 
-       printf("Calling %s()\n", __FUNCTION__);
+       printf("Calling %s()\n", __func__);
 
        ras->db_ref_count++;
        if (ras->db_ref_count > 1)
@@ -1277,6 +1277,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
                return -1;
 
        struct stat st = {0};
+
        if (stat(RASSTATEDIR, &st) == -1) {
                if (errno != ENOENT) {
                        log(TERM, LOG_ERR,
@@ -1358,7 +1359,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
        rc = ras_mc_create_table(priv, &non_standard_event_tab);
        if (rc == SQLITE_OK) {
                rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record,
-                                       &non_standard_event_tab);
+                                        &non_standard_event_tab);
                if (rc != SQLITE_OK)
                        goto error;
        }
@@ -1368,7 +1369,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
        rc = ras_mc_create_table(priv, &arm_event_tab);
        if (rc == SQLITE_OK) {
                rc = ras_mc_prepare_stmt(priv, &priv->stmt_arm_record,
-                                       &arm_event_tab);
+                                        &arm_event_tab);
                if (rc != SQLITE_OK)
                        goto error;
        }
@@ -1377,7 +1378,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
        rc = ras_mc_create_table(priv, &devlink_event_tab);
        if (rc == SQLITE_OK) {
                rc = ras_mc_prepare_stmt(priv, &priv->stmt_devlink_event,
-                                       &devlink_event_tab);
+                                        &devlink_event_tab);
                if (rc != SQLITE_OK)
                        goto error;
        }
@@ -1387,7 +1388,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
        rc = ras_mc_create_table(priv, &diskerror_event_tab);
        if (rc == SQLITE_OK) {
                rc = ras_mc_prepare_stmt(priv, &priv->stmt_diskerror_event,
-                                       &diskerror_event_tab);
+                                        &diskerror_event_tab);
                if (rc != SQLITE_OK)
                        goto error;
        }
@@ -1527,7 +1528,6 @@ int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras)
        }
 #endif
 
-
 #ifdef HAVE_MCE
        if (priv->stmt_mce_record) {
                rc = sqlite3_finalize(priv->stmt_mce_record);
index a30b66d3d8269b38cc95c8299b2f040aa4f78406..5cc55b6cd9dd6cd534e3fe0ce13ba0bcdd93190a 100644 (file)
 
 #include "ras-report.h"
 
-static int setup_report_socket(void){
+static int setup_report_socket(void)
+{
        int sockfd = -1;
        int rc = -1;
        struct sockaddr_un addr;
 
        sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
@@ -45,12 +46,13 @@ static int setup_report_socket(void){
        return sockfd;
 }
 
-static int commit_report_basic(int sockfd){
+static int commit_report_basic(int sockfd)
+{
        char buf[INPUT_BUFFER_SIZE];
        struct utsname un;
        int rc = -1;
 
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return rc;
        }
 
@@ -58,7 +60,7 @@ static int commit_report_basic(int sockfd){
        memset(&un, 0, sizeof(struct utsname));
 
        rc = uname(&un);
-       if(rc < 0){
+       if (rc < 0) {
                return rc;
        }
 
@@ -67,35 +69,36 @@ static int commit_report_basic(int sockfd){
         */
        sprintf(buf, "PUT / HTTP/1.1\r\n\r\n");
        rc = write(sockfd, buf, strlen(buf));
-       if(rc < strlen(buf)){
+       if (rc < strlen(buf)) {
                return -1;
        }
 
        sprintf(buf, "PID=%d", (int)getpid());
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                return -1;
        }
 
        sprintf(buf, "EXECUTABLE=/boot/vmlinuz-%s", un.release);
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                return -1;
        }
 
        sprintf(buf, "TYPE=%s", "ras");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                return -1;
        }
 
        return 0;
 }
 
-static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
+static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -131,10 +134,11 @@ static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
        return 0;
 }
 
-static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
+static int set_mce_event_backtrace(char *buf, struct mce_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -190,10 +194,11 @@ static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
        return 0;
 }
 
-static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
+static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -211,10 +216,11 @@ static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
        return 0;
 }
 
-static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev){
+static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -230,10 +236,11 @@ static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_e
        return 0;
 }
 
-static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev){
+static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -257,10 +264,11 @@ static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev){
        return 0;
 }
 
-static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev){
+static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -282,10 +290,11 @@ static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev){
        return 0;
 }
 
-static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev) {
+static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev)
+{
        char bt_buf[MAX_BACKTRACE_SIZE];
 
-       if(!buf || !ev)
+       if (!buf || !ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
@@ -317,14 +326,14 @@ static int set_mf_event_backtrace(char *buf, struct ras_mf_event *ev)
                return -1;
 
        sprintf(bt_buf, "BACKTRACE="    \
-                                                "timestamp=%s\n"       \
-                                                "pfn=%s\n"             \
-                                                "page_type=%s\n"       \
-                                                "action_result=%s\n",  \
-                                                ev->timestamp,         \
-                                                ev->pfn,               \
-                                                ev->page_type,         \
-                                                ev->action_result);
+                                               "timestamp=%s\n"        \
+                                               "pfn=%s\n"              \
+                                               "page_type=%s\n"        \
+                                               "action_result=%s\n",   \
+                                               ev->timestamp,          \
+                                               ev->pfn,                \
+                                               ev->page_type,          \
+                                               ev->action_result);
 
        strcat(buf, bt_buf);
 
@@ -661,19 +670,20 @@ static int set_cxl_memory_module_event_backtrace(char *buf, struct ras_cxl_memor
        return 0;
 }
 
-static int commit_report_backtrace(int sockfd, int type, void *ev){
+static int commit_report_backtrace(int sockfd, int type, void *ev)
+{
        char buf[MAX_BACKTRACE_SIZE];
        char *pbuf = buf;
        int rc = -1;
        int buf_len = 0;
 
-       if(sockfd < 0 || !ev){
+       if (sockfd < 0 || !ev) {
                return -1;
        }
 
        memset(buf, 0, MAX_BACKTRACE_SIZE);
 
-       switch(type){
+       switch (type) {
        case MC_EVENT:
                rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
                break;
@@ -726,15 +736,15 @@ static int commit_report_backtrace(int sockfd, int type, void *ev){
                return -1;
        }
 
-       if(rc < 0){
+       if (rc < 0) {
                return -1;
        }
 
        buf_len = strlen(buf);
 
-       for(;buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)){
+       for (; buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)) {
                rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
-               if(rc < INPUT_BUFFER_SIZE - 1){
+               if (rc < INPUT_BUFFER_SIZE - 1) {
                        return -1;
                }
 
@@ -742,14 +752,15 @@ static int commit_report_backtrace(int sockfd, int type, void *ev){
        }
 
        rc = write(sockfd, pbuf, buf_len + 1);
-       if(rc < buf_len){
+       if (rc < buf_len) {
                return -1;
        }
 
        return 0;
 }
 
-int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
+int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = -1;
        int done = 0;
@@ -758,29 +769,29 @@ int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto mc_fail;
        }
 
        rc = commit_report_backtrace(sockfd, MC_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto mc_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-mc");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto mc_fail;
        }
 
        sprintf(buf, "REASON=%s", "EDAC driver report problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto mc_fail;
        }
 
@@ -788,18 +799,19 @@ int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
 
 mc_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
-       if(done){
+       if (done) {
                return 0;
-       }else{
+       } else {
                return -1;
        }
 }
 
-int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
+int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int done = 0;
@@ -808,29 +820,29 @@ int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto aer_fail;
        }
 
        rc = commit_report_backtrace(sockfd, AER_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto aer_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-aer");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto aer_fail;
        }
 
        sprintf(buf, "REASON=%s", "PCIe AER driver report problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto aer_fail;
        }
 
@@ -838,18 +850,19 @@ int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
 
 aer_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
-       if(done){
+       if (done) {
                return 0;
-       }else{
+       } else {
                return -1;
        }
 }
 
-int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev){
+int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int rc = -1;
@@ -857,29 +870,29 @@ int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standar
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return rc;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto non_standard_fail;
        }
 
        rc = commit_report_backtrace(sockfd, NON_STANDARD_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto non_standard_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-non-standard");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto non_standard_fail;
        }
 
        sprintf(buf, "REASON=%s", "Unknown CPER section problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto non_standard_fail;
        }
 
@@ -887,14 +900,15 @@ int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standar
 
 non_standard_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
        return rc;
 }
 
-int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
+int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int rc = -1;
@@ -902,29 +916,29 @@ int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return rc;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto arm_fail;
        }
 
        rc = commit_report_backtrace(sockfd, ARM_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto arm_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-arm");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto arm_fail;
        }
 
        sprintf(buf, "REASON=%s", "ARM CPU report problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto arm_fail;
        }
 
@@ -932,14 +946,15 @@ int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
 
 arm_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
        return rc;
 }
 
-int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
+int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int done = 0;
@@ -948,29 +963,29 @@ int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto mce_fail;
        }
 
        rc = commit_report_backtrace(sockfd, MCE_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto mce_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-mce");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto mce_fail;
        }
 
        sprintf(buf, "REASON=%s", "Machine Check driver report problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto mce_fail;
        }
 
@@ -978,18 +993,19 @@ int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
 
 mce_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
-       if(done){
+       if (done) {
                return 0;
-       }else{
+       } else {
                return -1;
        }
 }
 
-int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
+int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int done = 0;
@@ -998,29 +1014,29 @@ int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto devlink_fail;
        }
 
        rc = commit_report_backtrace(sockfd, DEVLINK_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto devlink_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-devlink");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto devlink_fail;
        }
 
        sprintf(buf, "REASON=%s", "devlink health report problem");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto devlink_fail;
        }
 
@@ -1028,18 +1044,19 @@ int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
 
 devlink_fail:
 
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
-       if(done){
+       if (done) {
                return 0;
-       }else{
+       } else {
                return -1;
        }
 }
 
-int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev){
+int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev)
+{
        char buf[MAX_MESSAGE_SIZE];
        int sockfd = 0;
        int done = 0;
@@ -1048,42 +1065,42 @@ int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *e
        memset(buf, 0, sizeof(buf));
 
        sockfd = setup_report_socket();
-       if(sockfd < 0){
+       if (sockfd < 0) {
                return -1;
        }
 
        rc = commit_report_basic(sockfd);
-       if(rc < 0){
+       if (rc < 0) {
                goto diskerror_fail;
        }
 
        rc = commit_report_backtrace(sockfd, DISKERROR_EVENT, ev);
-       if(rc < 0){
+       if (rc < 0) {
                goto diskerror_fail;
        }
 
        sprintf(buf, "ANALYZER=%s", "rasdaemon-diskerror");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto diskerror_fail;
        }
 
        sprintf(buf, "REASON=%s", "disk I/O error");
        rc = write(sockfd, buf, strlen(buf) + 1);
-       if(rc < strlen(buf) + 1){
+       if (rc < strlen(buf) + 1) {
                goto diskerror_fail;
        }
 
        done = 1;
 
 diskerror_fail:
-       if(sockfd >= 0){
+       if (sockfd >= 0) {
                close(sockfd);
        }
 
-       if(done){
+       if (done) {
                return 0;
-       }else{
+       } else {
                return -1;
        }
 }
@@ -1349,7 +1366,6 @@ cxl_generic_fail:
                return 0;
        else
                return -1;
-
 }
 
 int ras_report_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
index 0db51c9991d6a87b8930001c76fe3b9ddbbcedfd..7a3f9649a0db30522203dc41d0c19789a9816cc5 100644 (file)
@@ -34,7 +34,7 @@
 #define TOOL_DESCRIPTION "RAS daemon to log the RAS events."
 #define ARGS_DOC "<options>"
 #define DISABLE "DISABLE"
-char *choices_disable = NULL;
+char *choices_disable;
 
 const char *argp_program_version = TOOL_NAME " " VERSION;
 const char *argp_program_bug_address = "Mauro Carvalho Chehab <mchehab@kernel.org>";
@@ -129,6 +129,7 @@ int main(int argc, char *argv[])
 {
        struct arguments args;
        int idx = -1;
+
        choices_disable = getenv(DISABLE);
 
 #ifdef HAVE_MCE
@@ -179,7 +180,7 @@ int main(int argc, char *argv[])
                .children = offline_parser,
 #endif
        };
-       memset (&args, 0, sizeof(args));
+       memset(&args, 0, sizeof(args));
 
        user_hz = sysconf(_SC_CLK_TCK);
 
@@ -208,7 +209,7 @@ int main(int argc, char *argv[])
 
        openlog(TOOL_NAME, 0, LOG_DAEMON);
        if (!args.foreground)
-               if (daemon(0,0))
+               if (daemon(0, 0))
                        exit(EXIT_FAILURE);
 
        handle_ras_events(args.record_events);
index d9b1bd4d635a8378ba2710d0aad149f8dee755f8..43da434da38782a389fc6c679660b5e392bb35f3 100644 (file)
--- a/rbtree.c
+++ b/rbtree.c
@@ -28,7 +28,8 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
        struct rb_node *right = node->rb_right;
        struct rb_node *parent = rb_parent(node);
 
-       if ((node->rb_right = right->rb_left))
+       node->rb_right = right->rb_left;
+       if (node->rb_right)
                rb_set_parent(right->rb_left, node);
        right->rb_left = node;
 
@@ -40,8 +41,7 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
                        parent->rb_left = right;
                else
                        parent->rb_right = right;
-       }
-       else
+       } else
                root->rb_node = right;
        rb_set_parent(node, right);
 }
@@ -51,7 +51,8 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
        struct rb_node *left = node->rb_left;
        struct rb_node *parent = rb_parent(node);
 
-       if ((node->rb_left = left->rb_right))
+       node->rb_left = left->rb_right;
+       if (node->rb_left)
                rb_set_parent(left->rb_right, node);
        left->rb_right = node;
 
@@ -63,8 +64,7 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
                        parent->rb_right = left;
                else
                        parent->rb_left = left;
-       }
-       else
+       } else
                root->rb_node = left;
        rb_set_parent(node, left);
 }
@@ -81,6 +81,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                {
                        {
                                register struct rb_node *uncle = gparent->rb_right;
+
                                if (uncle && rb_is_red(uncle))
                                {
                                        rb_set_black(uncle);
@@ -94,6 +95,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                        if (parent->rb_right == node)
                        {
                                struct rb_node *tmp;
+
                                __rb_rotate_left(parent, root);
                                tmp = parent;
                                parent = node;
@@ -106,6 +108,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                } else {
                        {
                                struct rb_node *uncle = gparent->rb_left;
+
                                if (uncle && rb_is_red(uncle))
                                {
                                        rb_set_black(uncle);
@@ -119,6 +122,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                        if (parent->rb_left == node)
                        {
                                struct rb_node *tmp;
+
                                __rb_rotate_right(parent, root);
                                tmp = parent;
                                parent = node;
@@ -157,8 +161,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                                rb_set_red(other);
                                node = parent;
                                parent = rb_parent(node);
-                       }
-                       else
+                       } else
                        {
                                if (!other->rb_right || rb_is_black(other->rb_right))
                                {
@@ -174,8 +177,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                                node = root->rb_node;
                                break;
                        }
-               }
-               else
+               } else
                {
                        other = parent->rb_left;
                        if (rb_is_red(other))
@@ -191,8 +193,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                                rb_set_red(other);
                                node = parent;
                                parent = rb_parent(node);
-                       }
-                       else
+                       } else
                        {
                                if (!other->rb_left || rb_is_black(other->rb_left))
                                {
@@ -272,8 +273,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
                        parent->rb_left = child;
                else
                        parent->rb_right = child;
-       }
-       else
+       } else
                root->rb_node = child;
 
  color:
@@ -320,7 +320,7 @@ struct rb_node *rb_next(const struct rb_node *node)
        if (node->rb_right) {
                node = node->rb_right;
                while (node->rb_left)
-                       node=node->rb_left;
+                       node = node->rb_left;
                return (struct rb_node *)node;
        }
 
@@ -348,7 +348,7 @@ struct rb_node *rb_prev(const struct rb_node *node)
        if (node->rb_left) {
                node = node->rb_left;
                while (node->rb_right)
-                       node=node->rb_right;
+                       node = node->rb_right;
                return (struct rb_node *)node;
        }