Skip to content
Permalink
Browse files

Update -nc console flag output. Fixes #787

Found by: mortmann
Patch by: Geo
Fixes: #787

* Dividing by zero is bad, mmmkay (if the total cache float rounded to 0, a not-a-number error was generated when dividing by the total cache)
* Don't wait 10 seconds to show -nc status
  • Loading branch information...
vanosg committed Jun 26, 2019
1 parent 103128c commit c763e7e798f859893d7f9e9eb0f7d53e032b4595
Showing with 7 additions and 5 deletions.
  1. +6 −4 src/chanprog.c
  2. +1 −1 src/main.c
@@ -290,7 +290,7 @@ void tell_verbose_status(int idx)
char *vers_t, *uni_t;
int i;
time_t now2 = now - online_since, hr, min;
float cputime;
double cputime, cache_total;
#ifdef HAVE_UNAME
struct utsname un;

@@ -342,9 +342,11 @@ void tell_verbose_status(int idx)
cputime -= hr * 60;
sprintf(s2, "CPU: %02d:%05.2f", (int) hr, cputime); /* Actually min/sec */
}
dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR,
s, s1, s2, MISC_CACHEHIT,
100.0 * ((float) cache_hit) / ((float) (cache_hit + cache_miss)));
if (cache_hit + cache_miss) { /* 2019, still can't divide by zero */
cache_total = 100.0 * (cache_hit) / (cache_hit + cache_miss);
} else cache_total = 0;
dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR,
s, s1, s2, MISC_CACHEHIT, cache_total);

dprintf(idx, "Configured with: " EGG_AC_ARGS "\n");
if (admin[0])
@@ -634,7 +634,7 @@ static struct tm nowtm;
*/
static void core_secondly()
{
static int cnt = 0;
static int cnt = 10; /* Don't wait the first 10 seconds to display */
int miltime;
time_t nowmins;
int i;

0 comments on commit c763e7e

Please sign in to comment.
You can’t perform that action at this time.