Skip to content

Commit

Permalink
rasdaemon: coding style cleanup
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mchehab committed Jul 16, 2024
1 parent 5f8ec6f commit 7a69b22
Show file tree
Hide file tree
Showing 49 changed files with 1,009 additions and 959 deletions.
7 changes: 4 additions & 3 deletions bitfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* 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>

#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)
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions bitfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
25 changes: 12 additions & 13 deletions mce-amd-k8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions mce-amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-broadwell-de.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-broadwell-epex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-dunnington.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-haswell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
58 changes: 42 additions & 16 deletions mce-intel-i10nm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-ivb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-knl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-nehalem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-p4-p6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-sb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-skylake-xeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion mce-intel-tulsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
19 changes: 12 additions & 7 deletions mce-intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 7a69b22

Please sign in to comment.