]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: coding style cleanup
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 16 Jul 2024 23:06:52 +0000 (01:06 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 16 Jul 2024 23:06:52 +0000 (01:06 +0200)
Solve lots of coding style issues reported by:

./scripts/checkpatch.pl --terse --show-types --strict \
-f $(git ls-files|grep -E '\.[ch]$') \
--ignore MACRO_ARG_REUSE,STRCPY,IF_0,UNNECESSARY_PARENTHESES,CAMELCASE,STRNCPY; done

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
49 files changed:
bitfield.c
bitfield.h
mce-amd-k8.c
mce-amd.c
mce-intel-broadwell-de.c
mce-intel-broadwell-epex.c
mce-intel-dunnington.c
mce-intel-haswell.c
mce-intel-i10nm.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-ampere.h
non-standard-hisi_hip08.c
non-standard-hisilicon.c
non-standard-jaguarmicro.c
ras-aer-handler.c
ras-aer-handler.h
ras-arm-handler.c
ras-cpu-isolation.c
ras-cxl-handler.c
ras-devlink-handler.c
ras-devlink-handler.h
ras-diskerror-handler.c
ras-diskerror-handler.h
ras-events.c
ras-events.h
ras-extlog-handler.c
ras-extlog-handler.h
ras-logger.h
ras-mc-handler.c
ras-mc-handler.h
ras-mce-handler.c
ras-mce-handler.h
ras-memory-failure-handler.h
ras-non-standard-handler.c
ras-page-isolation.c
ras-page-isolation.h
ras-record.c
ras-record.h
ras-report.c
rbtree.c
rbtree.h

index 2076683d1d0dc20004ee90e023a897becc867219..17e154abfcef9e96c2975d19d8b3e4cf19b30216 100644 (file)
@@ -17,7 +17,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
@@ -25,7 +25,7 @@
 #include "ras-mce-handler.h"
 #include "bitfield.h"
 
-unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+unsigned int bitfield_msg(char *buf, size_t len, const char * const *bitarray,
                          unsigned int array_len,
                          unsigned int bit_offset, unsigned int ignore_bits,
                          uint64_t status)
@@ -86,8 +86,9 @@ void decode_bitfield(struct mce_event *e, uint64_t status,
                                continue;
                        mce_snprintf(e->error_msg, "<%u:%llx>",
                                     f->start_bit, (long long)v);
-               } else
+               } else {
                        mce_snprintf(e->error_msg, "%s", s);
+               }
        }
 }
 
index 2b75b4120b82c446b9fc7e140aa35e8795146ce5..b38db429f6417115da4cbffafcbda493c40eb945 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <stdint.h>
 
@@ -60,7 +60,7 @@ static inline int test_prefix(int nr, uint32_t value)
 
 /* Ancillary routines */
 
-unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+unsigned int bitfield_msg(char *buf, size_t len, const char * const *bitarray,
                          unsigned int array_len,
                          unsigned int bit_offset, unsigned int ignore_bits,
                          uint64_t status);
index f27b823dc28cfa86db43c4326b245207487027fe..7906c95e1aafc96d44069d23eda1d306aff5f68d 100644 (file)
@@ -17,7 +17,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <stdio.h>
 #include <string.h>
@@ -33,7 +33,7 @@
 #define K8_MCELOG_THRESHOLD_L3_CACHE (4 * 9 + 2)
 #define K8_MCELOG_THRESHOLD_FBDIMM   (4 * 9 + 3)
 
-static const char *k8bank[] = {
+static const char * const k8bank[] = {
        "data cache",
        "instruction cache",
        "bus unit",
@@ -42,7 +42,7 @@ static const char *k8bank[] = {
        "fixed-issue reoder"
 };
 
-static const char *k8threshold[] = {
+static const char * const k8threshold[] = {
        [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",
@@ -53,35 +53,35 @@ static const char *k8threshold[] = {
                "Unknown threshold counter",
 };
 
-static const char *transaction[] = {
+static const char * const transaction[] = {
        "instruction", "data", "generic", "reserved"
 };
 
-static const char *cachelevel[] = {
+static const char * const cachelevel[] = {
        "0", "1", "2", "generic"
 };
 
-static const char *memtrans[] = {
+static const char * const memtrans[] = {
        "generic error", "generic read", "generic write", "data read",
        "data write", "instruction fetch", "prefetch", "evict", "snoop",
        "?", "?", "?", "?", "?", "?", "?"
 };
 
-static const char *partproc[] = {
+static const char * const partproc[] = {
        "local node origin", "local node response",
        "local node observed", "generic participation"
 };
 
-static const char *timeout[] = {
+static const char * const timeout[] = {
        "request didn't time out",
        "request timed out"
 };
 
-static const char *memoryio[] = {
+static const char * const memoryio[] = {
        "memory", "res.", "i/o", "generic"
 };
 
-static const char *nbextendederr[] = {
+static const char * const nbextendederr[] = {
        "RAM ECC error",
        "CRC error",
        "Sync error",
@@ -103,7 +103,7 @@ static const char *nbextendederr[] = {
        "L3 Cache LRU Error"
 };
 
-static const char *highbits[32] = {
+static const char * const highbits[32] = {
        [31] = "valid",
        [30] = "error overflow (multiple errors)",
        [29] = "error uncorrected",
@@ -264,9 +264,8 @@ int parse_amd_k8_event(struct ras_events *ras, struct mce_event *e)
        if (e->bank == 4) {
                unsigned short exterrcode = (e->status >> 16) & 0x0f;
 
-               if (exterrcode == 5 && (e->status & (1ULL << 61))) {
+               if (exterrcode == 5 && (e->status & (1ULL << 61)))
                        return -1;
-               }
        }
 
        bank_name(e);
index ac0dbac9c6f8ad66b41c67cb4b90c2c6bb405ea4..028a329b3ea845e8fca1a91bed458cae6edea83b 100644 (file)
--- a/mce-amd.c
+++ b/mce-amd.c
@@ -86,10 +86,11 @@ void decode_amd_errcode(struct mce_event *e)
                               "Uncorrected, software restartable error.");
                strcpy(e->error_msg,
                       "Uncorrected, software containable error.");
-       } else if (e->status & MCI_STATUS_DEFERRED)
+       } else if (e->status & MCI_STATUS_DEFERRED) {
                strcpy(e->error_msg, "Deferred error, no action required.");
-       else
+       } else {
                strcpy(e->error_msg, "Corrected error, no action required.");
+       }
 
        if (!(e->status & MCI_STATUS_VAL))
                mce_snprintf(e->mcistatus_msg, "MCE_INVALID");
index 8210782a52b1286470d3b60750f3167d04d9fd43..ad2421c0bcc9c27e9770a65830122229af14b400 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 9c863d9b186f73d5e5098d79c397a836c90435f0..52b38155866247b30439dabf33014c4cd51ebdf4 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 71c3fb4490f74360c2d440c41f08f4be8f398458..1114fd7e16a3cfdd29e27c8d3c0abd50ce7af4df 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 195f6ed8c9fbf631b2a7c4dc765cc06856c0efce..12ec3c3d8bb7dfc4e87c90c1e90fee3779831dae 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index c4ace5624242c4333860437a56284696bad9cd38..a48686689f7d0a1fb92c47ef9e75ad2bff79835a 100644 (file)
@@ -18,7 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <inttypes.h>
 #include <stdio.h>
@@ -299,18 +299,32 @@ static void i10nm_imc_misc(struct mce_event *e)
        uint32_t eccmode = EXTRACT(e->misc, 59, 62);
        uint32_t transient = EXTRACT(e->misc, 63, 63);
 
-       mce_snprintf(e->error_msg, "bank: 0x%x bankgroup: 0x%x row: 0x%x column: 0x%x", bank, bankgroup, row, column);
+       mce_snprintf(e->error_msg,
+                    "bank: 0x%x bankgroup: 0x%x row: 0x%x column: 0x%x",
+                    bank, bankgroup, row, column);
        if (!transient && !EXTRACT(e->status, 61, 61))
                mce_snprintf(e->error_msg, "failed device: 0x%x", fdevice);
        mce_snprintf(e->error_msg, "rank: 0x%x subrank: 0x%x", rank, subrank);
        mce_snprintf(e->error_msg, "ecc mode: ");
        switch (eccmode) {
-       case 0: mce_snprintf(e->error_msg, "SDDC memory mode"); break;
-       case 1: mce_snprintf(e->error_msg, "SDDC"); break;
-       case 4: mce_snprintf(e->error_msg, "ADDDC memory mode"); break;
-       case 5: mce_snprintf(e->error_msg, "ADDDC"); break;
-       case 8: mce_snprintf(e->error_msg, "DDRT read"); break;
-       default: mce_snprintf(e->error_msg, "unknown"); break;
+       case 0:
+               mce_snprintf(e->error_msg, "SDDC memory mode");
+               break;
+       case 1:
+               mce_snprintf(e->error_msg, "SDDC");
+               break;
+       case 4:
+               mce_snprintf(e->error_msg, "ADDDC memory mode");
+               break;
+       case 5:
+               mce_snprintf(e->error_msg, "ADDDC");
+               break;
+       case 8:
+               mce_snprintf(e->error_msg, "DDRT read");
+               break;
+       default:
+               mce_snprintf(e->error_msg, "unknown");
+               break;
        }
        if (transient)
                mce_snprintf(e->error_msg, "transient");
@@ -359,7 +373,7 @@ static enum banktype sapphire[32] = {
        [13 ... 20]     = BT_IMC,
 };
 
-void i10nm_memerr_misc(struct mce_event *e, int *channel);
+static void i10nm_memerr_misc(struct mce_event *e, int *channel);
 
 void i10nm_decode_model(enum cputype cputype, struct ras_events *ras,
                        struct mce_event *e)
@@ -426,12 +440,24 @@ void i10nm_decode_model(enum cputype cputype, struct ras_events *ras,
                mce_snprintf(e->error_msg, "MemCtrl: ");
                f = EXTRACT(status, 16, 23);
                switch (EXTRACT(status, 24, 31)) {
-               case 0: decode_bitfield(e, f, imc0); break;
-               case 1: decode_bitfield(e, f, imc1); break;
-               case 2: decode_bitfield(e, f, imc2); break;
-               case 4: decode_bitfield(e, f, imc4); break;
-               case 8: decode_bitfield(e, f, imc8); break;
-               case 0x10: decode_bitfield(e, f, imc10); break;
+               case 0:
+                       decode_bitfield(e, f, imc0);
+                       break;
+               case 1:
+                       decode_bitfield(e, f, imc1);
+                       break;
+               case 2:
+                       decode_bitfield(e, f, imc2);
+                       break;
+               case 4:
+                       decode_bitfield(e, f, imc4);
+                       break;
+               case 8:
+                       decode_bitfield(e, f, imc8);
+                       break;
+               case 0x10:
+                       decode_bitfield(e, f, imc10);
+                       break;
                }
                i10nm_imc_misc(e);
                break;
@@ -464,7 +490,7 @@ void i10nm_decode_model(enum cputype cputype, struct ras_events *ras,
  * we can derive the channel from the bank number.
  * There can be four memory controllers with two channels each.
  */
-void i10nm_memerr_misc(struct mce_event *e, int *channel)
+static void i10nm_memerr_misc(struct mce_event *e, int *channel)
 {
        uint64_t status = e->status;
        unsigned int chan, imc;
index e5e6a7aaf46f154a10e132ee29c2ebd0949d670d..3204b58b4ae0927903584bf6f3ccdf8de29b097f 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 0e2ea809a127e419d323c393dcea32ca3d2dd6bd..ff00ca935b3feca50a04277c48f10457fc9a565a 100644 (file)
@@ -12,7 +12,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 18992d1b692440a33ca66d182008b385343d5a85..1ab0ef3beeacad0d95cc721a60b23f1c1382e175 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 2751d342a5adf519e557934fe639726706d85434..ecd266f1111d99afec4bdcfce4f29b48c425b161 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 385b1254d6eb6046a2ec947039fdd07b9329e371..6c69f28121a761455c387a62e0cdc14e701cbb49 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 37e5e11bc05e29a0bb359114435e2def89dbdf95..fdf02b9738632354d2b96a2e198c576d1d24c8c8 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index f38d638eb12b876fc175d29dd42e0dcefc8819e1..7607e02cccb9dd3ee1ac58d6664991ae538c7399 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <string.h>
 #include <stdio.h>
index 7f48cc4b03750dc3cec47e840c12e6e0201d68f7..58bcba3afbfcb5bb8d110531db36a7bc83ddfbef 100644 (file)
@@ -17,7 +17,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #include <errno.h>
 #include <fcntl.h>
@@ -164,10 +164,15 @@ static void decode_memory_controller(struct mce_event *e, uint32_t status)
 static void decode_termal_bank(struct mce_event *e)
 {
        if (e->status & 1) {
-               mce_snprintf(e->mcgstatus_msg, "Processor %d heated above trip temperature. Throttling enabled.", e->cpu);
-               mce_snprintf(e->user_action, "Please check your system cooling. Performance will be impacted");
+               mce_snprintf(e->mcgstatus_msg,
+                            "Processor %d heated above trip temperature. Throttling enabled.",
+                            e->cpu);
+               mce_snprintf(e->user_action,
+                            "Please check your system cooling. Performance will be impacted");
        } else {
-               mce_snprintf(e->error_msg, "Processor %d below trip temperature. Throttling disabled", e->cpu);
+               mce_snprintf(e->error_msg,
+                            "Processor %d below trip temperature. Throttling disabled",
+                            e->cpu);
        }
 }
 
@@ -209,9 +214,8 @@ static char *get_RRRR_str(uint8_t rrrr)
        unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(RRRR); i++) {
-               if (RRRR[i].value == rrrr) {
+               if (RRRR[i].value == rrrr)
                        return RRRR[i].str;
-               }
        }
 
        return "UNKNOWN";
@@ -281,8 +285,9 @@ static void decode_mca(struct mce_event *e, uint64_t track, int *ismemerr)
        } else if (test_prefix(7, mca)) {
                decode_memory_controller(e, mca);
                *ismemerr = 1;
-       } else
+       } else {
                mce_snprintf(e->mcastatus_msg, "Unknown Error %x", mca);
+       }
 }
 
 static void decode_tracking(struct mce_event *e, uint64_t track)
index 905e0c57cf9418e03f169ee7c26c4acd7ec69cea..0790323c9d9cd4a5423424be33e5edfc55d2323e 100644 (file)
@@ -1058,8 +1058,9 @@ static int decode_amp_oem_type_error(struct ras_events *ras,
        } else if (payload_type == PAYLOAD_TYPE_3) {
                db_tab = amp_payload3_event_tab;
                id = AMP_PAYLOAD3_FIELD_TIMESTAMP;
-       } else
+       } else {
                return -1;
+       }
 
        if (!ev_decoder->stmt_dec_record) {
                if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
index 1bfe34466c44ee0c631e9471dca7e82af006378d..58c203a547bd1393efef6be7f07659edd8dae4ae 100644 (file)
 #include "ras-events.h"
 #include <traceevent/event-parse.h>
 
-#define SOCKET_NUM(x) ((x >> 14) & 0x3)
-#define PAYLOAD_TYPE(x) ((x >> 6) & 0x3)
-#define TYPE(x) (x & 0x3f)
-#define INSTANCE(x) (x & 0x3fff)
+#define SOCKET_NUM(x) (((x) >> 14) & 0x3)
+#define PAYLOAD_TYPE(x) (((x) >> 6) & 0x3)
+#define TYPE(x) ((x) & 0x3f)
+#define INSTANCE(x) ((x) & 0x3fff)
 #define AMP_PAYLOAD0_BUF_LEN   1024
 #define PAYLOAD_TYPE_0         0x00
 #define PAYLOAD_TYPE_1         0x01
index e482a7adcf7409912a2b215b8de1d19557b97b5a..d90c6bf08017e5d25a32160dc9ce0b3b9b6e22ca 100644 (file)
@@ -185,11 +185,11 @@ enum {
 struct hisi_module_info {
        int id;
        const char *name;
-       const char **sub;
+       const char * const *sub;
        int sub_num;
 };
 
-static const char *pll_submodule_name[] = {
+static const char * const pll_submodule_name[] = {
        "TB_PLL0",
        "TB_PLL1",
        "TB_PLL2",
@@ -205,7 +205,7 @@ static const char *pll_submodule_name[] = {
        "NIMBUS_PLL4",
 };
 
-static const char *sllc_submodule_name[] = {
+static const char * const sllc_submodule_name[] = {
        "TB_SLLC0",
        "TB_SLLC1",
        "TB_SLLC2",
@@ -216,7 +216,7 @@ static const char *sllc_submodule_name[] = {
        "NIMBUS_SLLC1",
 };
 
-static const char *sioe_submodule_name[] = {
+static const char * const sioe_submodule_name[] = {
        "TB_SIOE0",
        "TB_SIOE1",
        "TB_SIOE2",
@@ -229,12 +229,12 @@ static const char *sioe_submodule_name[] = {
        "NIMBUS_SIOE1",
 };
 
-static const char *poe_submodule_name[] = {
+static const char * const poe_submodule_name[] = {
        "TB_POE",
        "TA_POE",
 };
 
-static const char *disp_submodule_name[] = {
+static const char * const disp_submodule_name[] = {
        "TB_PERI_DISP",
        "TB_POE_DISP",
        "TB_GIC_DISP",
@@ -247,7 +247,7 @@ static const char *disp_submodule_name[] = {
        "NETWORK_DISP",
 };
 
-static const char *sas_submodule_name[] = {
+static const char * const sas_submodule_name[] = {
        "SAS0",
        "SAS1",
 };
@@ -321,27 +321,27 @@ static const struct hisi_module_info hisi_oem_type1_module[] = {
        }
 };
 
-static const char *smmu_submodule_name[] = {
+static const char * const smmu_submodule_name[] = {
        "HAC_SMMU",
        "PCIE_SMMU",
        "MGMT_SMMU",
        "NIC_SMMU",
 };
 
-static const char *hllc_submodule_name[] = {
+static const char * const hllc_submodule_name[] = {
        "HLLC0",
        "HLLC1",
        "HLLC2",
 };
 
-static const char *hha_submodule_name[] = {
+static const char * const hha_submodule_name[] = {
        "TB_HHA0",
        "TB_HHA1",
        "TA_HHA0",
        "TA_HHA1"
 };
 
-static const char *ddrc_submodule_name[] = {
+static const char * const ddrc_submodule_name[] = {
        "TB_DDRC0",
        "TB_DDRC1",
        "TB_DDRC2",
@@ -352,7 +352,7 @@ static const char *ddrc_submodule_name[] = {
        "TA_DDRC3",
 };
 
-static const char *l3tag_submodule_name[] = {
+static const char * const l3tag_submodule_name[] = {
        "TB_PARTITION0",
        "TB_PARTITION1",
        "TB_PARTITION2",
@@ -371,7 +371,7 @@ static const char *l3tag_submodule_name[] = {
        "TA_PARTITION7",
 };
 
-static const char *l3data_submodule_name[] = {
+static const char * const l3data_submodule_name[] = {
        "TB_BANK0",
        "TB_BANK1",
        "TB_BANK2",
@@ -427,8 +427,8 @@ static const struct hisi_module_info hisi_oem_type2_module[] = {
        }
 };
 
-static const char *oem_module_name(const struct hisi_module_info *info,
-                                  uint8_t module_id)
+static const char * const oem_module_name(const struct hisi_module_info *info,
+                                         uint8_t module_id)
 {
        const struct hisi_module_info *module = &info[0];
 
@@ -442,13 +442,13 @@ static const char *oem_module_name(const struct hisi_module_info *info,
        return "unknown";
 }
 
-static const char *oem_submodule_name(const struct hisi_module_info *info,
-                                     uint8_t module_id, uint8_t sub_module_id)
+static const char * const oem_submodule_name(const struct hisi_module_info *info,
+                                            uint8_t module_id, uint8_t sub_module_id)
 {
        const struct hisi_module_info *module = &info[0];
 
        for (; module->name; module++) {
-               const char **submodule = module->sub;
+               const char * const *submodule = module->sub;
 
                if (module->id != module_id)
                        continue;
index e9ea5df80d4b6f20a823b1ff98ab02835c2cb0c5..00388ec2e87f7893477c454ffa6e9599625318ee 100644 (file)
@@ -171,13 +171,13 @@ static const struct db_table_descriptor hisi_common_section_tab = {
 };
 #endif
 
-static const char *soc_desc[] = {
+static const char * const soc_desc[] = {
        "Kunpeng916",
        "Kunpeng920",
        "Kunpeng930",
 };
 
-static const char *module_name[] = {
+static const char * const module_name[] = {
        "MN",
        "PLL",
        "SLLC",
@@ -221,7 +221,7 @@ static const char *module_name[] = {
        "HBMC",
 };
 
-static const char *get_soc_desc(uint8_t soc_id)
+static const char * const get_soc_desc(uint8_t soc_id)
 {
        if (soc_id >= sizeof(soc_desc) / sizeof(char *))
                return "unknown";
index cb0a78d5224e8caaff5a9daa51f39ddcb9c8cf41..fb887d34c198b46c6e7cd0bedd7546395fe9e826 100644 (file)
@@ -448,10 +448,14 @@ static const char *get_jm_dev_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t su
 static inline char *jm_err_severity(uint8_t err_sev)
 {
        switch (err_sev) {
-       case JM_ERR_SEVERITY_NFE: return "recoverable";
-       case JM_ERR_SEVERITY_FE: return "fatal";
-       case JM_ERR_SEVERITY_CE: return "corrected";
-       case JM_ERR_SEVERITY_NONE: return "none";
+       case JM_ERR_SEVERITY_NFE:
+               return "recoverable";
+       case JM_ERR_SEVERITY_FE:
+               return "fatal";
+       case JM_ERR_SEVERITY_CE:
+               return "corrected";
+       case JM_ERR_SEVERITY_NONE:
+               return "none";
        default:
                break;
        }
@@ -498,11 +502,13 @@ static void decode_jm_common_sec_head(struct ras_ns_ev_decoder *ev_decoder,
 
        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,
                        0,
-                       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_INT,
                               JM_PAYLOAD_FIELD_MODULE_ID,
                        err->submodule_id, NULL);
@@ -510,10 +516,12 @@ static void decode_jm_common_sec_head(struct ras_ns_ev_decoder *ev_decoder,
 
        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,
-                       0, get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
+                       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,
                                        err->dev_id, NULL);
index 414d89ee34bac36cf11f873a6ddff53afdf9ce71..bc6e77415dacb8ef81b29c5812728bd18024db48 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 4394921a53882b920579f3f732c91c0f27d2f4a1..cb995502727e58a17378a865bccc1db219048b25 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_AER_HANDLER_H
 #define __RAS_AER_HANDLER_H
index c07d957048003f35d842e68dfc2a83daefa9035a..1fa510e3e926bf90a361c1d3468ba8e5fc47c124 100644 (file)
@@ -42,8 +42,9 @@ void display_raw_data(struct trace_seq *s,
                if (++line_count == 4) {
                        trace_seq_printf(s, "\n  %08x: ", i);
                        line_count = 0;
-               } else
+               } else {
                        trace_seq_printf(s, " ");
+               }
        }
 }
 
index 8af31e9dc15173d7296f0173f1797f6574dcc500..2b37ebea4c7aff13d924d4371e30bf17a26b7174 100644 (file)
@@ -84,7 +84,7 @@ static int open_sys_file(unsigned int cpu, int __oflag, const char *format)
        char real_path[PATH_MAX] = "";
 
        snprintf(path, sizeof(path), format, cpu);
-       if (strlen(path) > PATH_MAX || realpath(path, real_path) == NULL) {
+       if (strlen(path) > PATH_MAX || !realpath(path, real_path)) {
                log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__, path);
                return -1;
        }
@@ -178,8 +178,9 @@ static int parse_ul_config(struct isolation_param *config, char *env, unsigned l
                                return -1;
                        }
                        *value = DEC_CHECK * (*value) + (env[i] - '0');
-               } else
+               } else {
                        return -1;
+               }
        }
 
        if (!has_unit)
@@ -391,15 +392,16 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
        }
 
        ret = error_handler(cpu, err_info);
-       if (ret == HANDLE_NOTHING)
+       if (ret == HANDLE_NOTHING) {
                log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu);
-       else if (ret == HANDLE_SUCCEED) {
+       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]);
                clear_queue(cpu_infos[cpu].ce_queue);
                cpu_infos[cpu].ce_nums = 0;
                cpu_infos[cpu].uce_nums = 0;
-       } else
+       } else {
                log(TERM, LOG_WARNING, "Offline cpu%d fail, the state is %s\n",
                    cpu, cpu_state[cpu_infos[cpu].state]);
+       }
 }
index 16a5f76b0001b19ea0d1014b2dce34e677d201dd..cbad347cf31c3114c9a655ab9cef86b3694509b4 100644 (file)
@@ -99,7 +99,8 @@ 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 * const get_cxl_type_str(const char * const *type_array,
+                                          uint8_t num_elems, uint8_t type)
 {
        if (type >= num_elems)
                return "Unknown";
@@ -245,8 +246,11 @@ int ras_cxl_poison_event_handler(struct trace_seq *s,
                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));
-       } else
-               strncpy(ev.overflow_ts, "1970-01-01 00:00:00 +0000", 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)
                return -1;
 
@@ -744,13 +748,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 char *cxl_gmer_mem_event_type[] = {
+static const char * const cxl_gmer_mem_event_type[] = {
        "ECC Error",
        "Invalid Address",
        "Data Path Error",
 };
 
-static const char *cxl_gmer_trans_type[] = {
+static const char * const cxl_gmer_trans_type[] = {
        "Unknown",
        "Host Read",
        "Host Write",
@@ -799,8 +803,9 @@ int ras_cxl_general_media_event_handler(struct trace_seq *s,
        if (tep_get_field_val(s,  event, "type", record, &val, 1) < 0)
                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)
+       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)
                return -1;
 
        if (tep_get_field_val(s,  event, "transaction_type", record, &val, 1) < 0)
@@ -903,7 +908,8 @@ int ras_cxl_dram_event_handler(struct trace_seq *s,
        ev.dpa_flags = val;
        if (trace_seq_printf(s, "dpa_flags:") <= 0)
                return -1;
-       if (decode_cxl_event_flags(s, ev.dpa_flags, cxl_dpa_flags, ARRAY_SIZE(cxl_dpa_flags)) < 0)
+       if (decode_cxl_event_flags(s, ev.dpa_flags, cxl_dpa_flags,
+                                  ARRAY_SIZE(cxl_dpa_flags)) < 0)
                return -1;
 
        if (tep_get_field_val(s,  event, "descriptor", record, &val, 1) < 0)
@@ -918,8 +924,10 @@ int ras_cxl_dram_event_handler(struct trace_seq *s,
        if (tep_get_field_val(s,  event, "type", record, &val, 1) < 0)
                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)
+       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)
                return -1;
 
        if (tep_get_field_val(s,  event, "transaction_type", record, &val, 1) < 0)
@@ -1021,7 +1029,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 char *cxl_dev_evt_type[] = {
+static const char * const cxl_dev_evt_type[] = {
        "Health Status Change",
        "Media Status Change",
        "Life Used Change",
@@ -1045,7 +1053,7 @@ static const struct cxl_event_flags cxl_health_status[] = {
        { .bit = CXL_DHI_HS_HW_REPLACEMENT_NEEDED, .flag = "REPLACEMENT_NEEDED" },
 };
 
-static const char *cxl_media_status[] = {
+static const char * const cxl_media_status[] = {
        "Normal",
        "Not Ready",
        "Write Persistency Lost",
@@ -1058,21 +1066,21 @@ static const char *cxl_media_status[] = {
        "All Data Loss Imminent",
 };
 
-static const char *cxl_two_bit_status[] = {
+static const char * const cxl_two_bit_status[] = {
        "Normal",
        "Warning",
        "Critical",
 };
 
-static const char *cxl_one_bit_status[] = {
+static const char * const cxl_one_bit_status[] = {
        "Normal",
        "Warning",
 };
 
-#define CXL_DHI_AS_LIFE_USED(as)       (as & 0x3)
-#define CXL_DHI_AS_DEV_TEMP(as)                ((as & 0xC) >> 2)
-#define CXL_DHI_AS_COR_VOL_ERR_CNT(as) ((as & 0x10) >> 4)
-#define CXL_DHI_AS_COR_PER_ERR_CNT(as) ((as & 0x20) >> 5)
+#define CXL_DHI_AS_LIFE_USED(as)       ((as) & 0x3)
+#define CXL_DHI_AS_DEV_TEMP(as)                (((as) & 0xC) >> 2)
+#define CXL_DHI_AS_COR_VOL_ERR_CNT(as) (((as) & 0x10) >> 4)
+#define CXL_DHI_AS_COR_PER_ERR_CNT(as) (((as) & 0x20) >> 5)
 
 int ras_cxl_memory_module_event_handler(struct trace_seq *s,
                                        struct tep_record *record,
@@ -1089,8 +1097,10 @@ int ras_cxl_memory_module_event_handler(struct trace_seq *s,
        if (tep_get_field_val(s, event, "event_type", record, &val, 1) < 0)
                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)
+       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)
                return -1;
 
        if (tep_get_field_val(s, event, "health_status", record, &val, 1) < 0)
@@ -1105,27 +1115,33 @@ int ras_cxl_memory_module_event_handler(struct trace_seq *s,
        if (tep_get_field_val(s, event, "media_status", record, &val, 1) < 0)
                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)
+       if (trace_seq_printf(s, "media_status:%s ",
+                            get_cxl_type_str(cxl_media_status,
+                                             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),
+       if (trace_seq_printf(s, "as_life_used:%s ",
+                            get_cxl_type_str(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),
+       if (trace_seq_printf(s, "as_dev_temp:%s ",
+                            get_cxl_type_str(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),
+       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),
                             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),
+       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),
                             CXL_DHI_AS_COR_PER_ERR_CNT(ev.add_status))) <= 0)
                return -1;
 
index dcecc6de740cf5fe63213d80b92951b07ceec9d4..e281cd00ff5f9ccb9e7dee990ad6cc2b05858ed9 100644 (file)
@@ -14,7 +14,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
index 39139e997bbe8f90b1d72f93fdeff3b166033305..ccda865b6937806184016707f3224430596f6e5c 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_DEVLINK_HANDLER_H
 #define __RAS_DEVLINK_HANDLER_H
index 02bb5a7e3d947ef1830cdba37a07a5e0f3c0eec8..0fd27aec516f72ff01b164608c327d5788b828ce 100644 (file)
@@ -14,7 +14,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
index ba4c1ab16daf3c1cbdff645d2c8666b4e4905a44..5f86a9eaeab2bad2132960ca13c5f3585da4bd4a 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_DISKERROR_HANDLER_H
 #define __RAS_DISKERROR_HANDLER_H
index 7fe98c5d9d73a94f41c03a0b35be07515e923aa7..89896a055312f159a615227f6cf157788644bea6 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/poll.h>
-#include <signal.h>
 #include <sys/signalfd.h>
-#include <traceevent/kbuffer.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <traceevent/event-parse.h>
-#include "ras-mc-handler.h"
+#include <traceevent/kbuffer.h>
+#include <unistd.h>
+
 #include "ras-aer-handler.h"
-#include "ras-non-standard-handler.h"
 #include "ras-arm-handler.h"
-#include "ras-mce-handler.h"
-#include "ras-extlog-handler.h"
+#include "ras-cpu-isolation.h"
+#include "ras-cxl-handler.h"
 #include "ras-devlink-handler.h"
 #include "ras-diskerror-handler.h"
-#include "ras-memory-failure-handler.h"
-#include "ras-cxl-handler.h"
-#include "ras-record.h"
+#include "ras-extlog-handler.h"
 #include "ras-logger.h"
+#include "ras-mce-handler.h"
+#include "ras-mc-handler.h"
+#include "ras-memory-failure-handler.h"
+#include "ras-non-standard-handler.h"
 #include "ras-page-isolation.h"
-#include "ras-cpu-isolation.h"
+#include "ras-record.h"
 #include "trigger.h"
 
 /*
@@ -105,7 +107,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
 
        fclose(fp);
        log(ALL, LOG_INFO, "Can't find debugfs\n");
-       return ENOENT;
+       return -ENOENT;
 }
 
 static int open_trace(struct ras_events *ras, char *name, int flags)
@@ -164,7 +166,8 @@ static int is_disabled_event(char *group, char *event)
        snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
                 group, event);
 
-       if (choices_disable && 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;
@@ -519,9 +522,8 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 
        do {
                ready = poll(fds, (n_cpus + 1), -1);
-               if (ready < 0) {
+               if (ready < 0)
                        log(TERM, LOG_WARNING, "poll\n");
-               }
 
                /* check for the signal */
                if (fds[n_cpus].revents & POLLIN) {
@@ -1139,7 +1141,7 @@ int handle_ras_events(int record_events)
                goto err;
        }
 
-       data = calloc(sizeof(*data), cpus);
+       data = calloc(cpus, sizeof(*data));
        if (!data)
                goto err;
 
index f3c53cae5bf54988ea1856ceaa9ab0349caa077a..75ca506f7710f866b5a8cdad984b9b8b8573ed4f 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_EVENTS_H
 #define __RAS_EVENTS_H
index e9e79f5631669141d2f25cd75e0971fea29bdbfb..6ffe9060b437be95cc063a1581cfc651c6e360b9 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #include <ctype.h>
 #include <errno.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <stdint.h>
 #include <traceevent/kbuffer.h>
+
 #include "ras-extlog-handler.h"
-#include "ras-record.h"
 #include "ras-logger.h"
+#include "ras-record.h"
 #include "ras-report.h"
 
 static char *err_type(int etype)
index ce72b4ad746ccb1c225620f5f868657fa50a390b..d9a7b1d543baf3a9c86760ac6112c637a22d4f63 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_EXTLOG_HANDLER_H
 #define __RAS_EXTLOG_HANDLER_H
index 8cab83e67b1de5178c27bc6fb102c54d9e36c0ed..dbf1cb0264ad9eb32d3cfb965600a98445265cfc 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_LOGGER_H
 
 #define ALL    (SYSLOG | TERM)
 /* TODO: global logging limit mask */
 
-#define log(where, level, fmt, args...) do {\
-       if (where & SYSLOG)\
-               syslog(level, fmt, ##args);\
-       if (where & TERM) {\
-               fprintf(stderr, "%s: ", TOOL_NAME);\
-               fprintf(stderr, fmt, ##args);\
-               fflush(stderr);\
-       }\
+#define log(where, level, fmt, args...) do {                   \
+       if ((where) & SYSLOG)                                   \
+               syslog(level, fmt, ##args);                     \
+       if ((where) & TERM) {                                   \
+               fprintf(stderr, "%s: ", TOOL_NAME);             \
+               fprintf(stderr, fmt, ##args);                   \
+               fflush(stderr);                                 \
+       }                                                       \
 } while (0)
 
 #define __RAS_LOGGER_H
index 7bc6c91e3529e3d0a28a27dc5fa12993f649c8c9..5062f9f5b1445254fb33b1f4249884384cb55778 100644 (file)
@@ -14,7 +14,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #define _GNU_SOURCE
 #include <assert.h>
 #include <stdio.h>
@@ -166,8 +167,8 @@ int ras_mc_event_handler(struct trace_seq *s,
        case HW_EVENT_ERR_FATAL:
                ev.error_type = "Fatal";
                break;
-       default:
        case HW_EVENT_ERR_INFO:
+       default:
                ev.error_type = "Info";
        }
 
index a7637b244d084b1a2ca1907baf2583ca660b29af..c39fee3af3b5bda05b1714032ba04f256e5ed1ac 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_MC_HANDLER_H
 #define __RAS_MC_HANDLER_H
index f58e291eb9e704d588d3cadaef0eb9f27d2023fe..fc08988069176198e378008ef6e3d8e91b12c6c1 100644 (file)
@@ -14,7 +14,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
@@ -23,6 +24,7 @@
 #include <unistd.h>
 #include <stdint.h>
 #include <traceevent/kbuffer.h>
+
 #include "ras-mce-handler.h"
 #include "ras-record.h"
 #include "ras-logger.h"
@@ -164,20 +166,19 @@ static int detect_cpu(struct mce_priv *mce)
        f = fopen("/proc/cpuinfo", "r");
        if (!f) {
                log(ALL, LOG_INFO, "Can't open /proc/cpuinfo\n");
-               return errno;
+               return -errno;
        }
 
        while (seen != CPU_ALL && getdelim(&line, &linelen, '\n', f) > 0) {
-               if (sscanf(line, "vendor_id : %63[^\n]",
-                          (char *)&mce->vendor) == 1)
+               if (sscanf(line, "vendor_id : %63[^\n]", (char *)&mce->vendor) == 1) {
                        seen |= CPU_VENDOR;
-               else if (sscanf(line, "cpu family : %d", &mce->family) == 1)
+               } else if (sscanf(line, "cpu family : %d", &mce->family) == 1) {
                        seen |= CPU_FAMILY;
-               else if (sscanf(line, "model : %d", &mce->model) == 1)
+               } else if (sscanf(line, "model : %d", &mce->model) == 1) {
                        seen |= CPU_MODEL;
-               else if (sscanf(line, "cpu MHz : %lf", &mce->mhz) == 1)
+               } else if (sscanf(line, "cpu MHz : %lf", &mce->mhz) == 1) {
                        seen |= CPU_MHZ;
-               else if (!strncmp(line, "flags", 5) && isspace(line[6])) {
+               else if (!strncmp(line, "flags", 5) && isspace(line[6])) {
                        if (mce->processor_flags)
                                free(mce->processor_flags);
                        mce->processor_flags = line;
@@ -187,7 +188,8 @@ static int detect_cpu(struct mce_priv *mce)
                }
        }
        if (!seen) {
-               log(ALL, LOG_INFO, "Can't find a x86 CPU at /proc/cpuinfo. Disabling MCE handler.\n");
+               log(ALL, LOG_INFO,
+                   "Can't find a x86 CPU at /proc/cpuinfo. Disabling MCE handler.\n");
                ret = -ENOENT;
                goto ret;
        }
@@ -199,7 +201,7 @@ static int detect_cpu(struct mce_priv *mce)
                        (seen & CPU_MODEL)  ? "" : " [model]",
                        (seen & CPU_MHZ)    ? "" : " [cpu MHz]",
                        (seen & CPU_FLAGS)  ? "" : " [flags]");
-               ret = EINVAL;
+               ret = -EINVAL;
                goto ret;
        }
 
@@ -217,18 +219,18 @@ static int detect_cpu(struct mce_priv *mce)
                        log(ALL, LOG_INFO,
                            "Can't parse MCE for this AMD CPU yet %d\n",
                            mce->family);
-                       ret = EINVAL;
+                       ret = -EINVAL;
                }
                goto ret;
        } else if (!strcmp(mce->vendor, "HygonGenuine")) {
-               if (mce->family == 24) {
+               if (mce->family == 24)
                        mce->cputype = CPU_DHYANA;
-               }
+
                goto ret;
        } else if (!strcmp(mce->vendor, "GenuineIntel")) {
                mce->cputype = select_intel_cputype(mce);
        } else {
-               ret = EINVAL;
+               ret = -EINVAL;
        }
 
 ret:
@@ -257,7 +259,7 @@ int register_mce_handler(struct ras_events *ras, unsigned int ncpus)
                        free(mce->processor_flags);
                free(ras->mce_priv);
                ras->mce_priv = NULL;
-               return (rc);
+               return rc;
        }
        switch (mce->cputype) {
        case CPU_SANDY_BRIDGE_EP:
index 407ee45a1832c07790cf1c74a0f1780edcfed0c2..74d913a5ae2c5736f0cf2ad35d7dbc45753ba794 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_MCE_HANDLER_H
 #define __RAS_MCE_HANDLER_H
index 7fbfd337a883c770c2f422c778663d7c08423e73..e299eae4b0f0065faed40d95885bdb55dcc56054 100644 (file)
@@ -10,7 +10,7 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
-*/
+ */
 
 #ifndef __RAS_MEMORY_FAILURE_HANDLER_H
 #define __RAS_MEMORY_FAILURE_HANDLER_H
index e21455aac686159c9b574f3882580b4f42fef913..19dd0c97e96871fc53844221a85b2398a4ca02f1 100644 (file)
@@ -26,7 +26,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]);
+       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)
@@ -253,8 +255,9 @@ int ras_non_standard_event_handler(struct trace_seq *s,
                        if (++line_count == 4) {
                                trace_seq_printf(s, "\n  %08x: ", i);
                                line_count = 0;
-                       } else
+                       } else {
                                trace_seq_printf(s, " ");
+                       }
                }
        }
 
index 89f8c153b8887044340c7a18beb82878a960caf1..4ef3caec94d42a990ef4a8b982ba02dc2ff31250 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
-*/
+ */
 
 #include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
+#include <stdlib.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+#include <unistd.h>
+
 #include "ras-logger.h"
 #include "ras-page-isolation.h"
 
@@ -53,7 +54,7 @@ static struct isolation cycle = {
        .unit = "h",
 };
 
-static const char *kernel_offline[] = {
+static const char * const kernel_offline[] = {
        [OFFLINE_SOFT]           = "/sys/devices/system/memory/soft_offline_page",
        [OFFLINE_HARD]           = "/sys/devices/system/memory/hard_offline_page",
        [OFFLINE_SOFT_THEN_HARD] = "/sys/devices/system/memory/soft_offline_page",
@@ -68,7 +69,7 @@ static const struct config offline_choice[] = {
        {}
 };
 
-static const char *page_state[] = {
+static const char * const page_state[] = {
        [PAGE_ONLINE]           = "online",
        [PAGE_OFFLINE]          = "offlined",
        [PAGE_OFFLINE_FAILED]   = "offline-failed",
@@ -150,8 +151,8 @@ parse:
                if (!no_unit)
                        config->unit = unit;
        } else {
-                log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
-                    config->name, config->env);
+               log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
+                   config->name, config->env);
        }
 
        /* if env value string is greater than ulong_max, truncate the last digit */
@@ -219,15 +220,18 @@ static int do_page_offline(unsigned long long addr, enum otype type)
 
        fd = open(kernel_offline[type], O_WRONLY);
        if (fd == -1) {
-               log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__, kernel_offline[type]);
+               log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__,
+                   kernel_offline[type]);
                return -1;
        }
 
        sprintf(buf, "%#llx", addr);
        rc = write(fd, buf, strlen(buf));
-       if (rc < 0) {
-               log(TERM, LOG_ERR, "page offline addr(%s) by %s failed, errno:%d\n", buf, kernel_offline[type], errno);
-       }
+       if (rc < 0)
+               log(TERM, LOG_ERR,
+                   "page offline addr(%s) by %s failed, errno:%d\n",
+                   buf, kernel_offline[type], errno);
+
        close(fd);
        return rc;
 }
@@ -307,13 +311,12 @@ static struct page_record *page_lookup_insert(unsigned long long addr)
        while (*entry) {
                parent = *entry;
                pr = rb_entry(parent, struct page_record, entry);
-               if (addr == pr->addr) {
+               if (addr == pr->addr)
                        return pr;
-               } else if (addr < pr->addr) {
+               else if (addr < pr->addr)
                        entry = &(*entry)->rb_left;
-               } else {
+               else
                        entry = &(*entry)->rb_right;
-               }
        }
 
        find = calloc(1, sizeof(struct page_record));
index 0482e1e6985b8df055a2df3a8eccae4647e2a68d..7ccfca16a048978f7f01484519476b9f24375627 100644 (file)
@@ -10,7 +10,7 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
-*/
+ */
 
 #ifndef __RAS_PAGE_ISOLATION_H
 #define __RAS_PAGE_ISOLATION_H
index 56c25cbede62f1be2ff0a983a86f51a35fb93c07..490934e1887500d9a950eedbb60376f8150fc419 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 /*
  * BuildRequires: sqlite-devel
@@ -885,7 +885,8 @@ static const struct db_table_descriptor cxl_general_media_event_tab = {
        .num_fields = ARRAY_SIZE(cxl_general_media_event_fields),
 };
 
-int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
+int ras_store_cxl_general_media_event(struct ras_events *ras,
+                                     struct ras_cxl_general_media_event *ev)
 {
        int rc;
        struct sqlite3_priv *priv = ras->db_priv;
@@ -1031,7 +1032,8 @@ static const struct db_table_descriptor cxl_memory_module_event_tab = {
        .num_fields = ARRAY_SIZE(cxl_memory_module_event_fields),
 };
 
-int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev)
+int ras_store_cxl_memory_module_event(struct ras_events *ras,
+                                     struct ras_cxl_memory_module_event *ev)
 {
        int rc;
        struct sqlite3_priv *priv = ras->db_priv;
index c3738baf048832d68352bfba039cc05b1380dc53..e8ed26326e04a57fc2c1c8aea75d2ec1776737fe 100644 (file)
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
 
 #ifndef __RAS_RECORD_H
 #define __RAS_RECORD_H
@@ -321,41 +321,71 @@ int ras_mc_finalize_vendor_table(sqlite3_stmt *stmt);
 int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
 int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
 int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev);
-int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev);
-int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev);
+int ras_store_extlog_mem_record(struct ras_events *ras,
+                               struct ras_extlog_event *ev);
+int ras_store_non_standard_record(struct ras_events *ras,
+                                 struct ras_non_standard_event *ev);
 int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev);
 int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev);
-int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev);
+int ras_store_diskerror_event(struct ras_events *ras,
+                             struct diskerror_event *ev);
 int ras_store_mf_event(struct ras_events *ras, struct ras_mf_event *ev);
-int ras_store_cxl_poison_event(struct ras_events *ras, struct ras_cxl_poison_event *ev);
-int ras_store_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev);
-int ras_store_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev);
-int ras_store_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev);
-int ras_store_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev);
-int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev);
-int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev);
-int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev);
+int ras_store_cxl_poison_event(struct ras_events *ras,
+                              struct ras_cxl_poison_event *ev);
+int ras_store_cxl_aer_ue_event(struct ras_events *ras,
+                              struct ras_cxl_aer_ue_event *ev);
+int ras_store_cxl_aer_ce_event(struct ras_events *ras,
+                              struct ras_cxl_aer_ce_event *ev);
+int ras_store_cxl_overflow_event(struct ras_events *ras,
+                                struct ras_cxl_overflow_event *ev);
+int ras_store_cxl_generic_event(struct ras_events *ras,
+                               struct ras_cxl_generic_event *ev);
+int ras_store_cxl_general_media_event(struct ras_events *ras,
+                                     struct ras_cxl_general_media_event *ev);
+int ras_store_cxl_dram_event(struct ras_events *ras,
+                            struct ras_cxl_dram_event *ev);
+int ras_store_cxl_memory_module_event(struct ras_events *ras,
+                                     struct ras_cxl_memory_module_event *ev);
 
 #else
-static inline int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras) { return 0; };
-static inline int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras) { return 0; };
-static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
-static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
-static inline int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev) { return 0; };
-static inline int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev) { return 0; };
-static inline int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev) { return 0; };
-static inline int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev) { return 0; };
-static inline int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev) { return 0; };
-static inline int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev) { return 0; };
-static inline int ras_store_mf_event(struct ras_events *ras, struct ras_mf_event *ev) { return 0; };
-static inline int ras_store_cxl_poison_event(struct ras_events *ras, struct ras_cxl_poison_event *ev) { return 0; };
-static inline int ras_store_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev) { return 0; };
-static inline int ras_store_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev) { return 0; };
-static inline int ras_store_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev) { return 0; };
-static inline int ras_store_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev) { return 0; };
-static inline int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev) { return 0; };
-static inline int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev) { return 0; };
-static inline int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev) { return 0; };
+static inline int ras_mc_event_opendb(unsigned int cpu,
+                                     struct ras_events *ras) { return 0; };
+static inline int ras_mc_event_closedb(unsigned int cpu,
+                                      struct ras_events *ras) { return 0; };
+static inline int ras_store_mc_event(struct ras_events *ras,
+                                    struct ras_mc_event *ev) { return 0; };
+static inline int ras_store_aer_event(struct ras_events *ras,
+                                     struct ras_aer_event *ev) { return 0; };
+static inline int ras_store_mce_record(struct ras_events *ras,
+                                      struct mce_event *ev) { return 0; };
+static inline int ras_store_extlog_mem_record(struct ras_events *ras,
+                                             struct ras_extlog_event *ev) { return 0; };
+static inline int ras_store_non_standard_record(struct ras_events *ras,
+                                               struct ras_non_standard_event *ev) { return 0; };
+static inline int ras_store_arm_record(struct ras_events *ras,
+                                      struct ras_arm_event *ev) { return 0; };
+static inline int ras_store_devlink_event(struct ras_events *ras,
+                                         struct devlink_event *ev) { return 0; };
+static inline int ras_store_diskerror_event(struct ras_events *ras,
+                                           struct diskerror_event *ev) { return 0; };
+static inline int ras_store_mf_event(struct ras_events *ras,
+                                    struct ras_mf_event *ev) { return 0; };
+static inline int ras_store_cxl_poison_event(struct ras_events *ras,
+                                            struct ras_cxl_poison_event *ev) { return 0; };
+static inline int ras_store_cxl_aer_ue_event(struct ras_events *ras,
+                                            struct ras_cxl_aer_ue_event *ev) { return 0; };
+static inline int ras_store_cxl_aer_ce_event(struct ras_events *ras,
+                                            struct ras_cxl_aer_ce_event *ev) { return 0; };
+static inline int ras_store_cxl_overflow_event(struct ras_events *ras,
+                                              struct ras_cxl_overflow_event *ev) { return 0; };
+static inline int ras_store_cxl_generic_event(struct ras_events *ras,
+                                             struct ras_cxl_generic_event *ev) { return 0; };
+static inline int ras_store_cxl_general_media_event(struct ras_events *ras,
+                                                   struct ras_cxl_general_media_event *ev) { return 0; };
+static inline int ras_store_cxl_dram_event(struct ras_events *ras,
+                                          struct ras_cxl_dram_event *ev) { return 0; };
+static inline int ras_store_cxl_memory_module_event(struct ras_events *ras,
+                                                   struct ras_cxl_memory_module_event *ev) { return 0; };
 
 #endif
 
index 5cc55b6cd9dd6cd534e3fe0ce13ba0bcdd93190a..cf841ec9e38c7a39a21d4926129e94e72c41d033 100644 (file)
@@ -28,9 +28,8 @@ static int setup_report_socket(void)
        struct sockaddr_un addr;
 
        sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (sockfd < 0) {
+       if (sockfd < 0)
                return -1;
-       }
 
        memset(&addr, 0, sizeof(struct sockaddr_un));
        addr.sun_family = AF_UNIX;
@@ -52,44 +51,38 @@ static int commit_report_basic(int sockfd)
        struct utsname un;
        int rc = -1;
 
-       if (sockfd < 0) {
+       if (sockfd < 0)
                return rc;
-       }
 
        memset(buf, 0, INPUT_BUFFER_SIZE);
        memset(&un, 0, sizeof(struct utsname));
 
        rc = uname(&un);
-       if (rc < 0) {
+       if (rc < 0)
                return rc;
-       }
 
        /*
         * ABRT server protocol
         */
        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;
 }
@@ -101,33 +94,33 @@ static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "error_count=%d\n"      \
-                                               "error_type=%s\n"       \
-                                               "msg=%s\n"      \
-                                               "label=%s\n"    \
-                                               "mc_index=%c\n" \
-                                               "top_layer=%c\n"        \
-                                               "middle_layer=%c\n"     \
-                                               "lower_layer=%c\n"      \
-                                               "address=%llu\n"        \
-                                               "grain=%llu\n"  \
-                                               "syndrome=%llu\n"       \
-                                               "driver_detail=%s\n",   \
-                                               ev->timestamp,  \
-                                               ev->error_count,        \
-                                               ev->error_type, \
-                                               ev->msg,        \
-                                               ev->label,      \
-                                               ev->mc_index,   \
-                                               ev->top_layer,  \
-                                               ev->middle_layer,       \
-                                               ev->lower_layer,        \
-                                               ev->address,    \
-                                               ev->grain,      \
-                                               ev->syndrome,   \
-                                               ev->driver_detail);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "error_count=%d\n"
+               "error_type=%s\n"
+               "msg=%s\n"
+               "label=%s\n"
+               "mc_index=%c\n"
+               "top_layer=%c\n"
+               "middle_layer=%c\n"
+               "lower_layer=%c\n"
+               "address=%llu\n"
+               "grain=%llu\n"
+               "syndrome=%llu\n"
+               "driver_detail=%s\n",
+               ev->timestamp,
+               ev->error_count,
+               ev->error_type,
+               ev->msg,
+               ev->label,
+               ev->mc_index,
+               ev->top_layer,
+               ev->middle_layer,
+               ev->lower_layer,
+               ev->address,
+               ev->grain,
+               ev->syndrome,
+               ev->driver_detail);
 
        strcat(buf, bt_buf);
 
@@ -141,53 +134,53 @@ static int set_mce_event_backtrace(char *buf, struct mce_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "bank_name=%s\n"        \
-                                               "error_msg=%s\n"        \
-                                               "mcgstatus_msg=%s\n"    \
-                                               "mcistatus_msg=%s\n"    \
-                                               "mcastatus_msg=%s\n"    \
-                                               "user_action=%s\n"      \
-                                               "mc_location=%s\n"      \
-                                               "mcgcap=%lu\n"  \
-                                               "mcgstatus=%lu\n"       \
-                                               "status=%lu\n"  \
-                                               "addr=%lu\n"    \
-                                               "misc=%lu\n"    \
-                                               "ip=%lu\n"      \
-                                               "tsc=%lu\n"     \
-                                               "walltime=%lu\n"        \
-                                               "cpu=%u\n"      \
-                                               "cpuid=%u\n"    \
-                                               "apicid=%u\n"   \
-                                               "socketid=%u\n" \
-                                               "cs=%d\n"       \
-                                               "bank=%d\n"     \
-                                               "cpuvendor=%d\n",       \
-                                               ev->timestamp,  \
-                                               ev->bank_name,  \
-                                               ev->error_msg,  \
-                                               ev->mcgstatus_msg,      \
-                                               ev->mcistatus_msg,      \
-                                               ev->mcastatus_msg,      \
-                                               ev->user_action,        \
-                                               ev->mc_location,        \
-                                               ev->mcgcap,     \
-                                               ev->mcgstatus,  \
-                                               ev->status,     \
-                                               ev->addr,       \
-                                               ev->misc,       \
-                                               ev->ip, \
-                                               ev->tsc,        \
-                                               ev->walltime,   \
-                                               ev->cpu,        \
-                                               ev->cpuid,      \
-                                               ev->apicid,     \
-                                               ev->socketid,   \
-                                               ev->cs, \
-                                               ev->bank,       \
-                                               ev->cpuvendor);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "bank_name=%s\n"
+               "error_msg=%s\n"
+               "mcgstatus_msg=%s\n"
+               "mcistatus_msg=%s\n"
+               "mcastatus_msg=%s\n"
+               "user_action=%s\n"
+               "mc_location=%s\n"
+               "mcgcap=%lu\n"
+               "mcgstatus=%lu\n"
+               "status=%lu\n"
+               "addr=%lu\n"
+               "misc=%lu\n"
+               "ip=%lu\n"
+               "tsc=%lu\n"
+               "walltime=%lu\n"
+               "cpu=%u\n"
+               "cpuid=%u\n"
+               "apicid=%u\n"
+               "socketid=%u\n"
+               "cs=%d\n"
+               "bank=%d\n"
+               "cpuvendor=%d\n",
+               ev->timestamp,
+               ev->bank_name,
+               ev->error_msg,
+               ev->mcgstatus_msg,
+               ev->mcistatus_msg,
+               ev->mcastatus_msg,
+               ev->user_action,
+               ev->mc_location,
+               ev->mcgcap,
+               ev->mcgstatus,
+               ev->status,
+               ev->addr,
+               ev->misc,
+               ev->ip,
+               ev->tsc,
+               ev->walltime,
+               ev->cpu,
+               ev->cpuid,
+               ev->apicid,
+               ev->socketid,
+               ev->cs,
+               ev->bank,
+               ev->cpuvendor);
 
        strcat(buf, bt_buf);
 
@@ -201,15 +194,15 @@ static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "error_type=%s\n"       \
-                                               "dev_name=%s\n" \
-                                               "msg=%s\n",     \
-                                               ev->timestamp,  \
-                                               ev->error_type, \
-                                               ev->dev_name,   \
-                                               ev->msg);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "error_type=%s\n"
+               "dev_name=%s\n"
+               "msg=%s\n",
+               ev->timestamp,
+               ev->error_type,
+               ev->dev_name,
+               ev->msg);
 
        strcat(buf, bt_buf);
 
@@ -223,13 +216,13 @@ static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_e
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "severity=%s\n" \
-                                               "length=%d\n",  \
-                                               ev->timestamp,  \
-                                               ev->severity,   \
-                                               ev->length);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "severity=%s\n"
+               "length=%d\n",
+               ev->timestamp,
+               ev->severity,
+               ev->length);
 
        strcat(buf, bt_buf);
 
@@ -243,21 +236,21 @@ static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "error_count=%d\n"      \
-                                               "affinity=%d\n" \
-                                               "mpidr=0x%lx\n" \
-                                               "midr=0x%lx\n"  \
-                                               "running_state=%d\n"    \
-                                               "psci_state=%d\n",      \
-                                               ev->timestamp,  \
-                                               ev->error_count,        \
-                                               ev->affinity,   \
-                                               ev->mpidr,      \
-                                               ev->midr,       \
-                                               ev->running_state,      \
-                                               ev->psci_state);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "error_count=%d\n"
+               "affinity=%d\n"
+               "mpidr=0x%lx\n"
+               "midr=0x%lx\n"
+               "running_state=%d\n"
+               "psci_state=%d\n",
+               ev->timestamp,
+               ev->error_count,
+               ev->affinity,
+               ev->mpidr,
+               ev->midr,
+               ev->running_state,
+               ev->psci_state);
 
        strcat(buf, bt_buf);
 
@@ -271,19 +264,19 @@ static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "bus_name=%s\n"         \
-                                               "dev_name=%s\n"         \
-                                               "driver_name=%s\n"      \
-                                               "reporter_name=%s\n"    \
-                                               "msg=%s\n",             \
-                                               ev->timestamp,          \
-                                               ev->bus_name,           \
-                                               ev->dev_name,           \
-                                               ev->driver_name,        \
-                                               ev->reporter_name,      \
-                                               ev->msg);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "bus_name=%s\n"
+               "dev_name=%s\n"
+               "driver_name=%s\n"
+               "reporter_name=%s\n"
+               "msg=%s\n",
+               ev->timestamp,
+               ev->bus_name,
+               ev->dev_name,
+               ev->driver_name,
+               ev->reporter_name,
+               ev->msg);
 
        strcat(buf, bt_buf);
 
@@ -297,21 +290,21 @@ static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev)
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "dev=%s\n"              \
-                                               "sector=%llu\n"         \
-                                               "nr_sector=%u\n"        \
-                                               "error=%s\n"            \
-                                               "rwbs=%s\n"             \
-                                               "cmd=%s\n",             \
-                                               ev->timestamp,          \
-                                               ev->dev,                \
-                                               ev->sector,             \
-                                               ev->nr_sector,          \
-                                               ev->error,              \
-                                               ev->rwbs,               \
-                                               ev->cmd);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "dev=%s\n"
+               "sector=%llu\n"
+               "nr_sector=%u\n"
+               "error=%s\n"
+               "rwbs=%s\n"
+               "cmd=%s\n",
+               ev->timestamp,
+               ev->dev,
+               ev->sector,
+               ev->nr_sector,
+               ev->error,
+               ev->rwbs,
+               ev->cmd);
 
        strcat(buf, bt_buf);
 
@@ -325,15 +318,15 @@ static int set_mf_event_backtrace(char *buf, struct ras_mf_event *ev)
        if (!buf || !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);
+       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);
 
        strcat(buf, bt_buf);
 
@@ -347,33 +340,33 @@ static int set_cxl_poison_event_backtrace(char *buf, struct ras_cxl_poison_event
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "trace_type=%s\n"       \
-                                               "region=%s\n"           \
-                                               "region_uuid=%s\n"      \
-                                               "hpa=0x%lx\n"           \
-                                               "dpa=0x%lx\n"           \
-                                               "dpa_length=0x%x\n"     \
-                                               "source=%s\n"           \
-                                               "flags=%u\n"            \
-                                               "overflow_timestamp=%s\n", \
-                                               ev->timestamp,          \
-                                               ev->memdev,             \
-                                               ev->host,               \
-                                               ev->serial,             \
-                                               ev->trace_type,         \
-                                               ev->region,             \
-                                               ev->uuid,               \
-                                               ev->hpa,                \
-                                               ev->dpa,                \
-                                               ev->dpa_length,         \
-                                               ev->source,             \
-                                               ev->flags,              \
-                                               ev->overflow_ts);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "trace_type=%s\n"
+               "region=%s\n"
+               "region_uuid=%s\n"
+               "hpa=0x%lx\n"
+               "dpa=0x%lx\n"
+               "dpa_length=0x%x\n"
+               "source=%s\n"
+               "flags=%u\n"
+               "overflow_timestamp=%s\n",
+               ev->timestamp,
+               ev->memdev,
+               ev->host,
+               ev->serial,
+               ev->trace_type,
+               ev->region,
+               ev->uuid,
+               ev->hpa,
+               ev->dpa,
+               ev->dpa_length,
+               ev->source,
+               ev->flags,
+               ev->overflow_ts);
 
        strcat(buf, bt_buf);
 
@@ -387,19 +380,19 @@ static int set_cxl_aer_ue_event_backtrace(char *buf, struct ras_cxl_aer_ue_event
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "error_status=%u\n"     \
-                                               "first_error=%u\n",     \
-                                               ev->timestamp,          \
-                                               ev->memdev,             \
-                                               ev->host,               \
-                                               ev->serial,             \
-                                               ev->error_status,       \
-                                               ev->first_error);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "error_status=%u\n"
+               "first_error=%u\n",
+               ev->timestamp,
+               ev->memdev,
+               ev->host,
+               ev->serial,
+               ev->error_status,
+               ev->first_error);
 
        strcat(buf, bt_buf);
 
@@ -413,17 +406,17 @@ static int set_cxl_aer_ce_event_backtrace(char *buf, struct ras_cxl_aer_ce_event
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "error_status=%u\n",    \
-                                               ev->timestamp,          \
-                                               ev->memdev,             \
-                                               ev->host,               \
-                                               ev->serial,             \
-                                               ev->error_status);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "error_status=%u\n",
+               ev->timestamp,
+               ev->memdev,
+               ev->host,
+               ev->serial,
+               ev->error_status);
 
        strcat(buf, bt_buf);
 
@@ -437,23 +430,23 @@ static int set_cxl_overflow_event_backtrace(char *buf, struct ras_cxl_overflow_e
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "log_type=%s\n"         \
-                                               "count=%u\n"            \
-                                               "first_ts=%s\n"         \
-                                               "last_ts=%s\n",         \
-                                               ev->timestamp,          \
-                                               ev->memdev,             \
-                                               ev->host,               \
-                                               ev->serial,             \
-                                               ev->log_type,           \
-                                               ev->count,              \
-                                               ev->first_ts,           \
-                                               ev->last_ts);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "log_type=%s\n"
+               "count=%u\n"
+               "first_ts=%s\n"
+               "last_ts=%s\n",
+               ev->timestamp,
+               ev->memdev,
+               ev->host,
+               ev->serial,
+               ev->log_type,
+               ev->count,
+               ev->first_ts,
+               ev->last_ts);
 
        strcat(buf, bt_buf);
 
@@ -467,31 +460,31 @@ static int set_cxl_generic_event_backtrace(char *buf, struct ras_cxl_generic_eve
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "log_type=%s\n"         \
-                                               "hdr_uuid=%s\n"         \
-                                               "hdr_flags=0x%x\n"      \
-                                               "hdr_handle=0x%x\n"     \
-                                               "hdr_related_handle=0x%x\n"     \
-                                               "hdr_timestamp=%s\n"    \
-                                               "hdr_length=%u\n"       \
-                                               "hdr_maint_op_class=%u\n",      \
-                                               ev->hdr.timestamp,      \
-                                               ev->hdr.memdev,         \
-                                               ev->hdr.host,           \
-                                               ev->hdr.serial,         \
-                                               ev->hdr.log_type,       \
-                                               ev->hdr.hdr_uuid,       \
-                                               ev->hdr.hdr_flags,      \
-                                               ev->hdr.hdr_handle,     \
-                                               ev->hdr.hdr_related_handle,     \
-                                               ev->hdr.hdr_timestamp,  \
-                                               ev->hdr.hdr_length,     \
-                                               ev->hdr.hdr_maint_op_class);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "log_type=%s\n"
+               "hdr_uuid=%s\n"
+               "hdr_flags=0x%x\n"
+               "hdr_handle=0x%x\n"
+               "hdr_related_handle=0x%x\n"
+               "hdr_timestamp=%s\n"
+               "hdr_length=%u\n"
+               "hdr_maint_op_class=%u\n",
+               ev->hdr.timestamp,
+               ev->hdr.memdev,
+               ev->hdr.host,
+               ev->hdr.serial,
+               ev->hdr.log_type,
+               ev->hdr.hdr_uuid,
+               ev->hdr.hdr_flags,
+               ev->hdr.hdr_handle,
+               ev->hdr.hdr_related_handle,
+               ev->hdr.hdr_timestamp,
+               ev->hdr.hdr_length,
+               ev->hdr.hdr_maint_op_class);
 
        strcat(buf, bt_buf);
 
@@ -505,47 +498,47 @@ static int set_cxl_general_media_event_backtrace(char *buf, struct ras_cxl_gener
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "log_type=%s\n"         \
-                                               "hdr_uuid=%s\n"         \
-                                               "hdr_flags=0x%x\n"      \
-                                               "hdr_handle=0x%x\n"     \
-                                               "hdr_related_handle=0x%x\n"     \
-                                               "hdr_timestamp=%s\n"    \
-                                               "hdr_length=%u\n"       \
-                                               "hdr_maint_op_class=%u\n"       \
-                                               "dpa=0x%lx\n"           \
-                                               "dpa_flags=%u\n"        \
-                                               "descriptor=%u\n"       \
-                                               "type=%u\n"             \
-                                               "transaction_type=%u\n" \
-                                               "channel=%u\n"          \
-                                               "rank=%u\n"             \
-                                               "device=0x%x\n",        \
-                                               ev->hdr.timestamp,      \
-                                               ev->hdr.memdev,         \
-                                               ev->hdr.host,           \
-                                               ev->hdr.serial,         \
-                                               ev->hdr.log_type,       \
-                                               ev->hdr.hdr_uuid,       \
-                                               ev->hdr.hdr_flags,      \
-                                               ev->hdr.hdr_handle,     \
-                                               ev->hdr.hdr_related_handle,     \
-                                               ev->hdr.hdr_timestamp,  \
-                                               ev->hdr.hdr_length,     \
-                                               ev->hdr.hdr_maint_op_class,     \
-                                               ev->dpa,                \
-                                               ev->dpa_flags,          \
-                                               ev->descriptor,         \
-                                               ev->type,               \
-                                               ev->transaction_type,   \
-                                               ev->channel,            \
-                                               ev->rank,               \
-                                               ev->device);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "log_type=%s\n"
+               "hdr_uuid=%s\n"
+               "hdr_flags=0x%x\n"
+               "hdr_handle=0x%x\n"
+               "hdr_related_handle=0x%x\n"
+               "hdr_timestamp=%s\n"
+               "hdr_length=%u\n"
+               "hdr_maint_op_class=%u\n"
+               "dpa=0x%lx\n"
+               "dpa_flags=%u\n"
+               "descriptor=%u\n"
+               "type=%u\n"
+               "transaction_type=%u\n"
+               "channel=%u\n"
+               "rank=%u\n"
+               "device=0x%x\n",
+               ev->hdr.timestamp,
+               ev->hdr.memdev,
+               ev->hdr.host,
+               ev->hdr.serial,
+               ev->hdr.log_type,
+               ev->hdr.hdr_uuid,
+               ev->hdr.hdr_flags,
+               ev->hdr.hdr_handle,
+               ev->hdr.hdr_related_handle,
+               ev->hdr.hdr_timestamp,
+               ev->hdr.hdr_length,
+               ev->hdr.hdr_maint_op_class,
+               ev->dpa,
+               ev->dpa_flags,
+               ev->descriptor,
+               ev->type,
+               ev->transaction_type,
+               ev->channel,
+               ev->rank,
+               ev->device);
 
        strcat(buf, bt_buf);
 
@@ -559,55 +552,55 @@ static int set_cxl_dram_event_backtrace(char *buf, struct ras_cxl_dram_event *ev
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "log_type=%s\n"         \
-                                               "hdr_uuid=%s\n"         \
-                                               "hdr_flags=0x%x\n"      \
-                                               "hdr_handle=0x%x\n"     \
-                                               "hdr_related_handle=0x%x\n"     \
-                                               "hdr_timestamp=%s\n"    \
-                                               "hdr_length=%u\n"       \
-                                               "hdr_maint_op_class=%u\n"       \
-                                               "dpa=0x%lx\n"           \
-                                               "dpa_flags=%u\n"        \
-                                               "descriptor=%u\n"       \
-                                               "type=%u\n"             \
-                                               "transaction_type=%u\n" \
-                                               "channel=%u\n"          \
-                                               "rank=%u\n"             \
-                                               "nibble_mask=%u\n"      \
-                                               "bank_group=%u\n"       \
-                                               "bank=%u\n"             \
-                                               "row=%u\n"              \
-                                               "column=%u\n",          \
-                                               ev->hdr.timestamp,      \
-                                               ev->hdr.memdev,         \
-                                               ev->hdr.host,           \
-                                               ev->hdr.serial,         \
-                                               ev->hdr.log_type,       \
-                                               ev->hdr.hdr_uuid,       \
-                                               ev->hdr.hdr_flags,      \
-                                               ev->hdr.hdr_handle,     \
-                                               ev->hdr.hdr_related_handle,     \
-                                               ev->hdr.hdr_timestamp,  \
-                                               ev->hdr.hdr_length,     \
-                                               ev->hdr.hdr_maint_op_class,     \
-                                               ev->dpa,                \
-                                               ev->dpa_flags,          \
-                                               ev->descriptor,         \
-                                               ev->type,               \
-                                               ev->transaction_type,   \
-                                               ev->channel,            \
-                                               ev->rank,               \
-                                               ev->nibble_mask,        \
-                                               ev->bank_group,         \
-                                               ev->bank,               \
-                                               ev->row,                \
-                                               ev->column);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "log_type=%s\n"
+               "hdr_uuid=%s\n"
+               "hdr_flags=0x%x\n"
+               "hdr_handle=0x%x\n"
+               "hdr_related_handle=0x%x\n"
+               "hdr_timestamp=%s\n"
+               "hdr_length=%u\n"
+               "hdr_maint_op_class=%u\n"
+               "dpa=0x%lx\n"
+               "dpa_flags=%u\n"
+               "descriptor=%u\n"
+               "type=%u\n"
+               "transaction_type=%u\n"
+               "channel=%u\n"
+               "rank=%u\n"
+               "nibble_mask=%u\n"
+               "bank_group=%u\n"
+               "bank=%u\n"
+               "row=%u\n"
+               "column=%u\n",
+               ev->hdr.timestamp,
+               ev->hdr.memdev,
+               ev->hdr.host,
+               ev->hdr.serial,
+               ev->hdr.log_type,
+               ev->hdr.hdr_uuid,
+               ev->hdr.hdr_flags,
+               ev->hdr.hdr_handle,
+               ev->hdr.hdr_related_handle,
+               ev->hdr.hdr_timestamp,
+               ev->hdr.hdr_length,
+               ev->hdr.hdr_maint_op_class,
+               ev->dpa,
+               ev->dpa_flags,
+               ev->descriptor,
+               ev->type,
+               ev->transaction_type,
+               ev->channel,
+               ev->rank,
+               ev->nibble_mask,
+               ev->bank_group,
+               ev->bank,
+               ev->row,
+               ev->column);
 
        strcat(buf, bt_buf);
 
@@ -621,49 +614,49 @@ static int set_cxl_memory_module_event_backtrace(char *buf, struct ras_cxl_memor
        if (!buf || !ev)
                return -1;
 
-       sprintf(bt_buf, "BACKTRACE="    \
-                                               "timestamp=%s\n"        \
-                                               "memdev=%s\n"           \
-                                               "host=%s\n"             \
-                                               "serial=0x%lx\n"        \
-                                               "log_type=%s\n"         \
-                                               "hdr_uuid=%s\n"         \
-                                               "hdr_flags=0x%x\n"      \
-                                               "hdr_handle=0x%x\n"     \
-                                               "hdr_related_handle=0x%x\n"     \
-                                               "hdr_timestamp=%s\n"    \
-                                               "hdr_length=%u\n"       \
-                                               "hdr_maint_op_class=%u\n"       \
-                                               "event_type=%u\n"       \
-                                               "health_status=%u\n"    \
-                                               "media_status=%u\n"     \
-                                               "life_used=%u\n"        \
-                                               "dirty_shutdown_cnt=%u\n"       \
-                                               "cor_vol_err_cnt=%u\n"  \
-                                               "cor_per_err_cnt=%u\n"  \
-                                               "device_temp=%d\n"      \
-                                               "add_status=%u\n",      \
-                                               ev->hdr.timestamp,      \
-                                               ev->hdr.memdev,         \
-                                               ev->hdr.host,           \
-                                               ev->hdr.serial,         \
-                                               ev->hdr.log_type,       \
-                                               ev->hdr.hdr_uuid,       \
-                                               ev->hdr.hdr_flags,      \
-                                               ev->hdr.hdr_handle,     \
-                                               ev->hdr.hdr_related_handle,     \
-                                               ev->hdr.hdr_timestamp,  \
-                                               ev->hdr.hdr_length,     \
-                                               ev->hdr.hdr_maint_op_class,     \
-                                               ev->event_type,         \
-                                               ev->health_status,      \
-                                               ev->media_status,       \
-                                               ev->life_used,          \
-                                               ev->dirty_shutdown_cnt, \
-                                               ev->cor_vol_err_cnt,    \
-                                               ev->cor_per_err_cnt,    \
-                                               ev->device_temp,        \
-                                               ev->add_status);
+       sprintf(bt_buf, "BACKTRACE="
+               "timestamp=%s\n"
+               "memdev=%s\n"
+               "host=%s\n"
+               "serial=0x%lx\n"
+               "log_type=%s\n"
+               "hdr_uuid=%s\n"
+               "hdr_flags=0x%x\n"
+               "hdr_handle=0x%x\n"
+               "hdr_related_handle=0x%x\n"
+               "hdr_timestamp=%s\n"
+               "hdr_length=%u\n"
+               "hdr_maint_op_class=%u\n"
+               "event_type=%u\n"
+               "health_status=%u\n"
+               "media_status=%u\n"
+               "life_used=%u\n"
+               "dirty_shutdown_cnt=%u\n"
+               "cor_vol_err_cnt=%u\n"
+               "cor_per_err_cnt=%u\n"
+               "device_temp=%d\n"
+               "add_status=%u\n",
+               ev->hdr.timestamp,
+               ev->hdr.memdev,
+               ev->hdr.host,
+               ev->hdr.serial,
+               ev->hdr.log_type,
+               ev->hdr.hdr_uuid,
+               ev->hdr.hdr_flags,
+               ev->hdr.hdr_handle,
+               ev->hdr.hdr_related_handle,
+               ev->hdr.hdr_timestamp,
+               ev->hdr.hdr_length,
+               ev->hdr.hdr_maint_op_class,
+               ev->event_type,
+               ev->health_status,
+               ev->media_status,
+               ev->life_used,
+               ev->dirty_shutdown_cnt,
+               ev->cor_vol_err_cnt,
+               ev->cor_per_err_cnt,
+               ev->device_temp,
+               ev->add_status);
 
        strcat(buf, bt_buf);
 
@@ -677,84 +670,96 @@ static int commit_report_backtrace(int sockfd, int type, void *ev)
        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) {
        case MC_EVENT:
-               rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
+               rc = set_mc_event_backtrace(buf,
+                                           (struct ras_mc_event *)ev);
                break;
        case AER_EVENT:
-               rc = set_aer_event_backtrace(buf, (struct ras_aer_event *)ev);
+               rc = set_aer_event_backtrace(buf,
+                                            (struct ras_aer_event *)ev);
                break;
        case MCE_EVENT:
-               rc = set_mce_event_backtrace(buf, (struct mce_event *)ev);
+               rc = set_mce_event_backtrace(buf,
+                                            (struct mce_event *)ev);
                break;
        case NON_STANDARD_EVENT:
-               rc = set_non_standard_event_backtrace(buf, (struct ras_non_standard_event *)ev);
+               rc = set_non_standard_event_backtrace(buf,
+                                                     (struct ras_non_standard_event *)ev);
                break;
        case ARM_EVENT:
-               rc = set_arm_event_backtrace(buf, (struct ras_arm_event *)ev);
+               rc = set_arm_event_backtrace(buf,
+                                            (struct ras_arm_event *)ev);
                break;
        case DEVLINK_EVENT:
-               rc = set_devlink_event_backtrace(buf, (struct devlink_event *)ev);
+               rc = set_devlink_event_backtrace(buf,
+                                                (struct devlink_event *)ev);
                break;
        case DISKERROR_EVENT:
-               rc = set_diskerror_event_backtrace(buf, (struct diskerror_event *)ev);
+               rc = set_diskerror_event_backtrace(buf,
+                                                  (struct diskerror_event *)ev);
                break;
        case MF_EVENT:
-               rc = set_mf_event_backtrace(buf, (struct ras_mf_event *)ev);
+               rc = set_mf_event_backtrace(buf,
+                                           (struct ras_mf_event *)ev);
                break;
        case CXL_POISON_EVENT:
-               rc = set_cxl_poison_event_backtrace(buf, (struct ras_cxl_poison_event *)ev);
+               rc = set_cxl_poison_event_backtrace(buf,
+                                                   (struct ras_cxl_poison_event *)ev);
                break;
        case CXL_AER_UE_EVENT:
-               rc = set_cxl_aer_ue_event_backtrace(buf, (struct ras_cxl_aer_ue_event *)ev);
+               rc = set_cxl_aer_ue_event_backtrace(buf,
+                                                   (struct ras_cxl_aer_ue_event *)ev);
                break;
        case CXL_AER_CE_EVENT:
-               rc = set_cxl_aer_ce_event_backtrace(buf, (struct ras_cxl_aer_ce_event *)ev);
+               rc = set_cxl_aer_ce_event_backtrace(buf,
+                                                   (struct ras_cxl_aer_ce_event *)ev);
                break;
        case CXL_OVERFLOW_EVENT:
-               rc = set_cxl_overflow_event_backtrace(buf, (struct ras_cxl_overflow_event *)ev);
+               rc = set_cxl_overflow_event_backtrace(buf,
+                                                     (struct ras_cxl_overflow_event *)ev);
                break;
        case CXL_GENERIC_EVENT:
-               rc = set_cxl_generic_event_backtrace(buf, (struct ras_cxl_generic_event *)ev);
+               rc = set_cxl_generic_event_backtrace(buf,
+                                                    (struct ras_cxl_generic_event *)ev);
                break;
        case CXL_GENERAL_MEDIA_EVENT:
-               rc = set_cxl_general_media_event_backtrace(buf, (struct ras_cxl_general_media_event *)ev);
+               rc = set_cxl_general_media_event_backtrace(buf,
+                                                          (struct ras_cxl_general_media_event *)ev);
                break;
        case CXL_DRAM_EVENT:
-               rc = set_cxl_dram_event_backtrace(buf, (struct ras_cxl_dram_event *)ev);
+               rc = set_cxl_dram_event_backtrace(buf,
+                                                 (struct ras_cxl_dram_event *)ev);
                break;
        case CXL_MEMORY_MODULE_EVENT:
-               rc = set_cxl_memory_module_event_backtrace(buf, (struct ras_cxl_memory_module_event *)ev);
+               rc = set_cxl_memory_module_event_backtrace(buf,
+                                                          (struct ras_cxl_memory_module_event *)ev);
                break;
        default:
                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)) {
                rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
-               if (rc < INPUT_BUFFER_SIZE - 1) {
+               if (rc < INPUT_BUFFER_SIZE - 1)
                        return -1;
-               }
 
                pbuf = pbuf + INPUT_BUFFER_SIZE - 1;
        }
 
        rc = write(sockfd, pbuf, buf_len + 1);
-       if (rc < buf_len) {
+       if (rc < buf_len)
                return -1;
-       }
 
        return 0;
 }
@@ -769,45 +774,37 @@ 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;
-       }
 
        done = 1;
 
 mc_fail:
-
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
-       if (done) {
+       if (done)
                return 0;
-       } else {
-               return -1;
-       }
+
+       return -1;
 }
 
 int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
@@ -820,45 +817,38 @@ 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;
-       }
 
        done = 1;
 
 aer_fail:
 
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
-       if (done) {
+       if (done)
                return 0;
-       } else {
-               return -1;
-       }
+
+       return -1;
 }
 
 int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev)
@@ -870,39 +860,33 @@ 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;
-       }
 
        rc = 0;
 
 non_standard_fail:
 
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
        return rc;
 }
@@ -916,39 +900,33 @@ 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;
-       }
 
        rc = 0;
 
 arm_fail:
 
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
        return rc;
 }
@@ -963,45 +941,38 @@ 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;
-       }
 
        done = 1;
 
 mce_fail:
 
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
-       if (done) {
+       if (done)
                return 0;
-       } else {
-               return -1;
-       }
+
+       return -1;
 }
 
 int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev)
@@ -1014,45 +985,38 @@ 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;
-       }
 
        done = 1;
 
 devlink_fail:
 
-       if (sockfd >= 0) {
+       if (sockfd >= 0)
                close(sockfd);
-       }
 
-       if (done) {
+       if (done)
                return 0;
-       } else {
-               return -1;
-       }
+
+       return -1;
 }
 
 int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev)
@@ -1065,44 +1029,37 @@ 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 {
-               return -1;
-       }
+
+       return -1;
 }
 
 int ras_report_mf_event(struct ras_events *ras, struct ras_mf_event *ev)
@@ -1188,8 +1145,8 @@ cxl_poison_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev)
@@ -1232,8 +1189,8 @@ cxl_aer_ue_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev)
@@ -1276,8 +1233,8 @@ cxl_aer_ce_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev)
@@ -1320,8 +1277,8 @@ cxl_overflow_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev)
@@ -1364,8 +1321,8 @@ cxl_generic_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
@@ -1408,8 +1365,8 @@ cxl_general_media_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev)
@@ -1452,8 +1409,8 @@ cxl_dram_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
 
 int ras_report_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev)
@@ -1496,6 +1453,6 @@ cxl_memory_module_fail:
 
        if (done)
                return 0;
-       else
-               return -1;
+
+       return -1;
 }
index 43da434da38782a389fc6c679660b5e392bb35f3..86d061c0a21edad1ec85d8f76a6363c8c755c4c0 100644 (file)
--- a/rbtree.c
+++ b/rbtree.c
@@ -1,25 +1,23 @@
 /*
-  Red Black Trees
-  (C) 1999  Andrea Arcangeli <andrea@suse.de>
-  (C) 2002  David Woodhouse <dwmw2@infradead.org>
-  Taken from the Linux 2.6.30 source with some minor modificatons.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-  linux/lib/rbtree.c
-*/
+ * Red Black Trees
+ * (C) 1999  Andrea Arcangeli <andrea@suse.de>
+ * (C) 2002  David Woodhouse <dwmw2@infradead.org>
+ * Taken from the Linux 2.6.30 source with some minor modificatons.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
 #include "rbtree.h"
 
@@ -35,14 +33,14 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
 
        rb_set_parent(right, parent);
 
-       if (parent)
-       {
+       if (parent) {
                if (node == parent->rb_left)
                        parent->rb_left = right;
                else
                        parent->rb_right = right;
-       } else
+       } else {
                root->rb_node = right;
+       }
        rb_set_parent(node, right);
 }
 
@@ -58,14 +56,14 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
 
        rb_set_parent(left, parent);
 
-       if (parent)
-       {
+       if (parent) {
                if (node == parent->rb_right)
                        parent->rb_right = left;
                else
                        parent->rb_left = left;
-       } else
+       } else {
                root->rb_node = left;
+       }
        rb_set_parent(node, left);
 }
 
@@ -73,27 +71,21 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
 {
        struct rb_node *parent, *gparent;
 
-       while ((parent = rb_parent(node)) && rb_is_red(parent))
-       {
+       while ((parent = rb_parent(node)) && rb_is_red(parent)) {
                gparent = rb_parent(parent);
 
-               if (parent == gparent->rb_left)
-               {
-                       {
-                               register struct rb_node *uncle = gparent->rb_right;
-
-                               if (uncle && rb_is_red(uncle))
-                               {
-                                       rb_set_black(uncle);
-                                       rb_set_black(parent);
-                                       rb_set_red(gparent);
-                                       node = gparent;
-                                       continue;
-                               }
+               if (parent == gparent->rb_left) {
+                       register struct rb_node *uncle = gparent->rb_right;
+
+                       if (uncle && rb_is_red(uncle)) {
+                               rb_set_black(uncle);
+                               rb_set_black(parent);
+                               rb_set_red(gparent);
+                               node = gparent;
+                               continue;
                        }
 
-                       if (parent->rb_right == node)
-                       {
+                       if (parent->rb_right == node) {
                                struct rb_node *tmp;
 
                                __rb_rotate_left(parent, root);
@@ -106,21 +98,17 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                        rb_set_red(gparent);
                        __rb_rotate_right(gparent, root);
                } else {
-                       {
-                               struct rb_node *uncle = gparent->rb_left;
-
-                               if (uncle && rb_is_red(uncle))
-                               {
-                                       rb_set_black(uncle);
-                                       rb_set_black(parent);
-                                       rb_set_red(gparent);
-                                       node = gparent;
-                                       continue;
-                               }
+                       struct rb_node *uncle = gparent->rb_left;
+
+                       if (uncle && rb_is_red(uncle)) {
+                               rb_set_black(uncle);
+                               rb_set_black(parent);
+                               rb_set_red(gparent);
+                               node = gparent;
+                               continue;
                        }
 
-                       if (parent->rb_left == node)
-                       {
+                       if (parent->rb_left == node) {
                                struct rb_node *tmp;
 
                                __rb_rotate_right(parent, root);
@@ -143,28 +131,22 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
 {
        struct rb_node *other;
 
-       while ((!node || rb_is_black(node)) && node != root->rb_node)
-       {
-               if (parent->rb_left == node)
-               {
+       while ((!node || rb_is_black(node)) && node != root->rb_node) {
+               if (parent->rb_left == node) {
                        other = parent->rb_right;
-                       if (rb_is_red(other))
-                       {
+                       if (rb_is_red(other)) {
                                rb_set_black(other);
                                rb_set_red(parent);
                                __rb_rotate_left(parent, root);
                                other = parent->rb_right;
                        }
                        if ((!other->rb_left || rb_is_black(other->rb_left)) &&
-                           (!other->rb_right || rb_is_black(other->rb_right)))
-                       {
+                           (!other->rb_right || rb_is_black(other->rb_right))) {
                                rb_set_red(other);
                                node = parent;
                                parent = rb_parent(node);
-                       } else
-                       {
-                               if (!other->rb_right || rb_is_black(other->rb_right))
-                               {
+                       } else {
+                               if (!other->rb_right || rb_is_black(other->rb_right)) {
                                        rb_set_black(other->rb_left);
                                        rb_set_red(other);
                                        __rb_rotate_right(other, root);
@@ -177,26 +159,21 @@ 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))
-                       {
+                       if (rb_is_red(other)) {
                                rb_set_black(other);
                                rb_set_red(parent);
                                __rb_rotate_right(parent, root);
                                other = parent->rb_left;
                        }
                        if ((!other->rb_left || rb_is_black(other->rb_left)) &&
-                           (!other->rb_right || rb_is_black(other->rb_right)))
-                       {
+                           (!other->rb_right || rb_is_black(other->rb_right))) {
                                rb_set_red(other);
                                node = parent;
                                parent = rb_parent(node);
-                       } else
-                       {
-                               if (!other->rb_left || rb_is_black(other->rb_left))
-                               {
+                       } else {
+                               if (!other->rb_left || rb_is_black(other->rb_left)) {
                                        rb_set_black(other->rb_right);
                                        rb_set_red(other);
                                        __rb_rotate_left(other, root);
@@ -220,12 +197,11 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
        struct rb_node *child, *parent;
        int color;
 
-       if (!node->rb_left)
+       if (!node->rb_left) {
                child = node->rb_right;
-       else if (!node->rb_right)
+       } else if (!node->rb_right) {
                child = node->rb_left;
-       else
-       {
+       } else {
                struct rb_node *old = node, *left;
 
                node = node->rb_right;
@@ -240,21 +216,22 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
                if (parent == old) {
                        parent->rb_right = child;
                        parent = node;
-               } else
+               } else {
                        parent->rb_left = child;
+               }
 
                node->rb_parent_color = old->rb_parent_color;
                node->rb_right = old->rb_right;
                node->rb_left = old->rb_left;
 
-               if (rb_parent(old))
-               {
+               if (rb_parent(old)) {
                        if (rb_parent(old)->rb_left == old)
                                rb_parent(old)->rb_left = node;
                        else
                                rb_parent(old)->rb_right = node;
-               } else
+               } else {
                        root->rb_node = node;
+               }
 
                rb_set_parent(old->rb_left, node);
                if (old->rb_right)
@@ -267,14 +244,14 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
 
        if (child)
                rb_set_parent(child, parent);
-       if (parent)
-       {
+       if (parent) {
                if (parent->rb_left == node)
                        parent->rb_left = child;
                else
                        parent->rb_right = child;
-       } else
+       } else {
                root->rb_node = child;
+       }
 
  color:
        if (color == RB_BLACK)
@@ -315,8 +292,10 @@ struct rb_node *rb_next(const struct rb_node *node)
        if (rb_parent(node) == node)
                return NULL;
 
-       /* If we have a right-hand child, go down and then left as far
-          as we can. */
+       /*
+        * If we have a right-hand child, go down and then left as far
+        * as we can.
+        */
        if (node->rb_right) {
                node = node->rb_right;
                while (node->rb_left)
@@ -324,12 +303,14 @@ struct rb_node *rb_next(const struct rb_node *node)
                return (struct rb_node *)node;
        }
 
-       /* No right-hand children.  Everything down and left is
-          smaller than us, so any 'next' node must be in the general
-          direction of our parent. Go up the tree; any time the
-          ancestor is a right-hand child of its parent, keep going
-          up. First time it's a left-hand child of its parent, said
-          parent is our 'next' node. */
+       /*
+        * No right-hand children.  Everything down and left is
+        * smaller than us, so any 'next' node must be in the general
+        * direction of our parent. Go up the tree; any time the
+        * ancestor is a right-hand child of its parent, keep going
+        * up. First time it's a left-hand child of its parent, said
+        * parent is our 'next' node.
+        */
        while ((parent = rb_parent(node)) && node == parent->rb_right)
                node = parent;
 
@@ -343,8 +324,10 @@ struct rb_node *rb_prev(const struct rb_node *node)
        if (rb_parent(node) == node)
                return NULL;
 
-       /* If we have a left-hand child, go down and then right as far
-          as we can. */
+       /*
+        * If we have a left-hand child, go down and then right as far
+        * as we can.
+        */
        if (node->rb_left) {
                node = node->rb_left;
                while (node->rb_right)
@@ -352,8 +335,10 @@ struct rb_node *rb_prev(const struct rb_node *node)
                return (struct rb_node *)node;
        }
 
-       /* No left-hand children. Go up till we find an ancestor which
-          is a right-hand child of its parent */
+       /*
+        * No left-hand children. Go up till we find an ancestor which
+        * is a right-hand child of its parent
+        */
        while ((parent = rb_parent(node)) && node == parent->rb_left)
                node = parent;
 
index 555b3dca7c97463582d61964c61fcd05fae7c7ca..bf861e56eeac1cd457b43a59ff2baf580ae6d17d 100644 (file)
--- a/rbtree.h
+++ b/rbtree.h
@@ -1,96 +1,96 @@
 /*
-  Red Black Trees
-  (C) 1999  Andrea Arcangeli <andrea@suse.de>
-  Taken from the Linux 2.6.30 source.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-  linux/include/linux/rbtree.h
-
-  To use rbtrees you'll have to implement your own insert and search cores.
-  This will avoid us to use callbacks and to drop drammatically performances.
-  I know it's not the cleaner way,  but in C (not in C++) to get
-  performances and genericity...
-
-  Some example of insert and search follows here. The search is a plain
-  normal search over an ordered tree. The insert instead must be implemented
-  int two steps: as first thing the code must insert the element in
-  order as a red leaf in the tree, then the support library function
-  rb_insert_color() must be called. Such function will do the
-  not trivial work to rebalance the rbtree if necessary.
-
------------------------------------------------------------------------
-static inline struct page * rb_search_page_cache(struct inode * inode,
-                                                unsigned long offset)
-{
-       struct rb_node * n = inode->i_rb_page_cache.rb_node;
-       struct page * page;
-
-       while (n)
-       {
-               page = rb_entry(n, struct page, rb_page_cache);
-
-               if (offset < page->offset)
-                       n = n->rb_left;
-               else if (offset > page->offset)
-                       n = n->rb_right;
-               else
-                       return page;
-       }
-       return NULL;
-}
-
-static inline struct page * __rb_insert_page_cache(struct inode * inode,
-                                                  unsigned long offset,
-                                                  struct rb_node * node)
-{
-       struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
-       struct rb_node * parent = NULL;
-       struct page * page;
-
-       while (*p)
-       {
-               parent = *p;
-               page = rb_entry(parent, struct page, rb_page_cache);
-
-               if (offset < page->offset)
-                       p = &(*p)->rb_left;
-               else if (offset > page->offset)
-                       p = &(*p)->rb_right;
-               else
-                       return page;
-       }
-
-       rb_link_node(node, parent, p);
-
-       return NULL;
-}
+ * Red Black Trees
+ * (C) 1999  Andrea Arcangeli <andrea@suse.de>
+ * Taken from the Linux 2.6.30 source.
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
-static inline struct page * rb_insert_page_cache(struct inode * inode,
-                                                unsigned long offset,
-                                                struct rb_node * node)
-{
-       struct page * ret;
-       if ((ret = __rb_insert_page_cache(inode, offset, node)))
-               goto out;
-       rb_insert_color(node, &inode->i_rb_page_cache);
- out:
-       return ret;
-}
------------------------------------------------------------------------
-*/
+/*
+ * To use rbtrees you'll have to implement your own insert and search cores.
+ * This will avoid us to use callbacks and to drop drammatically performances.
+ * I know it's not the cleaner way,  but in C (not in C++) to get
+ * performances and genericity...
+ *
+ * Some example of insert and search follows here. The search is a plain
+ * normal search over an ordered tree. The insert instead must be implemented
+ * int two steps: as first thing the code must insert the element in
+ * order as a red leaf in the tree, then the support library function
+ * rb_insert_color() must be called. Such function will do the
+ * not trivial work to rebalance the rbtree if necessary.
+ *
+ * -----------------------------------------------------------------------
+ *
+ * static inline struct page * rb_search_page_cache(struct inode * inode,
+ *                                              unsigned long offset)
+ * {
+ *     struct rb_node * n = inode->i_rb_page_cache.rb_node;
+ *     struct page * page;
+ *
+ *     while (n)
+ *     {
+ *             page = rb_entry(n, struct page, rb_page_cache);
+ *
+ *             if (offset < page->offset)
+ *                     n = n->rb_left;
+ *             else if (offset > page->offset)
+ *                     n = n->rb_right;
+ *             else
+ *                     return page;
+ *     }
+ *     return NULL;
+ * }
+ *
+ * static inline struct page * __rb_insert_page_cache(struct inode * inode,
+ *                                                unsigned long offset,
+ *                                                struct rb_node * node)
+ * {
+ *     struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
+ *     struct rb_node * parent = NULL;
+ *     struct page * page;
+ *
+ *     while (*p)
+ *     {
+ *             parent = *p;
+ *             page = rb_entry(parent, struct page, rb_page_cache);
+ *
+ *             if (offset < page->offset)
+ *                     p = &(*p)->rb_left;
+ *             else if (offset > page->offset)
+ *                     p = &(*p)->rb_right;
+ *             else
+ *                     return page;
+ *     }
+ *
+ *     rb_link_node(node, parent, p);
+ *
+ *     return NULL;
+ * }
+ *
+ * static inline struct page * rb_insert_page_cache(struct inode * inode,
+ *                                              unsigned long offset,
+ *                                              struct rb_node * node)
+ * {
+ *     struct page * ret;
+ *     if ((ret = __rb_insert_page_cache(inode, offset, node)))
+ *             goto out;
+ *     rb_insert_color(node, &inode->i_rb_page_cache);
+ *  out:
+ *     return ret;
+ * }
+ */
 
 #ifndef        _LINUX_RBTREE_H
 #define        _LINUX_RBTREE_H
@@ -98,8 +98,9 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
 #include <stddef.h>
 
 #define container_of(ptr, type, member) ({                     \
-       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-       (type *)( (char *)__mptr - offsetof(type,member) );})
+       const typeof(((type *)0)->member) *__mptr = (ptr);      \
+       (type *)((char *)__mptr - offsetof(type, member));      \
+})
 
 struct rb_node {
        unsigned long  rb_parent_color;