X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/67617ebf00d594ee3c932b6c8e1850265f28adee..8eef03acb9747a40aaf92175c49e43397b872404:/latester/histogram.h diff --git a/latester/histogram.h b/latester/histogram.h index 4a9aade..80d629e 100644 --- a/latester/histogram.h +++ b/latester/histogram.h @@ -23,8 +23,9 @@ int histogram_init(struct histogram *h, return -1; } -void histogram_add(struct histogram *h, unsigned value) +void histogram_add(struct histogram *h, int value) { + if (value < 0) value = 0; unsigned index = value / h->resolution; if (index >= h->allocated) index = h->allocated - 1; @@ -35,6 +36,10 @@ void histogram_fprint(struct histogram *h, FILE *f) { unsigned long long sum = 0, cum; unsigned i; + + if (!f) + return; + for (i = 0; i < h->allocated; i++) sum += h->data[i]; cum = sum;