8 Star 1 Fork 7

src-anolis-os/rasdaemon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1047-C-files-cleanup-coding-style.patch 106.74 KB
一键复制 编辑 原始数据 按行查看 历史
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343
From 531a16aa949221932f76108bf9c74fe164fec7df Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <[email protected]>
Date: Mon, 22 Jan 2024 08:36:47 +0100
Subject: [PATCH 47/85] C files: cleanup coding style
The rasdaemon conding style follows Linux Kernel where it makes sense.
Yet, changes made overtime ended with some coding style non-compliances.
Adjust rasdaemon coding style by using:
scripts/checkpatch.pl --fix-inplace --strict *.c --ignore PREFER_KERNEL_TYPES
And doing some manual fixups where the script didn't work.
As a bonus, some typos were also fixed on some rasdaemon messages.
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
---
bitfield.c | 13 ++-
mce-amd-k8.c | 28 +++--
mce-amd-smca.c | 17 ++-
mce-amd.c | 6 +-
mce-intel-broadwell-de.c | 6 +-
mce-intel-broadwell-epex.c | 8 +-
mce-intel-dunnington.c | 2 +
mce-intel-haswell.c | 9 +-
mce-intel-ivb.c | 8 +-
mce-intel-knl.c | 2 +-
mce-intel-nehalem.c | 5 +-
mce-intel-p4-p6.c | 10 +-
mce-intel-sb.c | 8 +-
mce-intel-skylake-xeon.c | 6 +-
mce-intel-tulsa.c | 1 +
mce-intel.c | 47 ++++----
non-standard-ampere.c | 134 +++++++++++-----------
non-standard-hisi_hip08.c | 4 +-
non-standard-hisilicon.c | 18 +--
non-standard-yitian.c | 28 ++---
queue.c | 14 +--
ras-aer-handler.c | 4 +-
ras-arm-handler.c | 6 +-
ras-cpu-isolation.c | 28 ++---
ras-devlink-handler.c | 5 +-
ras-diskerror-handler.c | 3 +-
ras-events.c | 36 +++---
ras-extlog-handler.c | 11 +-
ras-mc-handler.c | 10 +-
ras-mce-handler.c | 26 ++---
ras-memory-failure-handler.c | 3 +-
ras-non-standard-handler.c | 11 +-
ras-page-isolation.c | 21 ++--
ras-record.c | 196 ++++++++++++++++-----------------
ras-report.c | 208 +++++++++++++++++++----------------
rasdaemon.c | 7 +-
rbtree.c | 32 +++---
37 files changed, 504 insertions(+), 477 deletions(-)
diff --git a/bitfield.c b/bitfield.c
index f004755..2076683 100644
--- a/bitfield.c
+++ b/bitfield.c
@@ -25,10 +25,10 @@
#include "ras-mce-handler.h"
#include "bitfield.h"
-unsigned bitfield_msg(char *buf, size_t len, const char **bitarray,
- unsigned array_len,
- unsigned bit_offset, unsigned ignore_bits,
- uint64_t status)
+unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+ unsigned int array_len,
+ unsigned int bit_offset, unsigned int ignore_bits,
+ uint64_t status)
{
int i, n;
char *p = buf;
@@ -64,6 +64,7 @@ unsigned bitfield_msg(char *buf, size_t len, const char **bitarray,
static uint64_t bitmask(uint64_t i)
{
uint64_t mask = 1;
+
while (mask < i)
mask = (mask << 1) | 1;
return mask;
@@ -77,6 +78,7 @@ void decode_bitfield(struct mce_event *e, uint64_t status,
for (f = fields; f->str; f++) {
uint64_t v = (status >> f->start_bit) & bitmask(f->stringlen - 1);
char *s = NULL;
+
if (v < f->stringlen)
s = f->str[v];
if (!s) {
@@ -93,11 +95,14 @@ void decode_numfield(struct mce_event *e, uint64_t status,
struct numfield *fields)
{
struct numfield *f;
+
for (f = fields; f->name; f++) {
uint64_t mask = (1ULL << (f->end - f->start + 1)) - 1;
uint64_t v = (status >> f->start) & mask;
+
if (v > 0 || f->force) {
char fmt[32] = {0};
+
snprintf(fmt, 32, "%%s: %s\n", f->fmt ? f->fmt : "%Lu");
mce_snprintf(e->error_msg, fmt, f->name, v);
}
diff --git a/mce-amd-k8.c b/mce-amd-k8.c
index dc772c2..f27b823 100644
--- a/mce-amd-k8.c
+++ b/mce-amd-k8.c
@@ -43,7 +43,7 @@ static const char *k8bank[] = {
};
static const char *k8threshold[] = {
- [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknow threshold counter",
+ [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknown threshold counter",
[K8_MCELOG_THRESHOLD_DRAM_ECC] = "MC4_MISC0 DRAM threshold",
[K8_MCELOG_THRESHOLD_LINK] = "MC4_MISC1 Link threshold",
[K8_MCELOG_THRESHOLD_L3_CACHE] = "MC4_MISC2 L3 Cache threshold",
@@ -56,25 +56,31 @@ static const char *k8threshold[] = {
static const char *transaction[] = {
"instruction", "data", "generic", "reserved"
};
+
static const char *cachelevel[] = {
"0", "1", "2", "generic"
};
+
static const char *memtrans[] = {
"generic error", "generic read", "generic write", "data read",
"data write", "instruction fetch", "prefetch", "evict", "snoop",
"?", "?", "?", "?", "?", "?", "?"
};
+
static const char *partproc[] = {
"local node origin", "local node response",
"local node observed", "generic participation"
};
+
static const char *timeout[] = {
"request didn't time out",
"request timed out"
};
+
static const char *memoryio[] = {
"memory", "res.", "i/o", "generic"
};
+
static const char *nbextendederr[] = {
"RAM ECC error",
"CRC error",
@@ -96,6 +102,7 @@ static const char *nbextendederr[] = {
"L3 Cache Tag Error",
"L3 Cache LRU Error"
};
+
static const char *highbits[32] = {
[31] = "valid",
[30] = "error overflow (multiple errors)",
@@ -164,7 +171,7 @@ static void decode_k8_dc_mc(struct mce_event *e)
if (e->status & (3ULL << 45)) {
mce_snprintf(e->error_msg,
"Data cache ECC error (syndrome %x)",
- (uint32_t) (e->status >> 47) & 0xff);
+ (uint32_t)(e->status >> 47) & 0xff);
if (e->status & (1ULL << 40))
mce_snprintf(e->error_msg, "found by scrubber");
}
@@ -185,7 +192,7 @@ static void decode_k8_ic_mc(struct mce_event *e)
if ((errcode & 0xfff0) == 0x0010)
mce_snprintf(e->error_msg, "TLB parity error in %s array",
- (exterrcode == 0) ? "physical" : "virtual");
+ (exterrcode == 0) ? "physical" : "virtual");
}
static void decode_k8_bu_mc(struct mce_event *e)
@@ -196,10 +203,10 @@ static void decode_k8_bu_mc(struct mce_event *e)
mce_snprintf(e->error_msg, "L2 cache ECC error");
mce_snprintf(e->error_msg, "%s array error",
- !exterrcode ? "Bus or cache" : "Cache tag");
+ !exterrcode ? "Bus or cache" : "Cache tag");
}
-static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
+static void decode_k8_nb_mc(struct mce_event *e, unsigned int *memerr)
{
unsigned short exterrcode = (e->status >> 16) & 0x0f;
@@ -209,13 +216,13 @@ static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
case 0:
*memerr = 1;
mce_snprintf(e->error_msg, "ECC syndrome = %x",
- (uint32_t) (e->status >> 47) & 0xff);
+ (uint32_t)(e->status >> 47) & 0xff);
break;
case 8:
*memerr = 1;
mce_snprintf(e->error_msg, "Chipkill ECC syndrome = %x",
- (uint32_t) ((((e->status >> 24) & 0xff) << 8)
- | ((e->status >> 47) & 0xff)));
+ (uint32_t)((((e->status >> 24) & 0xff) << 8)
+ | ((e->status >> 47) & 0xff)));
break;
case 1:
case 2:
@@ -223,7 +230,7 @@ static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
case 4:
case 6:
mce_snprintf(e->error_msg, "link number = %x",
- (uint32_t) (e->status >> 36) & 0xf);
+ (uint32_t)(e->status >> 36) & 0xf);
break;
}
}
@@ -251,11 +258,12 @@ static void bank_name(struct mce_event *e)
int parse_amd_k8_event(struct ras_events *ras, struct mce_event *e)
{
- unsigned ismemerr = 0;
+ unsigned int ismemerr = 0;
/* Don't handle GART errors */
if (e->bank == 4) {
unsigned short exterrcode = (e->status >> 16) & 0x0f;
+
if (exterrcode == 5 && (e->status & (1ULL << 61))) {
return -1;
}
diff --git a/mce-amd-smca.c b/mce-amd-smca.c
index 3fd97e0..c66a5f7 100644
--- a/mce-amd-smca.c
+++ b/mce-amd-smca.c
@@ -74,10 +74,10 @@ enum smca_bank_types {
SMCA_PCIE, /* PCI Express Unit */
SMCA_PCIE_V2,
SMCA_XGMI_PCS, /* xGMI PCS Unit */
- SMCA_NBIF, /*NBIF Unit */
- SMCA_SHUB, /* System Hub Unit */
- SMCA_SATA, /* SATA Unit */
- SMCA_USB, /* USB Unit */
+ SMCA_NBIF, /* NBIF Unit */
+ SMCA_SHUB, /* System Hub Unit */
+ SMCA_SATA, /* SATA Unit */
+ SMCA_USB, /* USB Unit */
SMCA_USR_DP, /* Ultra Short Reach Data Plane Controller */
SMCA_USR_CP, /* Ultra Short Reach Control Plane Controller */
SMCA_GMI_PCS, /* GMI PCS Unit */
@@ -833,7 +833,7 @@ static struct smca_bank_name smca_names[] = {
[SMCA_PSP ... SMCA_PSP_V2] = { "Platform Security Processor" },
[SMCA_SMU ... SMCA_SMU_V2] = { "System Management Unit" },
[SMCA_MP5] = { "Microprocessor 5 Unit" },
- [SMCA_MPDMA] = { "MPDMA Unit" },
+ [SMCA_MPDMA] = { "MPDMA Unit" },
[SMCA_NBIO] = { "Northbridge IO Unit" },
[SMCA_PCIE ... SMCA_PCIE_V2] = { "PCI Express Unit" },
[SMCA_XGMI_PCS] = { "Ext Global Memory Interconnect PCS Unit" },
@@ -851,7 +851,6 @@ static struct smca_bank_name smca_names[] = {
void amd_decode_errcode(struct mce_event *e)
{
-
decode_amd_errcode(e);
if (e->status & MCI_STATUS_POISON)
@@ -859,8 +858,8 @@ void amd_decode_errcode(struct mce_event *e)
if (e->status & MCI_STATUS_TCC)
mce_snprintf(e->mcistatus_msg, "Task_context_corrupt");
-
}
+
/*
* To find the UMC channel represented by this bank we need to match on its
* instance_id. The instance_id of a bank is held in the lower 32 bits of its
@@ -890,7 +889,7 @@ static int find_hbm_channel(struct mce_event *e)
return (umc % 2) ? tmp + 4 : tmp;
}
-static inline void fixup_hwid(struct mce_priv* m, uint32_t *hwid_mcatype)
+static inline void fixup_hwid(struct mce_priv *m, uint32_t *hwid_mcatype)
{
if (m->family == 0x19) {
switch (m->model) {
@@ -1006,7 +1005,7 @@ int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e)
uint64_t mcgstatus = e->mcgstatus;
mce_snprintf(e->mcgstatus_msg, "mcgstatus=%lld",
- (long long)e->mcgstatus);
+ (long long)e->mcgstatus);
if (mcgstatus & MCG_STATUS_RIPV)
mce_snprintf(e->mcgstatus_msg, "RIPV");
diff --git a/mce-amd.c b/mce-amd.c
index 116df11..ac0dbac 100644
--- a/mce-amd.c
+++ b/mce-amd.c
@@ -26,26 +26,31 @@
static char *transaction[] = {
"instruction", "data", "generic", "reserved"
};
+
/* Error codes: cache level (LL) */
static char *cachelevel[] = {
"reserved", "L1", "L2", "L3/generic"
};
+
/* Error codes: memory transaction type (RRRR) */
static char *memtrans[] = {
"generic", "generic read", "generic write", "data read",
"data write", "instruction fetch", "prefetch", "evict", "snoop",
"?", "?", "?", "?", "?", "?", "?"
};
+
/* Participation Processor */
static char *partproc[] = {
"local node origin", "local node response",
"local node observed", "generic participation"
};
+
/* Timeout */
static char *timeout[] = {
"request didn't time out",
"request timed out"
};
+
/* internal unclassified error code */
static char *internal[] = { "reserved",
"reserved",
@@ -118,5 +123,4 @@ void decode_amd_errcode(struct mce_event *e)
PP_MSG(ec), TO_MSG(ec),
R4_MSG(ec), LL_MSG(ec));
return;
-
}
diff --git a/mce-intel-broadwell-de.c b/mce-intel-broadwell-de.c
index d52c82e..8210782 100644
--- a/mce-intel-broadwell-de.c
+++ b/mce-intel-broadwell-de.c
@@ -78,7 +78,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -115,7 +115,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
@@ -140,7 +140,7 @@ void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
diff --git a/mce-intel-broadwell-epex.c b/mce-intel-broadwell-epex.c
index f7cd3b6..9c863d9 100644
--- a/mce-intel-broadwell-epex.c
+++ b/mce-intel-broadwell-epex.c
@@ -91,7 +91,7 @@ static char *qpi[] = {
[0x22] = "Phy detected in-band reset (no width change)",
[0x23] = "Link failover clock failover",
[0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
- [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+ [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
};
static struct field qpi_mc[] = {
@@ -118,7 +118,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -160,7 +160,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
@@ -185,7 +185,7 @@ void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
diff --git a/mce-intel-dunnington.c b/mce-intel-dunnington.c
index c695c62..71c3fb4 100644
--- a/mce-intel-dunnington.c
+++ b/mce-intel-dunnington.c
@@ -91,6 +91,7 @@ static void dunnington_decode_bus(struct mce_event *e, uint64_t status)
static void dunnington_decode_internal(struct mce_event *e, uint64_t status)
{
uint32_t mca = (status >> 16) & 0xffff;
+
if ((mca & 0xfff0) == 0)
decode_bitfield(e, mca, dnt_front_status);
else if ((mca & 0xf0ff) == 0)
@@ -104,6 +105,7 @@ static void dunnington_decode_internal(struct mce_event *e, uint64_t status)
void dunnington_decode_model(struct mce_event *e)
{
uint64_t status = e->status;
+
if ((status & 0xffff) == 0xe0f)
dunnington_decode_bus(e, status);
else if ((status & 0xffff) == (1 << 10))
diff --git a/mce-intel-haswell.c b/mce-intel-haswell.c
index 1791a36..195f6ed 100644
--- a/mce-intel-haswell.c
+++ b/mce-intel-haswell.c
@@ -23,7 +23,6 @@
#include "ras-mce-handler.h"
#include "bitfield.h"
-
/* See IA32 SDM Vol3B Table 16-20 */
static char *pcu_1[] = {
@@ -92,7 +91,7 @@ static char *qpi[] = {
[0x22] = "Phy detected in-band reset (no width change)",
[0x23] = "Link failover clock failover",
[0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
- [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+ [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
};
static struct field qpi_mc[] = {
@@ -120,7 +119,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -160,7 +159,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
@@ -185,7 +184,7 @@ void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
diff --git a/mce-intel-ivb.c b/mce-intel-ivb.c
index 0c5bebc..e5e6a7a 100644
--- a/mce-intel-ivb.c
+++ b/mce-intel-ivb.c
@@ -90,7 +90,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
struct mce_priv *mce = ras->mce_priv;
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -121,7 +121,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
@@ -146,7 +146,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 >= 0 && rank1 >= 0)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 >= 0)
mce_snprintf(e->mc_location, "rank=%d", rank0);
else
@@ -162,7 +162,7 @@ void ivb_decode_model(struct ras_events *ras, struct mce_event *e)
* faling rank to a DIMM slot.
*/
#if 0
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
{
switch (failrank) {
case 0: case 1: case 2: case 3:
diff --git a/mce-intel-knl.c b/mce-intel-knl.c
index 7062fbb..0e2ea80 100644
--- a/mce-intel-knl.c
+++ b/mce-intel-knl.c
@@ -36,7 +36,7 @@ void knl_decode_model(struct ras_events *ras, struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan = 0;
+ unsigned int rank0 = -1, rank1 = -1, chan = 0;
switch (e->bank) {
case 5:
diff --git a/mce-intel-nehalem.c b/mce-intel-nehalem.c
index ad4ce69..18992d1 100644
--- a/mce-intel-nehalem.c
+++ b/mce-intel-nehalem.c
@@ -112,9 +112,9 @@ void nehalem_decode_model(struct mce_event *e)
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
uint64_t misc = e->misc;
- unsigned channel, dimm;
+ unsigned int channel, dimm;
- if ((mca >> 11) == 1) { /* bus and interconnect QPI */
+ if ((mca >> 11) == 1) { /* bus and interconnect QPI */
decode_bitfield(e, status, qpi_status);
if (status & MCI_STATUS_MISCV) {
decode_numfield(e, misc, qpi_numbers);
@@ -143,6 +143,7 @@ void xeon75xx_decode_model(struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
+
if (mca == 0x0001) { /* internal unspecified */
decode_bitfield(e, status, internal_error_status);
decode_numfield(e, status, internal_error_numbers);
diff --git a/mce-intel-p4-p6.c b/mce-intel-p4-p6.c
index 5c6c3ff..2751d34 100644
--- a/mce-intel-p4-p6.c
+++ b/mce-intel-p4-p6.c
@@ -66,8 +66,8 @@ static struct field p6_shared_status[] = {
FIELD(25, bus_queue_error_type),
SBITFIELD(30, "internal BINIT"),
SBITFIELD(36, "received parity error on response transaction"),
- SBITFIELD(38, "timeout BINIT (ROB timeout)."
- " No micro-instruction retired for some time"),
+ SBITFIELD(38,
+ "timeout BINIT (ROB timeout). No micro-instruction retired for some time"),
FIELD_NULL(39),
SBITFIELD(42, "bus transaction received hard error response"),
SBITFIELD(43, "failure that caused IERR"),
@@ -86,7 +86,7 @@ static struct field p6old_status[] = {
FIELD_NULL(31),
FIELD_NULL(32),
SBITFIELD(35, "BINIT received from external bus"),
- SBITFIELD(37, "Received hard error reponse on split transaction (Bus BINIT)"),
+ SBITFIELD(37, "Received hard error response on split transaction (Bus BINIT)"),
{}
};
@@ -109,7 +109,7 @@ static struct numfield p6old_status_numbers[] = {
static struct {
int value;
char *str;
-} p4_model []= {
+} p4_model[] = {
{16, "FSB address parity"},
{17, "Response hard fail"},
{18, "Response parity"},
@@ -123,7 +123,7 @@ static struct {
void p4_decode_model(struct mce_event *e)
{
uint32_t model = e->status & 0xffff0000L;
- unsigned i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(p4_model); i++) {
if (model & (1 << p4_model[i].value))
diff --git a/mce-intel-sb.c b/mce-intel-sb.c
index e754496..385b125 100644
--- a/mce-intel-sb.c
+++ b/mce-intel-sb.c
@@ -82,7 +82,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
{
struct mce_priv *mce = ras->mce_priv;
uint32_t mca = e->status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -113,7 +113,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 8 || e->bank > 11 || (e->status & MCI_STATUS_UC) ||
- !test_prefix(7, e->status & 0xefff))
+ !test_prefix(7, e->status & 0xefff))
return;
/*
@@ -138,7 +138,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 >= 0 && rank1 >= 0)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 >= 0)
mce_snprintf(e->mc_location, "rank=%d", rank0);
else
@@ -162,7 +162,7 @@ void snb_decode_model(struct ras_events *ras, struct mce_event *e)
* can be converted to a DIMM number within a channel for systems with either
* two or three DIMMs per channel.
*/
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
{
switch (failrank) {
case 0: case 1: case 2: case 3:
diff --git a/mce-intel-skylake-xeon.c b/mce-intel-skylake-xeon.c
index 680578a..37e5e11 100644
--- a/mce-intel-skylake-xeon.c
+++ b/mce-intel-skylake-xeon.c
@@ -170,7 +170,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
@@ -221,7 +221,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 13 || e->bank > 18 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
@@ -246,7 +246,7 @@ void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e)
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
diff --git a/mce-intel-tulsa.c b/mce-intel-tulsa.c
index e59bf06..f38d638 100644
--- a/mce-intel-tulsa.c
+++ b/mce-intel-tulsa.c
@@ -105,6 +105,7 @@ static void tulsa_decode_bus(struct mce_event *e, uint64_t status)
static void tulsa_decode_internal(struct mce_event *e, uint64_t status)
{
uint32_t mca = (status >> 16) & 0xffff;
+
if ((mca & 0xfff0) == 0)
decode_bitfield(e, mca, tls_front_status);
else if ((mca & 0xf0ff) == 0)
diff --git a/mce-intel.c b/mce-intel.c
index 18a9072..7f48cc4 100644
--- a/mce-intel.c
+++ b/mce-intel.c
@@ -57,8 +57,7 @@
#define BUS_PP_MASK 0x600 /*bit 9, bit 10*/
#define BUS_PP_SHIFT 0x9
-#define MCG_TES_P (1ULL<<11) /* Yellow bit cache threshold supported */
-
+#define MCG_TES_P BIT_ULL(11) /* Yellow bit cache threshold supported */
static char *TT[] = {
"Instruction",
@@ -76,8 +75,8 @@ static char *LL[] = {
static struct {
uint8_t value;
- char* str;
-} RRRR [] = {
+ char *str;
+} RRRR[] = {
{0, "Generic"},
{1, "Read"},
{2, "Write" },
@@ -121,7 +120,7 @@ static char *mca_msg[] = {
static char *tracking_msg[] = {
[1] = "green",
[2] = "yellow",
- [3] ="res3"
+ [3] = "res3"
};
static const char *arstate[4] = {
@@ -157,9 +156,9 @@ static void decode_memory_controller(struct mce_event *e, uint32_t status)
sprintf(channel, "%u", status & 0xf);
mce_snprintf(e->error_msg, "MEMORY CONTROLLER %s_CHANNEL%s_ERR",
- mmm_mnemonic[(status >> 4) & 7], channel);
+ mmm_mnemonic[(status >> 4) & 7], channel);
mce_snprintf(e->error_msg, "Transaction: %s",
- mmm_desc[(status >> 4) & 7]);
+ mmm_desc[(status >> 4) & 7]);
}
static void decode_termal_bank(struct mce_event *e)
@@ -207,7 +206,7 @@ static void bank_name(struct mce_event *e)
static char *get_RRRR_str(uint8_t rrrr)
{
- unsigned i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(RRRR); i++) {
if (RRRR[i].value == rrrr) {
@@ -220,7 +219,7 @@ static char *get_RRRR_str(uint8_t rrrr)
#define decode_attr(arr, val) ({ \
char *__str; \
- if ((unsigned)(val) >= ARRAY_SIZE(arr)) \
+ if ((unsigned int)(val) >= ARRAY_SIZE(arr)) \
__str = "UNKNOWN"; \
else \
__str = (arr)[val]; \
@@ -248,17 +247,17 @@ static void decode_mca(struct mce_event *e, uint64_t track, int *ismemerr)
decode_attr(LL, mca & 3));
} else if (test_prefix(4, mca)) {
mce_snprintf(e->mcastatus_msg, "%s TLB %s Error",
- decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
- decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
+ decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
+ decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
} else if (test_prefix(8, mca)) {
- unsigned typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
- unsigned levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
+ unsigned int typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
+ unsigned int levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
char *type = decode_attr(TT, typenum);
char *level = decode_attr(LL, levelnum);
+
mce_snprintf(e->mcastatus_msg,
"%s CACHE %s %s Error", type, level,
- get_RRRR_str((mca & CACHE_RRRR_MASK) >>
- CACHE_RRRR_SHIFT));
+ get_RRRR_str((mca & CACHE_RRRR_MASK) >> CACHE_RRRR_SHIFT));
#if 0
/* FIXME: We shouldn't mix parsing with actions */
if (track == 2)
@@ -313,15 +312,13 @@ static void decode_mci(struct mce_event *e, int *ismemerr)
else
mce_snprintf(e->mcistatus_msg, "Corrected_error");
-
if (e->status & MCI_STATUS_EN)
mce_snprintf(e->mcistatus_msg, "Error_enabled");
-
if (e->status & MCI_STATUS_PCC)
mce_snprintf(e->mcistatus_msg, "Processor_context_corrupt");
- if (e->status & (MCI_STATUS_S|MCI_STATUS_AR))
+ if (e->status & (MCI_STATUS_S | MCI_STATUS_AR))
mce_snprintf(e->mcistatus_msg, "%s",
arstate[(e->status >> 55) & 3]);
@@ -350,14 +347,14 @@ int parse_intel_event(struct ras_events *ras, struct mce_event *e)
/* Check if the error is at the memory controller */
if (((e->status & 0xffff) >> 7) == 1) {
- unsigned corr_err_cnt;
+ unsigned int corr_err_cnt;
corr_err_cnt = EXTRACT(e->status, 38, 52);
mce_snprintf(e->mc_location, "n_errors=%d", corr_err_cnt);
}
if (test_prefix(11, (e->status & 0xffffL))) {
- switch(mce->cputype) {
+ switch (mce->cputype) {
case CPU_P6OLD:
p6old_decode_model(e);
break;
@@ -375,7 +372,7 @@ int parse_intel_event(struct ras_events *ras, struct mce_event *e)
break;
}
}
- switch(mce->cputype) {
+ switch (mce->cputype) {
case CPU_NEHALEM:
nehalem_decode_model(e);
break;
@@ -447,18 +444,18 @@ static int domsr(int cpu, int msr, int bit)
return -EINVAL;
}
}
- if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot read MSR_ERROR_CONTROL from %s\n", fpath);
return -EINVAL;
}
data |= bit;
- if (pwrite(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pwrite(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot write MSR_ERROR_CONTROL to %s\n", fpath);
return -EINVAL;
}
- if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot re-read MSR_ERROR_CONTROL from %s\n", fpath);
return -EINVAL;
@@ -472,7 +469,7 @@ static int domsr(int cpu, int msr, int bit)
return 0;
}
-int set_intel_imc_log(enum cputype cputype, unsigned ncpus)
+int set_intel_imc_log(enum cputype cputype, unsigned int ncpus)
{
int cpu, msr, bit, rc;
diff --git a/non-standard-ampere.c b/non-standard-ampere.c
index 05b5252..79e09a0 100644
--- a/non-standard-ampere.c
+++ b/non-standard-ampere.c
@@ -31,6 +31,7 @@ static const char * const disp_payload0_err_reg_name[] = {
"MISC2:",
"MISC3:",
};
+
/*PCIe AER Error Payload Type 1*/
static const char * const disp_payload1_err_reg_name[] = {
"Error Type:",
@@ -86,7 +87,6 @@ static const char * const err_cpm_sub_type[] = {
"ARMv8 Core 1",
};
-
static const char * const err_mcu_sub_type[] = {
"ERR0",
"ERR1",
@@ -155,8 +155,6 @@ static char *err_smmu_sub_type(int etype)
return "unknown error";
}
-
-
static const char * const err_pcie_aer_sub_type[] = {
"Root Port",
"Device",
@@ -173,7 +171,6 @@ static char *err_peci_rasdp_sub_type(int etype)
return "unknown error";
}
-
static const char * const err_ocm_sub_type[] = {
"ERR0",
"ERR1",
@@ -327,7 +324,7 @@ static const struct amp_ras_type_info amp_payload_error_type[] = {
/*get the error type name*/
static const char *oem_type_name(const struct amp_ras_type_info *info,
- uint8_t type_id)
+ uint8_t type_id)
{
const struct amp_ras_type_info *type = &info[0];
@@ -350,7 +347,7 @@ static const char *oem_subtype_name(const struct amp_ras_type_info *info,
if (type->id != type_id)
continue;
- if (type->sub == NULL)
+ if (!type->sub)
return type->name;
if (sub_type_id >= type->sub_num)
return "unknown";
@@ -477,7 +474,7 @@ static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
}
static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
- const char *name)
+ const char *name)
{
int rc;
@@ -502,37 +499,37 @@ static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
/*save all Ampere Specific Error Payload type 0 to sqlite3 database*/
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload0_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD0_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
+ AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_ADDR_REG,
+ AMP_PAYLOAD0_FIELD_ADDR_REG,
err->err_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC0,
+ AMP_PAYLOAD0_FIELD_MISC0,
err->err_misc_0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC1,
+ AMP_PAYLOAD0_FIELD_MISC1,
err->err_misc_1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC2,
+ AMP_PAYLOAD0_FIELD_MISC2,
err->err_misc_2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC3,
+ AMP_PAYLOAD0_FIELD_MISC3,
err->err_misc_3, NULL);
store_amp_err_data(ev_decoder, "amp_payload0_event_tab");
}
@@ -540,10 +537,10 @@ static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
/*save all Ampere Specific Error Payload type 1 to sqlite3 database*/
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload1_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD1_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
@@ -590,45 +587,45 @@ static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
/*save all Ampere Specific Error Payload type 2 to sqlite3 database*/
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload2_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload2_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD2_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
+ AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
err->ce_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_LOACATION,
+ AMP_PAYLOAD2_FIELD_CE_LOACATION,
err->ce_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_ADDR,
+ AMP_PAYLOAD2_FIELD_CE_ADDR,
err->ce_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
+ AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
err->ue_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_LOCATION,
+ AMP_PAYLOAD2_FIELD_UE_LOCATION,
err->ue_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_ADDR,
+ AMP_PAYLOAD2_FIELD_UE_ADDR,
err->ue_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_RESERVED1,
+ AMP_PAYLOAD2_FIELD_RESERVED1,
err->reserved1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD2_FIELD_RESERVED2,
+ AMP_PAYLOAD2_FIELD_RESERVED2,
err->reserved2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD2_FIELD_RESERVED3,
+ AMP_PAYLOAD2_FIELD_RESERVED3,
err->reserved3, NULL);
store_amp_err_data(ev_decoder, "amp_payload2_event_tab");
}
@@ -636,36 +633,36 @@ static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
/*save all Ampere Specific Error Payload type 3 to sqlite3 database*/
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload3_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD3_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
err->fw_speci_data0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
err->fw_speci_data1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
err->fw_speci_data2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
err->fw_speci_data3, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
err->fw_speci_data4, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
err->fw_speci_data5, NULL);
store_amp_err_data(ev_decoder, "amp_payload3_event_tab");
}
@@ -680,29 +677,29 @@ static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
}
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload0_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload0_type_sec *err)
{
return 0;
}
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload1_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload1_type_sec *err)
{
return 0;
}
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload2_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload2_type_sec *err)
{
return 0;
}
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload3_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload3_type_sec *err)
{
return 0;
}
@@ -716,7 +713,7 @@ static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder, char *name)
/*decode ampere specific error payload type 0, the CPU's data is save*/
/*to sqlite by ras-arm-handler, others are saved by this function.*/
void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
+ struct trace_seq *s,
const struct amp_payload0_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
@@ -803,8 +800,8 @@ void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
/*decode ampere specific error payload type 1 and save to sqlite db*/
static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload1_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload1_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
@@ -887,8 +884,8 @@ static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
/*decode ampere specific error payload type 2 and save to sqlite db*/
static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload2_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload2_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
@@ -903,7 +900,7 @@ static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
subtype_str = err_peci_rasdp_sub_type(err->subtype);
else
subtype_str = oem_subtype_name(amp_payload_error_type,
- TYPE(err->type), err->subtype);
+ TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
@@ -972,8 +969,8 @@ static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
/*decode ampere specific error payload type 3 and save to sqlite db*/
static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload3_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload3_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
@@ -989,7 +986,6 @@ static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
-
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", subtype_str);
@@ -1074,13 +1070,13 @@ static int decode_amp_oem_type_error(struct ras_events *ras,
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
&db_tab) != SQLITE_OK) {
trace_seq_printf(s,
- "create sql %s fail\n",
- sqlite3_table_list[payload_type]);
+ "create sql %s fail\n",
+ sqlite3_table_list[payload_type]);
return -1;
}
}
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- id, 0, event->timestamp);
+ id, 0, event->timestamp);
#endif
if (payload_type == PAYLOAD_TYPE_0) {
diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c
index 0899812..e482a7a 100644
--- a/non-standard-hisi_hip08.c
+++ b/non-standard-hisi_hip08.c
@@ -453,7 +453,7 @@ static const char *oem_submodule_name(const struct hisi_module_info *info,
if (module->id != module_id)
continue;
- if (module->sub == NULL)
+ if (!module->sub)
return module->name;
if (sub_module_id >= module->sub_num)
@@ -675,7 +675,7 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
struct ras_non_standard_event *event)
{
const struct hisi_oem_type1_err_sec *err =
- (struct hisi_oem_type1_err_sec*)event->error;
+ (struct hisi_oem_type1_err_sec *)event->error;
if (err->val_bits == 0) {
trace_seq_printf(s, "%s: no valid error information\n",
diff --git a/non-standard-hisilicon.c b/non-standard-hisilicon.c
index 7296d28..e9ea5df 100644
--- a/non-standard-hisilicon.c
+++ b/non-standard-hisilicon.c
@@ -88,10 +88,10 @@ struct hisi_event {
#ifdef HAVE_SQLITE3
void record_vendor_data(struct ras_ns_ev_decoder *ev_decoder,
- enum hisi_oem_data_type data_type,
+ enum hisi_oem_data_type data_type,
int id, int64_t data, const char *text)
{
- if (ev_decoder->stmt_dec_record == NULL)
+ if (!ev_decoder->stmt_dec_record)
return;
switch (data_type) {
@@ -111,7 +111,7 @@ int step_vendor_data_tab(struct ras_ns_ev_decoder *ev_decoder, const char *name)
{
int rc;
- if (ev_decoder->stmt_dec_record == NULL)
+ if (!ev_decoder->stmt_dec_record)
return 0;
rc = sqlite3_step(ev_decoder->stmt_dec_record);
@@ -171,13 +171,13 @@ static const struct db_table_descriptor hisi_common_section_tab = {
};
#endif
-static const char* soc_desc[] = {
+static const char *soc_desc[] = {
"Kunpeng916",
"Kunpeng920",
"Kunpeng930",
};
-static const char* module_name[] = {
+static const char *module_name[] = {
"MN",
"PLL",
"SLLC",
@@ -221,9 +221,9 @@ static const char* module_name[] = {
"HBMC",
};
-static const char* get_soc_desc(uint8_t soc_id)
+static const char *get_soc_desc(uint8_t soc_id)
{
- if (soc_id >= sizeof(soc_desc)/sizeof(char *))
+ if (soc_id >= sizeof(soc_desc) / sizeof(char *))
return "unknown";
return soc_desc[soc_id];
@@ -232,7 +232,7 @@ static const char* get_soc_desc(uint8_t soc_id)
static void decode_module(struct ras_ns_ev_decoder *ev_decoder,
struct hisi_event *event, uint8_t module_id)
{
- if (module_id >= sizeof(module_name)/sizeof(char *)) {
+ if (module_id >= sizeof(module_name) / sizeof(char *)) {
HISI_SNPRINTF(event->error_msg, "module=unknown(id=%hhu) ", module_id);
record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_TEXT,
HISI_COMMON_FIELD_MODULE_ID,
@@ -246,7 +246,7 @@ static void decode_module(struct ras_ns_ev_decoder *ev_decoder,
}
static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder,
- const struct hisi_common_error_section *err,
+ const struct hisi_common_error_section *err,
struct hisi_event *event)
{
HISI_SNPRINTF(event->error_msg, "[ table_version=%hhu", err->version);
diff --git a/non-standard-yitian.c b/non-standard-yitian.c
index 4c30514..daadb95 100644
--- a/non-standard-yitian.c
+++ b/non-standard-yitian.c
@@ -86,25 +86,25 @@ static const struct db_table_descriptor yitian_ddr_payload_section_tab = {
};
int record_yitian_ddr_reg_dump_event(struct ras_ns_ev_decoder *ev_decoder,
- struct ras_yitian_ddr_payload_event *ev)
+ struct ras_yitian_ddr_payload_event *ev)
{
int rc;
struct sqlite3_stmt *stmt = ev_decoder->stmt_dec_record;
log(TERM, LOG_INFO, "yitian_ddr_reg_dump_event store: %p\n", stmt);
- sqlite3_bind_text (stmt, 1, ev->timestamp, -1, NULL);
- sqlite3_bind_int64 (stmt, 2, ev->address);
- sqlite3_bind_text (stmt, 3, ev->reg_msg, -1, NULL);
+ sqlite3_bind_text(stmt, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_int64(stmt, 2, ev->address);
+ sqlite3_bind_text(stmt, 3, ev->reg_msg, -1, NULL);
rc = sqlite3_step(stmt);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
+ "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
rc = sqlite3_reset(stmt);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
+ "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
log(TERM, LOG_INFO, "register inserted at db\n");
return rc;
@@ -112,7 +112,7 @@ int record_yitian_ddr_reg_dump_event(struct ras_ns_ev_decoder *ev_decoder,
#endif
static const char *oem_type_name(const struct yitian_ras_type_info *info,
- uint8_t type_id)
+ uint8_t type_id)
{
const struct yitian_ras_type_info *type = &info[0];
@@ -134,7 +134,7 @@ static const char *oem_subtype_name(const struct yitian_ras_type_info *info,
if (type->id != type_id)
continue;
- if (type->sub == NULL)
+ if (!type->sub)
return type->name;
if (sub_type_id >= type->sub_num)
return "unknown";
@@ -144,7 +144,7 @@ static const char *oem_subtype_name(const struct yitian_ras_type_info *info,
}
void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
+ struct trace_seq *s,
const struct yitian_ddr_payload_type_sec *err,
struct ras_events *ras)
{
@@ -168,7 +168,7 @@ void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
tm = localtime(&now);
if (tm)
strftime(ev.timestamp, sizeof(ev.timestamp),
- "%Y-%m-%d %H:%M:%S %z", tm);
+ "%Y-%m-%d %H:%M:%S %z", tm);
//display error type
p += snprintf(p, end - p, " %s", yitian_ddr_payload_err_reg_name[i++]);
p += snprintf(p, end - p, " %s,", type_str);
@@ -204,18 +204,17 @@ void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
#ifdef HAVE_SQLITE3
record_yitian_ddr_reg_dump_event(ev_decoder, &ev);
#endif
-
}
static int add_yitian_common_table(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder)
+ struct ras_ns_ev_decoder *ev_decoder)
{
#ifdef HAVE_SQLITE3
if (ras->record_events && !ev_decoder->stmt_dec_record) {
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
- &yitian_ddr_payload_section_tab) != SQLITE_OK) {
+ &yitian_ddr_payload_section_tab) != SQLITE_OK) {
log(TERM, LOG_WARNING,
- "Failed to create sql yitian_ddr_payload_section_tab\n");
+ "Failed to create sql yitian_ddr_payload_section_tab\n");
return -1;
}
}
@@ -253,6 +252,7 @@ struct ras_ns_ev_decoder yitian_ns_oem_decoder[] = {
static void __attribute__((constructor)) yitian_ns_init(void)
{
int i;
+
for (i = 0; i < ARRAY_SIZE(yitian_ns_oem_decoder); i++)
register_ns_ev_decoder(&yitian_ns_oem_decoder[i]);
}
diff --git a/queue.c b/queue.c
index 65b6fb8..a90ed6a 100644
--- a/queue.c
+++ b/queue.c
@@ -29,7 +29,7 @@ struct link_queue *init_queue(void)
struct link_queue *queue = NULL;
queue = (struct link_queue *)malloc(sizeof(struct link_queue));
- if (queue == NULL) {
+ if (!queue) {
log(TERM, LOG_ERR, "Failed to allocate memory for queue.\n");
return NULL;
}
@@ -43,13 +43,13 @@ struct link_queue *init_queue(void)
void clear_queue(struct link_queue *queue)
{
- if (queue == NULL)
+ if (!queue)
return;
struct queue_node *node = queue->head;
struct queue_node *tmp = NULL;
- while (node != NULL) {
+ while (node) {
tmp = node;
node = node->next;
free(tmp);
@@ -72,7 +72,7 @@ void free_queue(struct link_queue *queue)
void push(struct link_queue *queue, struct queue_node *node)
{
/* there is no element in the queue */
- if (queue->head == NULL)
+ if (!queue->head)
queue->head = node;
else
queue->tail->next = node;
@@ -85,7 +85,7 @@ int pop(struct link_queue *queue)
{
struct queue_node *tmp = NULL;
- if (queue == NULL || is_empty(queue))
+ if (!queue || is_empty(queue))
return -1;
tmp = queue->head;
@@ -98,7 +98,7 @@ int pop(struct link_queue *queue)
struct queue_node *front(struct link_queue *queue)
{
- if (queue == NULL)
+ if (!queue)
return NULL;
return queue->head;
@@ -109,7 +109,7 @@ struct queue_node *node_create(time_t time, unsigned int value)
struct queue_node *node = NULL;
node = (struct queue_node *)malloc(sizeof(struct queue_node));
- if (node != NULL) {
+ if (node) {
node->time = time;
node->value = value;
node->next = NULL;
diff --git a/ras-aer-handler.c b/ras-aer-handler.c
index d6898e0..a867ae4 100644
--- a/ras-aer-handler.c
+++ b/ras-aer-handler.c
@@ -82,7 +82,7 @@ int ras_aer_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
@@ -177,7 +177,7 @@ int ras_aer_event_handler(struct trace_seq *s,
sel_data[4] = (((dev & 0x1f) << 3) | (fn & 0x7));
sprintf(ipmi_add_sel,
- "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
+ "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
sel_data[0], sel_data[1], sel_data[2], sel_data[3], sel_data[4]);
system(ipmi_add_sel);
diff --git a/ras-arm-handler.c b/ras-arm-handler.c
index 731176d..c7e9fd5 100644
--- a/ras-arm-handler.c
+++ b/ras-arm-handler.c
@@ -29,7 +29,7 @@
#define BIT2 2
void display_raw_data(struct trace_seq *s,
- const uint8_t *buf,
+ const uint8_t *buf,
uint32_t datalen)
{
int i = 0, line_count = 0;
@@ -72,7 +72,7 @@ static int count_errors(struct ras_arm_event *ev, int sev)
if (ev->pei_len % err_info_size != 0) {
log(TERM, LOG_ERR,
- "The event data does not match to the ARM Processor Error Information Structure\n");
+ "The event data does not match to the ARM Processor Error Information Structure\n");
return num;
}
num_pei = ev->pei_len / err_info_size;
@@ -172,7 +172,7 @@ int ras_arm_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-cpu-isolation.c b/ras-cpu-isolation.c
index 90633fd..8af31e9 100644
--- a/ras-cpu-isolation.c
+++ b/ras-cpu-isolation.c
@@ -120,7 +120,7 @@ static int init_cpu_info(unsigned int cpus)
cpu_infos = (struct cpu_info *)malloc(sizeof(*cpu_infos) * cpus);
if (!cpu_infos) {
log(TERM, LOG_ERR,
- "Failed to allocate memory for cpu infos in %s.\n", __func__);
+ "Failed to allocate memory for cpu infos in %s.\n", __func__);
return -1;
}
@@ -130,9 +130,9 @@ static int init_cpu_info(unsigned int cpus)
cpu_infos[i].state = get_cpu_status(i);
cpu_infos[i].ce_queue = init_queue();
- if (cpu_infos[i].ce_queue == NULL) {
+ if (!cpu_infos[i].ce_queue) {
log(TERM, LOG_ERR,
- "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
+ "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
return -1;
}
}
@@ -147,7 +147,7 @@ static void check_config(struct isolation_param *config)
{
if (config->value > config->limit) {
log(TERM, LOG_WARNING, "Value: %lu exceed limit: %lu, set to limit\n",
- config->value, config->limit);
+ config->value, config->limit);
config->value = config->limit;
}
}
@@ -173,7 +173,7 @@ static int parse_ul_config(struct isolation_param *config, char *env, unsigned l
for (int i = 0; i < env_size; ++i) {
if (isdigit(env[i])) {
if (*value > ULONG_MAX / DEC_CHECK ||
- (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
+ (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
log(TERM, LOG_ERR, "%s is out of range: %lu\n", env, ULONG_MAX);
return -1;
}
@@ -208,7 +208,7 @@ static void init_config(struct isolation_param *config)
if (parse_ul_config(config, env, &value) < 0) {
log(TERM, LOG_ERR, "Invalid %s: %s! Use default value %lu.\n",
- config->name, env, config->value);
+ config->name, env, config->value);
return;
}
@@ -220,7 +220,7 @@ static int check_config_status(void)
{
char *env = getenv("CPU_ISOLATION_ENABLE");
- if (env == NULL || strcasecmp(env, "yes"))
+ if (!env || strcasecmp(env, "yes"))
return -1;
return 0;
@@ -295,12 +295,12 @@ static int do_ce_handler(unsigned int cpu)
cpu_infos[cpu].ce_nums -= tmp;
}
log(TERM, LOG_INFO,
- "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
+ "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
cpu, cpu_infos[cpu].ce_nums);
if (cpu_infos[cpu].ce_nums >= threshold.value) {
log(TERM, LOG_INFO,
- "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
+ "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
threshold.value, cpu);
return do_cpu_offline(cpu);
}
@@ -341,7 +341,7 @@ static void record_error_info(unsigned int cpu, struct error_info *err_info)
{
struct queue_node *node = node_create(err_info->time, err_info->nums);
- if (node == NULL) {
+ if (!node) {
log(TERM, LOG_ERR, "Fail to allocate memory for queue node\n");
return;
}
@@ -366,7 +366,7 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
if (cpu >= ncores || cpu < 0) {
log(TERM, LOG_ERR,
- "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
+ "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
return;
}
@@ -385,7 +385,7 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
*/
if (ncores - sysconf(_SC_NPROCESSORS_ONLN) >= cpu_limit.value) {
log(TERM, LOG_WARNING,
- "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
+ "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
cpu_limit.value);
return;
}
@@ -395,11 +395,11 @@ void ras_record_cpu_error(struct error_info *err_info, int cpu)
log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu);
else if (ret == HANDLE_SUCCEED) {
log(TERM, LOG_INFO, "Offline cpu%d succeed, the state is %s\n",
- cpu, cpu_state[cpu_infos[cpu].state]);
+ cpu, cpu_state[cpu_infos[cpu].state]);
clear_queue(cpu_infos[cpu].ce_queue);
cpu_infos[cpu].ce_nums = 0;
cpu_infos[cpu].uce_nums = 0;
} else
log(TERM, LOG_WARNING, "Offline cpu%d fail, the state is %s\n",
- cpu, cpu_state[cpu_infos[cpu].state]);
+ cpu, cpu_state[cpu_infos[cpu].state]);
}
diff --git a/ras-devlink-handler.c b/ras-devlink-handler.c
index e52d66e..b19ccaa 100644
--- a/ras-devlink-handler.c
+++ b/ras-devlink-handler.c
@@ -38,7 +38,7 @@ int ras_net_xmit_timeout_handler(struct trace_seq *s,
struct devlink_event ev;
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
@@ -78,7 +78,6 @@ int ras_net_xmit_timeout_handler(struct trace_seq *s,
free(ev.msg);
return 0;
-
}
int ras_devlink_event_handler(struct trace_seq *s,
@@ -104,7 +103,7 @@ int ras_devlink_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-diskerror-handler.c b/ras-diskerror-handler.c
index b46f859..618afdb 100644
--- a/ras-diskerror-handler.c
+++ b/ras-diskerror-handler.c
@@ -30,7 +30,6 @@
#include "ras-logger.h"
#include "ras-report.h"
-
static const struct {
int error;
const char *name;
@@ -82,7 +81,7 @@ int ras_diskerror_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-events.c b/ras-events.c
index 2cc54b3..c83b8de 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -58,7 +58,7 @@
#define ENDIAN KBUFFER_ENDIAN_BIG
#endif
-extern char* choices_disable;
+extern char *choices_disable;
static const struct event_trigger event_triggers[] = {
{ "mc_event", &mc_event_trigger_setup },
@@ -71,7 +71,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
char line[MAX_PATH + 1 + 256];
char *p, *type, *dir;
- fp = fopen("/proc/mounts","r");
+ fp = fopen("/proc/mounts", "r");
if (!fp) {
log(ALL, LOG_INFO, "Can't open /proc/mounts");
return errno;
@@ -99,7 +99,7 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
tracing_dir[len - 1] = '\0';
return 0;
}
- } while(1);
+ } while (1);
fclose(fp);
log(ALL, LOG_INFO, "Can't find debugfs\n");
@@ -144,7 +144,7 @@ static int get_tracing_dir(struct ras_events *ras)
strcat(ras->tracing, "/tracing");
if (has_instances) {
strcat(ras->tracing, "/instances/" TOOL_NAME);
- rc = mkdir(ras->tracing, S_IRWXU);
+ rc = mkdir(ras->tracing, 0700);
if (rc < 0 && errno != EEXIST) {
log(ALL, LOG_INFO,
"Unable to create " TOOL_NAME " instance at %s\n",
@@ -155,13 +155,14 @@ static int get_tracing_dir(struct ras_events *ras)
return 0;
}
-static int is_disabled_event(char *group, char *event) {
+static int is_disabled_event(char *group, char *event)
+{
char ras_event_name[MAX_PATH + 1];
snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
- group, event);
+ group, event);
- if (choices_disable != NULL && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
+ if (choices_disable && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
return 1;
}
return 0;
@@ -175,6 +176,7 @@ static int __toggle_ras_mc_event(struct ras_events *ras,
{
int fd, rc;
char fname[MAX_PATH + 1];
+
enable = is_disabled_event(group, event) ? 0 : 1;
snprintf(fname, sizeof(fname), "%s%s:%s\n",
@@ -188,7 +190,7 @@ static int __toggle_ras_mc_event(struct ras_events *ras,
return errno;
}
- rc = write(fd, fname,strlen(fname));
+ rc = write(fd, fname, strlen(fname));
if (rc < 0) {
log(ALL, LOG_WARNING, "Can't write to set_event\n");
close(fd);
@@ -330,7 +332,6 @@ static int get_pagesize(struct ras_events *ras, struct pevent *pevent)
error:
close(fd);
return page_size;
-
}
static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
@@ -411,7 +412,7 @@ static int set_buffer_percent(struct ras_events *ras, int percent)
}
static int read_ras_event_all_cpus(struct pthread_data *pdata,
- unsigned n_cpus)
+ unsigned int n_cpus)
{
ssize_t size;
unsigned long long time_stamp;
@@ -462,7 +463,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
/* FIXME: use select to open for all CPUs */
snprintf(pipe_raw, sizeof(pipe_raw),
- "per_cpu/cpu%d/trace_pipe_raw", i);
+ "per_cpu/cpu%d/trace_pipe_raw", i);
fds[i].fd = open_trace(pdata[0].ras, pipe_raw, O_RDONLY);
if (fds[i].fd < 0) {
@@ -512,7 +513,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
fdsiginfo.ssi_signo == SIGTERM ||
fdsiginfo.ssi_signo == SIGHUP ||
fdsiginfo.ssi_signo == SIGQUIT) {
- log(TERM, LOG_INFO, "Recevied signal=%d\n",
+ log(TERM, LOG_INFO, "Received signal=%d\n",
fdsiginfo.ssi_signo);
goto cleanup;
} else {
@@ -717,7 +718,7 @@ static int select_tracing_timestamp(struct ras_events *ras)
int fd, rc;
time_t uptime, now;
size_t size;
- unsigned j1;
+ unsigned int j1;
char buf[4096];
/* Check if uptime is supported (kernel 3.10-rc1 or upper) */
@@ -850,7 +851,7 @@ static int add_event_handler(struct ras_events *ras, struct pevent *pevent,
if (is_disabled_event(group, event)) {
log(ALL, LOG_INFO, "Disabled %s:%s tracing from config\n",
- group, event);
+ group, event);
return -EINVAL;
}
@@ -1043,7 +1044,6 @@ int handle_ras_events(int record_events)
if (!data)
goto err;
-
for (i = 0; i < cpus; i++) {
data[i].ras = ras;
data[i].cpu = i;
@@ -1058,14 +1058,14 @@ int handle_ras_events(int record_events)
}
log(SYSLOG, LOG_INFO,
- "Opening one thread per cpu (%d threads)\n", cpus);
+ "Opening one thread per cpu (%d threads)\n", cpus);
for (i = 0; i < cpus; i++) {
rc = pthread_create(&data[i].thread, NULL,
- handle_ras_events_cpu,
+ handle_ras_events_cpu,
(void *)&data[i]);
if (rc) {
log(SYSLOG, LOG_INFO,
- "Failed to create thread for cpu %d. Aborting.\n",
+ "Failed to create thread for cpu %d. Aborting.\n",
i);
while (--i)
pthread_cancel(data[i].thread);
diff --git a/ras-extlog-handler.c b/ras-extlog-handler.c
index 1834687..b40160a 100644
--- a/ras-extlog-handler.c
+++ b/ras-extlog-handler.c
@@ -139,7 +139,7 @@ static char *err_cper_data(const char *c)
p += sprintf(p, "card_handle: %d ", cpd->mem_array_handle);
if (cpd->validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
p += sprintf(p, "module_handle: %d ", cpd->mem_dev_handle);
- p += sprintf(p-1, ")");
+ p += sprintf(p - 1, ")");
return buf;
}
@@ -149,10 +149,10 @@ static char *uuid_le(const char *uu)
static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
char *p = uuid;
int i;
- static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+ static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
switch (i) {
case 3:
case 5:
@@ -168,14 +168,13 @@ static char *uuid_le(const char *uu)
return uuid;
}
-
static void report_extlog_mem_event(struct ras_events *ras,
struct pevent_record *record,
struct trace_seq *s,
struct ras_extlog_event *ev)
{
trace_seq_printf(s, "%d %s error: %s physical addr: 0x%llx mask: 0x%llx%s %s %s",
- ev->error_seq, err_severity(ev->severity),
+ ev->error_seq, err_severity(ev->severity),
err_type(ev->etype), ev->address,
err_mask(ev->pa_mask_lsb),
err_cper_data(ev->cper_data),
@@ -204,7 +203,7 @@ int ras_extlog_mem_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-mc-handler.c b/ras-mc-handler.c
index b62dfb6..7a4fa3c 100644
--- a/ras-mc-handler.c
+++ b/ras-mc-handler.c
@@ -134,7 +134,7 @@ int ras_mc_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
@@ -207,22 +207,22 @@ int ras_mc_event_handler(struct trace_seq *s,
if (pevent_get_field_val(s, event, "top_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.top_layer = (signed char) val;
+ ev.top_layer = (signed char)val;
if (pevent_get_field_val(s, event, "middle_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.middle_layer = (signed char) val;
+ ev.middle_layer = (signed char)val;
if (pevent_get_field_val(s, event, "lower_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.lower_layer = (signed char) val;
+ ev.lower_layer = (signed char)val;
if (ev.top_layer >= 0 || ev.middle_layer >= 0 || ev.lower_layer >= 0) {
if (ev.lower_layer >= 0)
trace_seq_printf(s, " location: %d:%d:%d",
- ev.top_layer, ev.middle_layer, ev.lower_layer);
+ ev.top_layer, ev.middle_layer, ev.lower_layer);
else if (ev.middle_layer >= 0)
trace_seq_printf(s, " location: %d:%d",
ev.top_layer, ev.middle_layer);
diff --git a/ras-mce-handler.c b/ras-mce-handler.c
index 370e68a..f55c732 100644
--- a/ras-mce-handler.c
+++ b/ras-mce-handler.c
@@ -114,11 +114,11 @@ static enum cputype select_intel_cputype(struct mce_priv *mce)
else if (mce->model == 0x6a)
return CPU_ICELAKE_XEON;
else if (mce->model == 0x6c)
- return CPU_ICELAKE_DE;
+ return CPU_ICELAKE_DE;
else if (mce->model == 0x86)
- return CPU_TREMONT_D;
+ return CPU_TREMONT_D;
else if (mce->model == 0x8f)
- return CPU_SAPPHIRERAPIDS;
+ return CPU_SAPPHIRERAPIDS;
else if (mce->model == 0xcf)
return CPU_EMERALDRAPIDS;
@@ -161,7 +161,7 @@ static int detect_cpu(struct mce_priv *mce)
mce->mhz = 0;
mce->vendor[0] = '\0';
- f = fopen("/proc/cpuinfo","r");
+ f = fopen("/proc/cpuinfo", "r");
if (!f) {
log(ALL, LOG_INFO, "Can't open /proc/cpuinfo\n");
return errno;
@@ -169,7 +169,7 @@ static int detect_cpu(struct mce_priv *mce)
while (seen != CPU_ALL && getdelim(&line, &linelen, '\n', f) > 0) {
if (sscanf(line, "vendor_id : %63[^\n]",
- (char *)&mce->vendor) == 1)
+ (char *)&mce->vendor) == 1)
seen |= CPU_VENDOR;
else if (sscanf(line, "cpu family : %d", &mce->family) == 1)
seen |= CPU_FAMILY;
@@ -189,7 +189,7 @@ static int detect_cpu(struct mce_priv *mce)
if (seen != CPU_ALL) {
log(ALL, LOG_INFO, "Can't parse /proc/cpuinfo: missing%s%s%s%s%s\n",
- (seen & CPU_VENDOR) ? "" : " [vendor_id]",
+ (seen & CPU_VENDOR) ? "" : " [vendor_id]",
(seen & CPU_FAMILY) ? "" : " [cpu family]",
(seen & CPU_MODEL) ? "" : " [model]",
(seen & CPU_MHZ) ? "" : " [cpu MHz]",
@@ -215,12 +215,12 @@ static int detect_cpu(struct mce_priv *mce)
ret = EINVAL;
}
goto ret;
- } else if (!strcmp(mce->vendor,"HygonGenuine")) {
+ } else if (!strcmp(mce->vendor, "HygonGenuine")) {
if (mce->family == 24) {
mce->cputype = CPU_DHYANA;
}
goto ret;
- } else if (!strcmp(mce->vendor,"GenuineIntel")) {
+ } else if (!strcmp(mce->vendor, "GenuineIntel")) {
mce->cputype = select_intel_cputype(mce);
} else {
ret = EINVAL;
@@ -233,7 +233,7 @@ ret:
return ret;
}
-int register_mce_handler(struct ras_events *ras, unsigned ncpus)
+int register_mce_handler(struct ras_events *ras, unsigned int ncpus)
{
int rc;
struct mce_priv *mce;
@@ -249,8 +249,8 @@ int register_mce_handler(struct ras_events *ras, unsigned ncpus)
rc = detect_cpu(mce);
if (rc) {
if (mce->processor_flags)
- free (mce->processor_flags);
- free (ras->mce_priv);
+ free(mce->processor_flags);
+ free(ras->mce_priv);
ras->mce_priv = NULL;
return (rc);
}
@@ -290,7 +290,7 @@ static void report_mce_event(struct ras_events *ras,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
@@ -459,7 +459,7 @@ int ras_offline_mce_event(struct ras_mc_offline_event *event)
mce->ipid = event->ipid;
if (!mce->ipid || !mce->status) {
log(TERM, LOG_ERR, "%s MSR required.\n",
- mce->ipid ? "Status" : "Ipid");
+ mce->ipid ? "Status" : "Ipid");
rc = -EINVAL;
goto free_mce;
}
diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
index d6e83a9..855c08c 100644
--- a/ras-memory-failure-handler.c
+++ b/ras-memory-failure-handler.c
@@ -167,7 +167,6 @@ static const char *get_action_result(int result)
return "unknown";
}
-
int ras_memory_failure_event_handler(struct trace_seq *s,
struct pevent_record *record,
struct event_format *event, void *context)
@@ -188,7 +187,7 @@ int ras_memory_failure_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c
index 3a4e300..968bd56 100644
--- a/ras-non-standard-handler.c
+++ b/ras-non-standard-handler.c
@@ -24,8 +24,9 @@
static struct ras_ns_ev_decoder *ras_ns_ev_dec_list;
-void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index) {
- trace_seq_printf(s, "%02x%02x%02x%02x", buf[index+3], buf[index+2], buf[index+1], buf[index]);
+void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index)
+{
+ trace_seq_printf(s, "%02x%02x%02x%02x", buf[index + 3], buf[index + 2], buf[index + 1], buf[index]);
}
static char *uuid_le(const char *uu)
@@ -33,10 +34,10 @@ static char *uuid_le(const char *uu)
static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
char *p = uuid;
int i;
- static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+ static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
switch (i) {
case 3:
case 5:
@@ -183,7 +184,7 @@ int ras_non_standard_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
diff --git a/ras-page-isolation.c b/ras-page-isolation.c
index caa8c31..89f8c15 100644
--- a/ras-page-isolation.c
+++ b/ras-page-isolation.c
@@ -116,7 +116,7 @@ static void parse_isolation_env(struct isolation *config)
int unit_matched = 0;
unsigned long value, tmp;
- /* check if env is vaild */
+ /* check if env is valid */
if (env && strlen(env)) {
/* All the character before unit must be digit */
for (i = 0; i < strlen(env) - 1; i++) {
@@ -125,7 +125,7 @@ static void parse_isolation_env(struct isolation *config)
}
if (sscanf(env, "%lu", &value) < 1 || !value)
goto parse;
- /* check if the unit is vaild */
+ /* check if the unit is valid */
unit = env + strlen(env) - 1;
/* no unit, all the character are value character */
if (isdigit(*unit)) {
@@ -151,7 +151,7 @@ parse:
config->unit = unit;
} else {
log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
- config->name, config->env);
+ config->name, config->env);
}
/* if env value string is greater than ulong_max, truncate the last digit */
@@ -177,10 +177,11 @@ static void parse_env_string(struct isolation *config, char *str, unsigned int s
if (config->overflow) {
/* when overflow, use basic unit */
- for (i = 0; config->units[i].name; i++) ;
- snprintf(str, size, "%lu%s", config->val, config->units[i-1].name);
+ for (i = 0; config->units[i].name; i++)
+ ;
+ snprintf(str, size, "%lu%s", config->val, config->units[i - 1].name);
log(TERM, LOG_INFO, "%s is set overflow(%s), truncate it\n",
- config->name, config->env);
+ config->name, config->env);
} else {
snprintf(str, size, "%s%s", config->env, config->unit);
}
@@ -202,7 +203,7 @@ static void page_isolation_init(void)
parse_env_string(&threshold, threshold_string, sizeof(threshold_string));
parse_env_string(&cycle, cycle_string, sizeof(cycle_string));
log(TERM, LOG_INFO, "Threshold of memory Corrected Errors is %s / %s\n",
- threshold_string, cycle_string);
+ threshold_string, cycle_string);
}
void ras_page_account_init(void)
@@ -239,7 +240,7 @@ static void page_offline(struct page_record *pr)
/* Offlining page is not required */
if (offline <= OFFLINE_ACCOUNT) {
log(TERM, LOG_INFO, "PAGE_CE_ACTION=%s, ignore to offline page at %#llx\n",
- offline_choice[offline].name, addr);
+ offline_choice[offline].name, addr);
return;
}
@@ -264,7 +265,7 @@ static void page_offline(struct page_record *pr)
addr, page_state[pr->offlined]);
}
-static void page_record(struct page_record *pr, unsigned count, time_t time)
+static void page_record(struct page_record *pr, unsigned int count, time_t time)
{
unsigned long period = time - pr->start;
unsigned long tolerate;
@@ -328,7 +329,7 @@ static struct page_record *page_lookup_insert(unsigned long long addr)
return find;
}
-void ras_record_page_error(unsigned long long addr, unsigned count, time_t time)
+void ras_record_page_error(unsigned long long addr, unsigned int count, time_t time)
{
struct page_record *pr = NULL;
diff --git a/ras-record.c b/ras-record.c
index adb00ca..0409099 100644
--- a/ras-record.c
+++ b/ras-record.c
@@ -42,20 +42,20 @@
*/
static const struct db_fields mc_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="err_count", .type="INTEGER" },
- { .name="err_type", .type="TEXT" },
- { .name="err_msg", .type="TEXT" },
- { .name="label", .type="TEXT" },
- { .name="mc", .type="INTEGER" },
- { .name="top_layer", .type="INTEGER" },
- { .name="middle_layer", .type="INTEGER" },
- { .name="lower_layer", .type="INTEGER" },
- { .name="address", .type="INTEGER" },
- { .name="grain", .type="INTEGER" },
- { .name="syndrome", .type="INTEGER" },
- { .name="driver_detail", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "err_count", .type = "INTEGER" },
+ { .name = "err_type", .type = "TEXT" },
+ { .name = "err_msg", .type = "TEXT" },
+ { .name = "label", .type = "TEXT" },
+ { .name = "mc", .type = "INTEGER" },
+ { .name = "top_layer", .type = "INTEGER" },
+ { .name = "middle_layer", .type = "INTEGER" },
+ { .name = "lower_layer", .type = "INTEGER" },
+ { .name = "address", .type = "INTEGER" },
+ { .name = "grain", .type = "INTEGER" },
+ { .name = "syndrome", .type = "INTEGER" },
+ { .name = "driver_detail", .type = "TEXT" },
};
static const struct db_table_descriptor mc_event_tab = {
@@ -82,9 +82,9 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
sqlite3_bind_int (priv->stmt_mc_event, 7, ev->top_layer);
sqlite3_bind_int (priv->stmt_mc_event, 8, ev->middle_layer);
sqlite3_bind_int (priv->stmt_mc_event, 9, ev->lower_layer);
- sqlite3_bind_int64 (priv->stmt_mc_event, 10, ev->address);
- sqlite3_bind_int64 (priv->stmt_mc_event, 11, ev->grain);
- sqlite3_bind_int64 (priv->stmt_mc_event, 12, ev->syndrome);
+ sqlite3_bind_int64(priv->stmt_mc_event, 10, ev->address);
+ sqlite3_bind_int64(priv->stmt_mc_event, 11, ev->grain);
+ sqlite3_bind_int64(priv->stmt_mc_event, 12, ev->syndrome);
sqlite3_bind_text(priv->stmt_mc_event, 13, ev->driver_detail, -1, NULL);
rc = sqlite3_step(priv->stmt_mc_event);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -106,11 +106,11 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
#ifdef HAVE_AER
static const struct db_fields aer_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="dev_name", .type="TEXT" },
- { .name="err_type", .type="TEXT" },
- { .name="err_msg", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "dev_name", .type = "TEXT" },
+ { .name = "err_type", .type = "TEXT" },
+ { .name = "err_msg", .type = "TEXT" },
};
static const struct db_table_descriptor aer_event_tab = {
@@ -154,13 +154,13 @@ int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
#ifdef HAVE_NON_STANDARD
static const struct db_fields non_standard_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="sec_type", .type="BLOB" },
- { .name="fru_id", .type="BLOB" },
- { .name="fru_text", .type="TEXT" },
- { .name="severity", .type="TEXT" },
- { .name="error", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "sec_type", .type = "BLOB" },
+ { .name = "fru_id", .type = "BLOB" },
+ { .name = "fru_text", .type = "TEXT" },
+ { .name = "severity", .type = "TEXT" },
+ { .name = "error", .type = "BLOB" },
};
static const struct db_table_descriptor non_standard_event_tab = {
@@ -178,12 +178,12 @@ int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standar
return 0;
log(TERM, LOG_INFO, "non_standard_event store: %p\n", priv->stmt_non_standard_record);
- sqlite3_bind_text (priv->stmt_non_standard_record, 1, ev->timestamp, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 2, ev->sec_type, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 3, ev->fru_id, 16, NULL);
- sqlite3_bind_text (priv->stmt_non_standard_record, 4, ev->fru_text, -1, NULL);
- sqlite3_bind_text (priv->stmt_non_standard_record, 5, ev->severity, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 6, ev->error, ev->length, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 2, ev->sec_type, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 3, ev->fru_id, 16, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 4, ev->fru_text, -1, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 5, ev->severity, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 6, ev->error, ev->length, NULL);
rc = sqlite3_step(priv->stmt_non_standard_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -205,16 +205,16 @@ int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standar
#ifdef HAVE_ARM
static const struct db_fields arm_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="error_count", .type="INTEGER" },
- { .name="affinity", .type="INTEGER" },
- { .name="mpidr", .type="INTEGER" },
- { .name="running_state", .type="INTEGER" },
- { .name="psci_state", .type="INTEGER" },
- { .name="err_info", .type="BLOB" },
- { .name="context_info", .type="BLOB" },
- { .name="vendor_info", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "error_count", .type = "INTEGER" },
+ { .name = "affinity", .type = "INTEGER" },
+ { .name = "mpidr", .type = "INTEGER" },
+ { .name = "running_state", .type = "INTEGER" },
+ { .name = "psci_state", .type = "INTEGER" },
+ { .name = "err_info", .type = "BLOB" },
+ { .name = "context_info", .type = "BLOB" },
+ { .name = "vendor_info", .type = "BLOB" },
};
static const struct db_table_descriptor arm_event_tab = {
@@ -232,18 +232,18 @@ int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev)
return 0;
log(TERM, LOG_INFO, "arm_event store: %p\n", priv->stmt_arm_record);
- sqlite3_bind_text (priv->stmt_arm_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_arm_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_arm_record, 2, ev->error_count);
sqlite3_bind_int (priv->stmt_arm_record, 3, ev->affinity);
- sqlite3_bind_int64 (priv->stmt_arm_record, 4, ev->mpidr);
+ sqlite3_bind_int64(priv->stmt_arm_record, 4, ev->mpidr);
sqlite3_bind_int (priv->stmt_arm_record, 5, ev->running_state);
sqlite3_bind_int (priv->stmt_arm_record, 6, ev->psci_state);
- sqlite3_bind_blob (priv->stmt_arm_record, 7,
- ev->pei_error, ev->pei_len, NULL);
- sqlite3_bind_blob (priv->stmt_arm_record, 8,
- ev->ctx_error, ev->ctx_len, NULL);
- sqlite3_bind_blob (priv->stmt_arm_record, 9,
- ev->vsei_error, ev->oem_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 7,
+ ev->pei_error, ev->pei_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 8,
+ ev->ctx_error, ev->ctx_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 9,
+ ev->vsei_error, ev->oem_len, NULL);
rc = sqlite3_step(priv->stmt_arm_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -262,15 +262,15 @@ int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev)
#ifdef HAVE_EXTLOG
static const struct db_fields extlog_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="etype", .type="INTEGER" },
- { .name="error_count", .type="INTEGER" },
- { .name="severity", .type="INTEGER" },
- { .name="address", .type="INTEGER" },
- { .name="fru_id", .type="BLOB" },
- { .name="fru_text", .type="TEXT" },
- { .name="cper_data", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "etype", .type = "INTEGER" },
+ { .name = "error_count", .type = "INTEGER" },
+ { .name = "severity", .type = "INTEGER" },
+ { .name = "address", .type = "INTEGER" },
+ { .name = "fru_id", .type = "BLOB" },
+ { .name = "fru_text", .type = "TEXT" },
+ { .name = "cper_data", .type = "BLOB" },
};
static const struct db_table_descriptor extlog_event_tab = {
@@ -288,14 +288,14 @@ int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event
return 0;
log(TERM, LOG_INFO, "extlog_record store: %p\n", priv->stmt_extlog_record);
- sqlite3_bind_text (priv->stmt_extlog_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_extlog_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_extlog_record, 2, ev->etype);
sqlite3_bind_int (priv->stmt_extlog_record, 3, ev->error_seq);
sqlite3_bind_int (priv->stmt_extlog_record, 4, ev->severity);
- sqlite3_bind_int64 (priv->stmt_extlog_record, 5, ev->address);
- sqlite3_bind_blob (priv->stmt_extlog_record, 6, ev->fru_id, 16, NULL);
- sqlite3_bind_text (priv->stmt_extlog_record, 7, ev->fru_text, -1, NULL);
- sqlite3_bind_blob (priv->stmt_extlog_record, 8, ev->cper_data, ev->cper_data_length, NULL);
+ sqlite3_bind_int64(priv->stmt_extlog_record, 5, ev->address);
+ sqlite3_bind_blob(priv->stmt_extlog_record, 6, ev->fru_id, 16, NULL);
+ sqlite3_bind_text(priv->stmt_extlog_record, 7, ev->fru_text, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_extlog_record, 8, ev->cper_data, ev->cper_data_length, NULL);
rc = sqlite3_step(priv->stmt_extlog_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
@@ -318,8 +318,8 @@ int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event
#ifdef HAVE_MCE
static const struct db_fields mce_record_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
/* MCE registers */
{ .name="mcgcap", .type="INTEGER" },
@@ -363,7 +363,7 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
return 0;
log(TERM, LOG_INFO, "mce_record store: %p\n", priv->stmt_mce_record);
- sqlite3_bind_text (priv->stmt_mce_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_mce_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_mce_record, 2, ev->mcgcap);
sqlite3_bind_int (priv->stmt_mce_record, 3, ev->mcgstatus);
sqlite3_bind_int64 (priv->stmt_mce_record, 4, ev->status);
@@ -409,13 +409,13 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
#ifdef HAVE_DEVLINK
static const struct db_fields devlink_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="bus_name", .type="TEXT" },
- { .name="dev_name", .type="TEXT" },
- { .name="driver_name", .type="TEXT" },
- { .name="reporter_name", .type="TEXT" },
- { .name="msg", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "bus_name", .type = "TEXT" },
+ { .name = "dev_name", .type = "TEXT" },
+ { .name = "driver_name", .type = "TEXT" },
+ { .name = "reporter_name", .type = "TEXT" },
+ { .name = "msg", .type = "TEXT" },
};
static const struct db_table_descriptor devlink_event_tab = {
@@ -461,14 +461,14 @@ int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev)
#ifdef HAVE_DISKERROR
static const struct db_fields diskerror_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="dev", .type="TEXT" },
- { .name="sector", .type="INTEGER" },
- { .name="nr_sector", .type="INTEGER" },
- { .name="error", .type="TEXT" },
- { .name="rwbs", .type="TEXT" },
- { .name="cmd", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "dev", .type = "TEXT" },
+ { .name = "sector", .type = "INTEGER" },
+ { .name = "nr_sector", .type = "INTEGER" },
+ { .name = "error", .type = "TEXT" },
+ { .name = "rwbs", .type = "TEXT" },
+ { .name = "cmd", .type = "TEXT" },
};
static const struct db_table_descriptor diskerror_event_tab = {
@@ -515,11 +515,11 @@ int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev
#ifdef HAVE_MEMORY_FAILURE
static const struct db_fields mf_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="pfn", .type="TEXT" },
- { .name="page_type", .type="TEXT" },
- { .name="action_result", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "pfn", .type = "TEXT" },
+ { .name = "page_type", .type = "TEXT" },
+ { .name = "action_result", .type = "TEXT" },
};
static const struct db_table_descriptor mf_event_tab = {
@@ -664,7 +664,7 @@ static int ras_mc_alter_table(struct sqlite3_priv *priv,
found = 0;
for (j = 0; j < col_count; j++) {
if (!strcmp(field->name,
- sqlite3_column_name(*stmt, j))) {
+ sqlite3_column_name(*stmt, j))) {
found = 1;
break;
}
@@ -755,13 +755,13 @@ int ras_mc_finalize_vendor_table(sqlite3_stmt *stmt)
return rc;
}
-int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
+int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras)
{
int rc;
sqlite3 *db;
struct sqlite3_priv *priv;
- printf("Calling %s()\n", __FUNCTION__);
+ printf("Calling %s()\n", __func__);
ras->db_ref_count++;
if (ras->db_ref_count > 1)
@@ -774,6 +774,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
return -1;
struct stat st = {0};
+
if (stat(RASSTATEDIR, &st) == -1) {
if (errno != ENOENT) {
log(TERM, LOG_ERR,
@@ -855,7 +856,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
rc = ras_mc_create_table(priv, &non_standard_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record,
- &non_standard_event_tab);
+ &non_standard_event_tab);
if (rc != SQLITE_OK)
goto error;
}
@@ -865,7 +866,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
rc = ras_mc_create_table(priv, &arm_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_arm_record,
- &arm_event_tab);
+ &arm_event_tab);
if (rc != SQLITE_OK)
goto error;
}
@@ -874,7 +875,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
rc = ras_mc_create_table(priv, &devlink_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_devlink_event,
- &devlink_event_tab);
+ &devlink_event_tab);
if (rc != SQLITE_OK)
goto error;
}
@@ -884,7 +885,7 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
rc = ras_mc_create_table(priv, &diskerror_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_diskerror_event,
- &diskerror_event_tab);
+ &diskerror_event_tab);
if (rc != SQLITE_OK)
goto error;
}
@@ -958,7 +959,6 @@ int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras)
}
#endif
-
#ifdef HAVE_MCE
if (priv->stmt_mce_record) {
rc = sqlite3_finalize(priv->stmt_mce_record);
diff --git a/ras-report.c b/ras-report.c
index 62d5eb7..6e3b351 100644
--- a/ras-report.c
+++ b/ras-report.c
@@ -21,13 +21,14 @@
#include "ras-report.h"
-static int setup_report_socket(void){
+static int setup_report_socket(void)
+{
int sockfd = -1;
int rc = -1;
struct sockaddr_un addr;
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
@@ -45,12 +46,13 @@ static int setup_report_socket(void){
return sockfd;
}
-static int commit_report_basic(int sockfd){
+static int commit_report_basic(int sockfd)
+{
char buf[INPUT_BUFFER_SIZE];
struct utsname un;
int rc = -1;
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
@@ -58,7 +60,7 @@ static int commit_report_basic(int sockfd){
memset(&un, 0, sizeof(struct utsname));
rc = uname(&un);
- if(rc < 0){
+ if (rc < 0) {
return rc;
}
@@ -67,35 +69,36 @@ static int commit_report_basic(int sockfd){
*/
sprintf(buf, "PUT / HTTP/1.1\r\n\r\n");
rc = write(sockfd, buf, strlen(buf));
- if(rc < strlen(buf)){
+ if (rc < strlen(buf)) {
return -1;
}
sprintf(buf, "PID=%d", (int)getpid());
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
sprintf(buf, "EXECUTABLE=/boot/vmlinuz-%s", un.release);
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
sprintf(buf, "TYPE=%s", "ras");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
return 0;
}
-static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
+static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -131,10 +134,11 @@ static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
return 0;
}
-static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
+static int set_mce_event_backtrace(char *buf, struct mce_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -190,10 +194,11 @@ static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
return 0;
}
-static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
+static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -211,10 +216,11 @@ static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
return 0;
}
-static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev){
+static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -230,10 +236,11 @@ static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_e
return 0;
}
-static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev){
+static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -257,10 +264,11 @@ static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev){
return 0;
}
-static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev){
+static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -282,10 +290,11 @@ static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev){
return 0;
}
-static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev) {
+static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
@@ -317,14 +326,14 @@ static int set_mf_event_backtrace(char *buf, struct ras_mf_event *ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "pfn=%s\n" \
- "page_type=%s\n" \
- "action_result=%s\n", \
- ev->timestamp, \
- ev->pfn, \
- ev->page_type, \
- ev->action_result);
+ "timestamp=%s\n" \
+ "pfn=%s\n" \
+ "page_type=%s\n" \
+ "action_result=%s\n", \
+ ev->timestamp, \
+ ev->pfn, \
+ ev->page_type, \
+ ev->action_result);
strcat(buf, bt_buf);
@@ -337,13 +346,13 @@ 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){
+ switch (type) {
case MC_EVENT:
rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
break;
@@ -372,15 +381,15 @@ static int commit_report_backtrace(int sockfd, int type, void *ev){
return -1;
}
- if(rc < 0){
+ if (rc < 0) {
return -1;
}
buf_len = strlen(buf);
- for(;buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)){
+ for (; buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)) {
rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
- if(rc < INPUT_BUFFER_SIZE - 1){
+ if (rc < INPUT_BUFFER_SIZE - 1) {
return -1;
}
@@ -388,14 +397,15 @@ static int commit_report_backtrace(int sockfd, int type, void *ev){
}
rc = write(sockfd, pbuf, buf_len + 1);
- if(rc < buf_len){
+ if (rc < buf_len) {
return -1;
}
return 0;
}
-int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
+int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = -1;
int done = 0;
@@ -404,29 +414,29 @@ int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto mc_fail;
}
rc = commit_report_backtrace(sockfd, MC_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto mc_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-mc");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mc_fail;
}
sprintf(buf, "REASON=%s", "EDAC driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mc_fail;
}
@@ -434,18 +444,19 @@ int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
mc_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
+int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
@@ -454,29 +465,29 @@ int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto aer_fail;
}
rc = commit_report_backtrace(sockfd, AER_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto aer_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-aer");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto aer_fail;
}
sprintf(buf, "REASON=%s", "PCIe AER driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto aer_fail;
}
@@ -484,18 +495,19 @@ int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
aer_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev){
+int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int rc = -1;
@@ -503,29 +515,29 @@ int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standar
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto non_standard_fail;
}
rc = commit_report_backtrace(sockfd, NON_STANDARD_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto non_standard_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-non-standard");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto non_standard_fail;
}
sprintf(buf, "REASON=%s", "Unknown CPER section problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto non_standard_fail;
}
@@ -533,14 +545,15 @@ int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standar
non_standard_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
return rc;
}
-int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
+int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int rc = -1;
@@ -548,29 +561,29 @@ int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto arm_fail;
}
rc = commit_report_backtrace(sockfd, ARM_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto arm_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-arm");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto arm_fail;
}
sprintf(buf, "REASON=%s", "ARM CPU report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto arm_fail;
}
@@ -578,14 +591,15 @@ int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
arm_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
return rc;
}
-int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
+int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
@@ -594,29 +608,29 @@ int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto mce_fail;
}
rc = commit_report_backtrace(sockfd, MCE_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto mce_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-mce");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mce_fail;
}
sprintf(buf, "REASON=%s", "Machine Check driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mce_fail;
}
@@ -624,18 +638,19 @@ int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
mce_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
+int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
@@ -644,29 +659,29 @@ int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto devlink_fail;
}
rc = commit_report_backtrace(sockfd, DEVLINK_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto devlink_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-devlink");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto devlink_fail;
}
sprintf(buf, "REASON=%s", "devlink health report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto devlink_fail;
}
@@ -674,18 +689,19 @@ int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
devlink_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev){
+int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
@@ -694,42 +710,42 @@ int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *e
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto diskerror_fail;
}
rc = commit_report_backtrace(sockfd, DISKERROR_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto diskerror_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-diskerror");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto diskerror_fail;
}
sprintf(buf, "REASON=%s", "disk I/O error");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto diskerror_fail;
}
done = 1;
diskerror_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
diff --git a/rasdaemon.c b/rasdaemon.c
index 0db51c9..7a3f964 100644
--- a/rasdaemon.c
+++ b/rasdaemon.c
@@ -34,7 +34,7 @@
#define TOOL_DESCRIPTION "RAS daemon to log the RAS events."
#define ARGS_DOC "<options>"
#define DISABLE "DISABLE"
-char *choices_disable = NULL;
+char *choices_disable;
const char *argp_program_version = TOOL_NAME " " VERSION;
const char *argp_program_bug_address = "Mauro Carvalho Chehab <[email protected]>";
@@ -129,6 +129,7 @@ int main(int argc, char *argv[])
{
struct arguments args;
int idx = -1;
+
choices_disable = getenv(DISABLE);
#ifdef HAVE_MCE
@@ -179,7 +180,7 @@ int main(int argc, char *argv[])
.children = offline_parser,
#endif
};
- memset (&args, 0, sizeof(args));
+ memset(&args, 0, sizeof(args));
user_hz = sysconf(_SC_CLK_TCK);
@@ -208,7 +209,7 @@ int main(int argc, char *argv[])
openlog(TOOL_NAME, 0, LOG_DAEMON);
if (!args.foreground)
- if (daemon(0,0))
+ if (daemon(0, 0))
exit(EXIT_FAILURE);
handle_ras_events(args.record_events);
diff --git a/rbtree.c b/rbtree.c
index d9b1bd4..43da434 100644
--- a/rbtree.c
+++ b/rbtree.c
@@ -28,7 +28,8 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
struct rb_node *right = node->rb_right;
struct rb_node *parent = rb_parent(node);
- if ((node->rb_right = right->rb_left))
+ node->rb_right = right->rb_left;
+ if (node->rb_right)
rb_set_parent(right->rb_left, node);
right->rb_left = node;
@@ -40,8 +41,7 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
parent->rb_left = right;
else
parent->rb_right = right;
- }
- else
+ } else
root->rb_node = right;
rb_set_parent(node, right);
}
@@ -51,7 +51,8 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
struct rb_node *left = node->rb_left;
struct rb_node *parent = rb_parent(node);
- if ((node->rb_left = left->rb_right))
+ node->rb_left = left->rb_right;
+ if (node->rb_left)
rb_set_parent(left->rb_right, node);
left->rb_right = node;
@@ -63,8 +64,7 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
parent->rb_right = left;
else
parent->rb_left = left;
- }
- else
+ } else
root->rb_node = left;
rb_set_parent(node, left);
}
@@ -81,6 +81,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
{
{
register struct rb_node *uncle = gparent->rb_right;
+
if (uncle && rb_is_red(uncle))
{
rb_set_black(uncle);
@@ -94,6 +95,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
if (parent->rb_right == node)
{
struct rb_node *tmp;
+
__rb_rotate_left(parent, root);
tmp = parent;
parent = node;
@@ -106,6 +108,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
} else {
{
struct rb_node *uncle = gparent->rb_left;
+
if (uncle && rb_is_red(uncle))
{
rb_set_black(uncle);
@@ -119,6 +122,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
if (parent->rb_left == node)
{
struct rb_node *tmp;
+
__rb_rotate_right(parent, root);
tmp = parent;
parent = node;
@@ -157,8 +161,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- }
- else
+ } else
{
if (!other->rb_right || rb_is_black(other->rb_right))
{
@@ -174,8 +177,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
node = root->rb_node;
break;
}
- }
- else
+ } else
{
other = parent->rb_left;
if (rb_is_red(other))
@@ -191,8 +193,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- }
- else
+ } else
{
if (!other->rb_left || rb_is_black(other->rb_left))
{
@@ -272,8 +273,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
parent->rb_left = child;
else
parent->rb_right = child;
- }
- else
+ } else
root->rb_node = child;
color:
@@ -320,7 +320,7 @@ struct rb_node *rb_next(const struct rb_node *node)
if (node->rb_right) {
node = node->rb_right;
while (node->rb_left)
- node=node->rb_left;
+ node = node->rb_left;
return (struct rb_node *)node;
}
@@ -348,7 +348,7 @@ struct rb_node *rb_prev(const struct rb_node *node)
if (node->rb_left) {
node = node->rb_left;
while (node->rb_right)
- node=node->rb_right;
+ node = node->rb_right;
return (struct rb_node *)node;
}
--
2.33.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/rasdaemon.git
[email protected]:src-anolis-os/rasdaemon.git
src-anolis-os
rasdaemon
rasdaemon
a8

搜索帮助