diff options
author | Huang Ying <ying.huang@intel.com> | 2008-12-12 13:27:16 +0100 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2008-12-12 13:27:16 +0100 |
commit | 3401280f40e7876205be61ebd65534cc0656fcbc (patch) | |
tree | 7ee104e658e5e83af48c6a1e46c9b035fea2b48d | |
parent | f211ca5ab71ff3abfcb2af09dca31c77cdd49638 (diff) | |
download | mce-inject-3401280f40e7876205be61ebd65534cc0656fcbc.tar.gz |
From: Huang Ying <ying.huang@intel.com>
Remove some useless whitespaces
- Trailing whitespaces
- Whitespaces inside TAB stop
Signed-off-by: Huang Ying <ying.huang@intel.com>
-rw-r--r-- | SPEC | 7 | ||||
-rw-r--r-- | inject.c | 73 | ||||
-rw-r--r-- | mce.lex | 67 | ||||
-rw-r--r-- | mce.y | 15 | ||||
-rw-r--r-- | parser.h | 2 | ||||
-rw-r--r-- | util.h | 1 |
6 files changed, 80 insertions, 85 deletions
@@ -24,7 +24,7 @@ described there. The keywords are case-insensitive -The machine check always starts with +The machine check always starts with MCE @@ -34,7 +34,7 @@ CPU number|broadcast [bank-number] Machine check is injected on CPU xx or broadcasted to all CPUs BANK bank-number -STATUS {number|fatal|corrected|uncorrected|pcc|uc|val|en|over} +STATUS {number|fatal|corrected|uncorrected|pcc|uc|val|en|over} MCGSTATUS {number|mcip|ripv|eipv} ADDR number RIP number @@ -61,11 +61,10 @@ multiple fields can be on a line number can be hex/octal/decimal in the usual C format. -Multiple machine checks can be in a single file, each new one +Multiple machine checks can be in a single file, each new one starts with "CPU" or "MCE" For all missing fields reasonable default values are filled in (hopefully) Comments start with # until the end of the line - @@ -79,15 +79,15 @@ static inline int cpu_id_to_index(int id) static void write_mce(int fd, struct mce *m) { int n = write(fd, m, sizeof(struct mce)); - if (n <= 0) + if (n <= 0) err("Injecting mce on /dev/mcelog"); - if (n < sizeof(struct mce)) { + if (n < sizeof(struct mce)) { fprintf(stderr, "Short mce write %d: kernel does not match?\n", n); } } -struct thread { +struct thread { struct thread *next; pthread_t thr; struct mce *m; @@ -129,37 +129,37 @@ void do_inject_mce(int fd, struct mce *m) blocked = 1; barrier(); - for (i = 0; i < cpu_num; i++) { - unsigned cpu = cpu_map[i]; - struct thread *t; - pthread_attr_t attr; - cpu_set_t aset; - - NEW(t); - if (cpu == m->cpu) { - t->m = m; - t->monarch = 1; - } else if (cpu_mce[i]) - t->m = cpu_mce[i]; - else if (mce_flags & MCE_NOBROADCAST) - continue; - else { - t->m = &t->otherm; - t->otherm = otherm; - t->otherm.cpu = cpu; - } - t->fd = fd; - t->next = tlist; - tlist = t; - - pthread_attr_init(&attr); - CPU_ZERO(&aset); - CPU_SET(cpu, &aset); - if (pthread_attr_setaffinity_np(&attr, sizeof(aset), &aset)) - err("pthread_attr_setaffinity"); - if (pthread_create(&t->thr, &attr, injector, t)) - err("pthread_create"); - } + for (i = 0; i < cpu_num; i++) { + unsigned cpu = cpu_map[i]; + struct thread *t; + pthread_attr_t attr; + cpu_set_t aset; + + NEW(t); + if (cpu == m->cpu) { + t->m = m; + t->monarch = 1; + } else if (cpu_mce[i]) + t->m = cpu_mce[i]; + else if (mce_flags & MCE_NOBROADCAST) + continue; + else { + t->m = &t->otherm; + t->otherm = otherm; + t->otherm.cpu = cpu; + } + t->fd = fd; + t->next = tlist; + tlist = t; + + pthread_attr_init(&attr); + CPU_ZERO(&aset); + CPU_SET(cpu, &aset); + if (pthread_attr_setaffinity_np(&attr, sizeof(aset), &aset)) + err("pthread_attr_setaffinity"); + if (pthread_create(&t->thr, &attr, injector, t)) + err("pthread_create"); + } /* could wait here for the threads to start up, but the kernel timeout should be long enough to catch slow ones */ @@ -167,7 +167,7 @@ void do_inject_mce(int fd, struct mce *m) barrier(); blocked = 0; - while (tlist) { + while (tlist) { struct thread *next = tlist->next; pthread_join(tlist->thr, NULL); free(tlist); @@ -189,7 +189,7 @@ void inject_mce(struct mce *m) } inject_fd = open("/dev/mcelog", O_RDWR); - if (inject_fd < 0) + if (inject_fd < 0) err("opening of /dev/mcelog"); if (!(m->status & MCI_STATUS_UC)) mce_flags |= MCE_NOBROADCAST; @@ -221,4 +221,3 @@ void init_mce(struct mce *m) { memset(m, 0, sizeof(struct mce)); } - @@ -19,7 +19,7 @@ Andi Kleen Ying Huang */ -%{ +%{ #define _GNU_SOURCE 1 #include <stdlib.h> #include <string.h> @@ -39,7 +39,7 @@ static int lookup_symbol(const char *); #.*\n /* comment */; \n ++yylineno; -0x[0-9a-fA-F]+ | +0x[0-9a-fA-F]+ | 0[0-7]+ | [0-9]+ yylval = strtoull(yytext, NULL, 0); return NUMBER; [:{}<>] return yytext[0]; @@ -51,40 +51,40 @@ static int lookup_symbol(const char *); /* Keyword handling */ -static struct key { +static struct key { const char *name; int tok; u64 val; -} keys[] = { +} keys[] = { #define KEY(x) { #x, x } #define KEYVAL(x,v) { #x, x, v } KEY(MCE), - KEY(STATUS), - KEY(RIP), - KEY(TSC), - KEY(ADDR), - KEY(MISC), - KEY(CPU), - KEY(BANK), - KEY(MCGSTATUS), - KEY(NOBROADCAST), + KEY(STATUS), + KEY(RIP), + KEY(TSC), + KEY(ADDR), + KEY(MISC), + KEY(CPU), + KEY(BANK), + KEY(MCGSTATUS), + KEY(NOBROADCAST), KEY(HOLD), KEY(IN_IRQ), KEYVAL(CORRECTED, MCI_STATUS_VAL), // checkme KEYVAL(UNCORRECTED, MCI_STATUS_VAL|MCI_STATUS_UC|MCI_STATUS_EN), KEYVAL(FATAL, MCI_STATUS_VAL|MCI_STATUS_UC|MCI_STATUS_EN |MCI_STATUS_PCC), - KEY(MACHINE), - KEY(CHECK), - KEY(EXCEPTION), - KEYVAL(RIPV, MCG_STATUS_RIPV), - KEYVAL(EIPV, MCG_STATUS_EIPV), - KEYVAL(MCIP, MCG_STATUS_MCIP), - KEYVAL(VAL, MCI_STATUS_VAL), - KEYVAL(OVER, MCI_STATUS_OVER), - KEYVAL(UC, MCI_STATUS_UC), - KEYVAL(EN, MCI_STATUS_EN), - KEYVAL(PCC, MCI_STATUS_PCC), + KEY(MACHINE), + KEY(CHECK), + KEY(EXCEPTION), + KEYVAL(RIPV, MCG_STATUS_RIPV), + KEYVAL(EIPV, MCG_STATUS_EIPV), + KEYVAL(MCIP, MCG_STATUS_MCIP), + KEYVAL(VAL, MCI_STATUS_VAL), + KEYVAL(OVER, MCI_STATUS_OVER), + KEYVAL(UC, MCI_STATUS_UC), + KEYVAL(EN, MCI_STATUS_EN), + KEYVAL(PCC, MCI_STATUS_PCC), }; static int cmp_key(const void *av, const void *bv) @@ -94,13 +94,13 @@ static int cmp_key(const void *av, const void *bv) return strcasecmp(a->name, b->name); } -static int lookup_symbol(const char *name) +static int lookup_symbol(const char *name) { struct key *k; struct key key; key.name = name; k = bsearch(&key, keys, ARRAY_SIZE(keys), sizeof(struct key), cmp_key); - if (k != NULL) { + if (k != NULL) { yylval = k->val; return k->tok; } @@ -131,15 +131,14 @@ int yywrap(void) int main(int ac, char **av) { init_lex(); - argv = ++av; - if (*av && !strcmp(*av, "--dump")) { - do_dump = 1; - av++; - } - init_cpu_info(); - init_inject(); + argv = ++av; + if (*av && !strcmp(*av, "--dump")) { + do_dump = 1; + av++; + } + init_cpu_info(); + init_inject(); if (*argv) yywrap(); return yyparse(); } - @@ -1,5 +1,5 @@ /* Copyright (c) 2008 by Intel Corp. - Grammar for machine check injection. Follows the format printed out + Grammar for machine check injection. Follows the format printed out by the kernel on panics with some extensions. See SPEC. mce-inject is free software; you can redistribute it and/or @@ -37,7 +37,7 @@ enum mceflags mce_flags; static void init(void); -%} +%} %token STATUS RIP TSC ADDR MISC CPU BANK MCGSTATUS NOBROADCAST HOLD IN_IRQ %token CORRECTED UNCORRECTED FATAL MCE @@ -45,21 +45,21 @@ static void init(void); %token SYMBOL %token MACHINE CHECK EXCEPTION -%token RIPV EIPV MCIP +%token RIPV EIPV MCIP %token VAL OVER UC EN PCC %% -input: /* empty */ +input: /* empty */ | input mce_start mce { submit_mce(&m); } ; mce_start: CPU NUMBER { init(); m.cpu = $2; } | CPU NUMBER NUMBER { init(); m.cpu = $2; m.bank = $3; } - | MCE { init(); } + | MCE { init(); } | CPU NUMBER ':' - MACHINE CHECK EXCEPTION ':' NUMBER BANK NUMBER ':' + MACHINE CHECK EXCEPTION ':' NUMBER BANK NUMBER ':' NUMBER { init(); - m.cpu = $2; m.mcgstatus = $6; + m.cpu = $2; m.mcgstatus = $6; m.bank = $8; m.status = $10; } ; @@ -116,4 +116,3 @@ void yyerror(char const *msg, ...) va_end(ap); exit(1); } - @@ -10,7 +10,7 @@ extern int yylex(void); extern int yyparse(void); extern char *filename; -enum mceflags { +enum mceflags { MCE_NOBROADCAST = (1 << 0), MCE_HOLD = (1 << 1), }; @@ -9,4 +9,3 @@ void *xalloc(size_t sz); #else #define barrier() do {} while(0) #endif - |