Skip to content

Commit

Permalink
rasdaemon: fix some coding style issues
Browse files Browse the repository at this point in the history
Use checkpatch to fix some trivial coding style issues with:

	$ ./scripts/checkpatch.pl -f *.c -q --strict --fix-inplace

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mchehab committed Nov 18, 2024
1 parent abb10f6 commit dc12330
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
1 change: 1 addition & 0 deletions ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
static int wait_access(char *path, int ms)
{
int i;

for (i = 0; i < ms; i++) {
if (access(path, F_OK) == 0)
return 0;
Expand Down
39 changes: 25 additions & 14 deletions ras-page-isolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void row_offline_init(void)
}
}

if (!matched){
if (!matched) {
log(TERM, LOG_INFO, "Improper %s, set to default off\n", env);
}

Expand Down Expand Up @@ -281,7 +281,7 @@ static void row_isolation_init(void)
parse_env_string(&row_threshold, threshold_string, sizeof(threshold_string));
parse_env_string(&row_cycle, cycle_string, sizeof(cycle_string));
log(TERM, LOG_INFO, "Threshold of memory row Corrected Errors is %s / %s\n",
threshold_string, cycle_string);
threshold_string, cycle_string);
}

void ras_row_account_init(void)
Expand All @@ -291,7 +291,6 @@ void ras_row_account_init(void)
log(TERM, LOG_INFO, "ras_row_account_init done\n");
}


void ras_page_account_init(void)
{
page_offline_init();
Expand Down Expand Up @@ -431,6 +430,7 @@ void ras_record_page_error(unsigned long long addr, unsigned int count, time_t t
page_record(pr, count, time);
}
}

/* memory page CE threshold policy ends */

/* memory row CE threshold policy starts */
Expand Down Expand Up @@ -463,6 +463,7 @@ void row_record_get_id(struct row_record *rr, char *buffer)

int len = 0, field_num = 0;
const struct memory_location_field *fields;

if (rr->type == GHES) {
field_num = APEI_FIELD_NUM_CONST;
fields = apei_fields;
Expand All @@ -488,6 +489,7 @@ bool row_record_is_same_row(struct row_record *rr1, struct row_record *rr2)
return false;

int field_num = 0;

if (rr1->type == GHES) {
field_num = APEI_FIELD_NUM_CONST;
} else {
Expand All @@ -510,14 +512,16 @@ void row_record_copy(struct row_record *dst, struct row_record *src)
}
}

static int parse_value(const char* str, const char *anchor_str, int value_base, int *value) {
static int parse_value(const char *str, const char *anchor_str, int value_base, int *value)
{
char *start, *endptr;
int tmp;

if (!str || !anchor_str || !value)
return 1;

char *pos = strstr(str, anchor_str);

if (!pos)
return 1;

Expand All @@ -530,15 +534,16 @@ static int parse_value(const char* str, const char *anchor_str, int value_base,
return 1;
}

if (endptr == start){
if (endptr == start) {
log(TERM, LOG_ERR, "parse_value error, start: %s, value_base: %d\n", start, value_base);
return 1;
}
*value = tmp;
return 0;
}

static int parse_row_info(const char *detail, struct row_record *r) {
static int parse_row_info(const char *detail, struct row_record *r)
{
const struct memory_location_field *fields = NULL;
int field_num;

Expand Down Expand Up @@ -577,14 +582,15 @@ static void row_offline(struct row_record *rr, time_t time)
/* Offlining row is not required */
if (row_offline_action <= OFFLINE_ACCOUNT) {
log(TERM, LOG_INFO, "ROW_CE_ACTION=%s, ignore to offline row at %s\n",
offline_choice[row_offline_action].name, row_id);
offline_choice[row_offline_action].name, row_id);
return;
}

struct page_addr *page_info = NULL;
// do offline
unsigned long long addr_list[SAME_PAGE_IN_ROW];
int addr_list_size = 0;

LIST_FOREACH(page_info, &rr->page_head, entry) {
/* Ignore offlined pages */
if (page_info->offlined == PAGE_OFFLINE && (addr_list_size < SAME_PAGE_IN_ROW)) {
Expand All @@ -593,14 +599,15 @@ static void row_offline(struct row_record *rr, time_t time)
}

int found = 0;

for (int i = 0; i < addr_list_size; i++) {
if (addr_list[i] == page_info->addr) {
found = 1;
break;
}
}

if(found){
if (found) {
page_info->offlined = PAGE_OFFLINE;
continue;
}
Expand All @@ -617,7 +624,7 @@ static void row_offline(struct row_record *rr, time_t time)
page_info->offlined = ret < 0 ? PAGE_OFFLINE_FAILED : PAGE_OFFLINE;

log(TERM, LOG_INFO, "Result of offlining page at %#llx of row %s: %s\n",
page_info->addr, row_id, page_state[page_info->offlined ]);
page_info->addr, row_id, page_state[page_info->offlined]);

if (page_info->offlined == PAGE_OFFLINE && (addr_list_size < SAME_PAGE_IN_ROW))
addr_list[addr_list_size++] = page_info->addr;
Expand All @@ -631,6 +638,7 @@ static void row_record(struct row_record *rr, time_t time)

if (time - rr->start > row_cycle.val) {
struct page_addr *page_info = NULL, *tmp_page_info = NULL;

page_info = LIST_FIRST(&rr->page_head);
while (page_info) {
// delete exceeds row_cycle.val
Expand All @@ -646,17 +654,18 @@ static void row_record(struct row_record *rr, time_t time)
}

char row_id[ROW_ID_MAX_LEN] = {0};

row_record_get_id(rr, row_id);
if (rr->count >= row_threshold.val) {
log(TERM, LOG_INFO, "Corrected Errors of row %s exceeded row CE threshold, count=%lu\n", row_id, rr->count);
row_offline(rr, time);
}
}

static struct row_record *row_lookup_insert(struct row_record *r, unsigned count, unsigned long long addr, time_t time)
static struct row_record *row_lookup_insert(struct row_record *r, unsigned int count, unsigned long long addr, time_t time)
{
struct row_record *rr = NULL, *new_row_record = NULL;
struct page_addr *new_page_addr = NULL, *tail_page_addr = NULL;;
struct page_addr *new_page_addr = NULL, *tail_page_addr = NULL;
int found = 0;

if (!r)
Expand All @@ -671,7 +680,7 @@ static struct row_record *row_lookup_insert(struct row_record *r, unsigned count
}

// new row
if (!found){
if (!found) {
new_row_record = calloc(1, sizeof(struct row_record));
if (!new_row_record) {
log(TERM, LOG_ERR, "No memory for new row record\n");
Expand All @@ -697,6 +706,7 @@ static struct row_record *row_lookup_insert(struct row_record *r, unsigned count

struct page_addr *record = NULL;
int not_empty = 0;

LIST_FOREACH(record, &new_row_record->page_head, entry) {
tail_page_addr = record;
not_empty = 1;
Expand All @@ -711,7 +721,7 @@ static struct row_record *row_lookup_insert(struct row_record *r, unsigned count
return new_row_record;
}

void ras_record_row_error(const char *detail, unsigned count, time_t time, unsigned long long addr)
void ras_record_row_error(const char *detail, unsigned int count, time_t time, unsigned long long addr)
{
struct row_record *pr = NULL;
struct row_record r = {0};
Expand All @@ -723,7 +733,7 @@ void ras_record_row_error(const char *detail, unsigned count, time_t time, unsig
return;

pr = row_lookup_insert(&r, count, addr, time);
if (!pr){
if (!pr) {
log(TERM, LOG_ERR, "insert CE page structure into CE row structure failed\n");
return;
}
Expand Down Expand Up @@ -751,4 +761,5 @@ void row_record_infos_free(void)
row_record = tmp_row_record;
}
}

/* memory row CE threshold policy ends */
4 changes: 2 additions & 2 deletions unified-sel.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ static const char *cor_error_ids[32] = {

static int verify_id_log_sel(uint64_t status,
const char **idarray,
unsigned bus,
unsigned dev_fn)
unsigned int bus,
unsigned int dev_fn)
{
int i;
char openbmc_ipmi_add_sel[105];
Expand Down

0 comments on commit dc12330

Please sign in to comment.