From bac417418daa781af73d3574bc4d8967b0374e8e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 23 May 2013 14:26:07 -0300 Subject: [PATCH] Cleanup warnings at ras-aer-handler.c Signed-off-by: Mauro Carvalho Chehab --- Makefile.am | 5 +++-- bitfield.c | 37 ++++++++++++++++++++++++++++++++----- bitfield.h | 11 +++++++++++ ras-aer-handler.c | 1 + ras-mce-handler.c | 31 ------------------------------- ras-mce-handler.h | 6 ------ 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/Makefile.am b/Makefile.am index e6fd1b1..bc6059b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,8 @@ SUBDIRS = libtrace util man EXTRA_DIST = misc/rasdaemon.service misc/ras-mc-ctl.service sbin_PROGRAMS = rasdaemon -rasdaemon_SOURCES = rasdaemon.c ras-events.c ras-mc-handler.c +rasdaemon_SOURCES = rasdaemon.c ras-events.c ras-mc-handler.c \ + bitfield.c if WITH_SQLITE3 rasdaemon_SOURCES += ras-record.c endif @@ -12,7 +13,7 @@ if WITH_AER endif if WITH_MCE rasdaemon_SOURCES += ras-mce-handler.c mce-intel.c mce-amd-k8.c \ - bitfield.c mce-intel-p4-p6.c mce-intel-nehalem.c \ + mce-intel-p4-p6.c mce-intel-nehalem.c \ mce-intel-dunnington.c mce-intel-tulsa.c \ mce-intel-sb.c mce-intel-ivb.c endif diff --git a/bitfield.c b/bitfield.c index 4085df3..b2895b4 100644 --- a/bitfield.c +++ b/bitfield.c @@ -25,9 +25,37 @@ #include "ras-mce-handler.h" #include "bitfield.h" -char *reserved_3bits[8]; -char *reserved_1bit[2]; -char *reserved_2bits[4]; +unsigned bitfield_msg(char *buf, size_t len, const char **bitarray, + unsigned array_len, + unsigned bit_offset, unsigned ignore_bits, + uint64_t status) +{ + int i, n; + char *p = buf; + + len--; + + for (i = 0; i < array_len; i++) { + if (status & ignore_bits) + continue; + if (status & (1 << (i + bit_offset))) { + if (p != buf) { + n = snprintf(p, len, ", "); + len -= n; + p += n; + } + if (!bitarray[i]) + n = snprintf(p, len, "BIT%d", i + bit_offset); + else + n = snprintf(p, len, "%s", bitarray[i]); + len -= n; + p += n; + } + } + + *p = 0; + return p - buf; +} static uint64_t bitmask(uint64_t i) { @@ -41,7 +69,6 @@ void decode_bitfield(struct mce_event *e, uint64_t status, struct field *fields) { struct field *f; - char buf[60]; for (f = fields; f->str; f++) { uint64_t v = (status >> f->start_bit) & bitmask(f->stringlen - 1); @@ -52,7 +79,7 @@ void decode_bitfield(struct mce_event *e, uint64_t status, if (v == 0) continue; mce_snprintf(e->error_msg, "<%u:%llx>", - f->start_bit, v); + f->start_bit, (long long)v); } } } diff --git a/bitfield.h b/bitfield.h index 05392d4..c7dfeb1 100644 --- a/bitfield.h +++ b/bitfield.h @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + /* Generic bitfield decoder */ struct field { @@ -40,6 +42,8 @@ struct numfield { #define HEXNUMBER(start, end, name) { start, end, name, "%Lx", 0 } #define HEXNUMBERFORCE(start, end, name) { start, end, name, "%Lx", 1 } +struct mce_event; + void decode_bitfield(struct mce_event *e, uint64_t status, struct field *fields); void decode_numfield(struct mce_event *e, uint64_t status, @@ -52,3 +56,10 @@ static inline int test_prefix(int nr, uint32_t value) { return ((value >> nr) == 1); } + +/* Ancillary routines */ + +unsigned bitfield_msg(char *buf, size_t len, const char **bitarray, + unsigned array_len, + unsigned bit_offset, unsigned ignore_bits, + uint64_t status); diff --git a/ras-aer-handler.c b/ras-aer-handler.c index 6f13fbf..ec63e2a 100644 --- a/ras-aer-handler.c +++ b/ras-aer-handler.c @@ -23,6 +23,7 @@ #include "ras-aer-handler.h" #include "ras-record.h" #include "ras-logger.h" +#include "bitfield.h" static const char *aer_errors[32] = { /* Correctable errors */ diff --git a/ras-mce-handler.c b/ras-mce-handler.c index c1e88a6..6014753 100644 --- a/ras-mce-handler.c +++ b/ras-mce-handler.c @@ -203,37 +203,6 @@ int register_mce_handler(struct ras_events *ras) * End of mcelog's code */ -unsigned bitfield_msg(char *buf, size_t len, char **bitarray, unsigned array_len, - unsigned bit_offset, unsigned ignore_bits, - uint64_t status) -{ - int i, n; - char *p = buf; - - len--; - - for (i = 0; i < array_len; i++) { - if (status & ignore_bits) - continue; - if (status & (1 << (i + bit_offset))) { - if (p != buf) { - n = snprintf(p, len, ", "); - len -= n; - p += n; - } - if (!bitarray[i]) - n = snprintf(p, len, "BIT%d", i + bit_offset); - else - n = snprintf(p, len, "%s", bitarray[i]); - len -= n; - p += n; - } - } - - *p = 0; - return p - buf; -} - static void report_mce_event(struct ras_events *ras, struct pevent_record *record, struct trace_seq *s, struct mce_event *e) diff --git a/ras-mce-handler.h b/ras-mce-handler.h index 7a7fd45..dc28f09 100644 --- a/ras-mce-handler.h +++ b/ras-mce-handler.h @@ -102,12 +102,6 @@ int ras_mce_event_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context); -/* Ancillary routines */ - -unsigned bitfield_msg(char *buf, size_t len, char **bitarray, unsigned array_len, - unsigned bit_offset, unsigned ignore_bits, - uint64_t status); - /* Per-CPU-type decoders for Intel CPUs */ void p4_decode_model(struct mce_event *e); void core2_decode_model(struct mce_event *e); -- 2.50.1