From 03c5c6a639cb408c15f633d1106719a5253bbb12 Mon Sep 17 00:00:00 2001 From: Francois Isabelle Date: Wed, 13 Aug 2008 19:31:35 +0000 Subject: [PATCH] Whenever 'total space' if >= 65535, the percentage can't be safely determined. So avoid printing it --- ipmitool/lib/ipmi_sel.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ipmitool/lib/ipmi_sel.c b/ipmitool/lib/ipmi_sel.c index fa081d5..d262d5b 100644 --- a/ipmitool/lib/ipmi_sel.c +++ b/ipmitool/lib/ipmi_sel.c @@ -666,7 +666,8 @@ ipmi_sel_get_info(struct ipmi_intf * intf) { struct ipmi_rs * rsp; struct ipmi_rq req; - uint16_t e, f, version; + uint16_t e, version; + uint32_t f; int pctfull = 0; uint32_t fs = 0xffffffff; uint32_t zeros = 0; @@ -699,13 +700,20 @@ ipmi_sel_get_info(struct ipmi_intf * intf) e = buf2short(rsp->data + 1); f = buf2short(rsp->data + 3); printf("Entries : %d\n", e); - printf("Free Space : %d bytes\n", f); + printf("Free Space : %d bytes %s\n", f ,(f==65535 ? "or more" : "" )); + if (e) { - e *= 16; - f += e; + e *= 16; /* each entry takes 16 bytes */ + f += e; /* this is supposed to give the total size ... */ pctfull = (int)(100 * ( (double)e / (double)f )); } - printf("Percent Used : %d%%\n", pctfull); + + if( f >= 65535 ) { + printf("Percent Used : %s\n", "unknown" ); + } + else { + printf("Percent Used : %d%%\n", pctfull); + } if ((!memcmp(rsp->data + 5, &fs, 4)) ||