diff --git a/src/core.c b/src/core.c index ac9656cd..b36cf88b 100644 --- a/src/core.c +++ b/src/core.c @@ -1375,7 +1375,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(entropy_avail, &update_entropy) obj->callbacks.print = &print_entropy_avail; END OBJ(entropy_perc, &update_entropy) - obj->callbacks.print = &print_entropy_perc; + obj->callbacks.percentage = &entropy_percentage; END OBJ(entropy_poolsize, &update_entropy) obj->callbacks.print = &print_entropy_poolsize; END OBJ(entropy_bar, &update_entropy) diff --git a/src/entropy.c b/src/entropy.c index b1f5fe85..1de29604 100644 --- a/src/entropy.c +++ b/src/entropy.c @@ -61,11 +61,10 @@ void print_entropy_avail(struct text_object *obj, char *p, int p_max_size) snprintf(p, p_max_size, "%u", entropy.avail); } -void print_entropy_perc(struct text_object *obj, char *p, int p_max_size) +uint8_t entropy_percentage(struct text_object *obj) { (void)obj; - percent_print(p, p_max_size, entropy.avail * - 100 / entropy.poolsize); + return round_to_int((double)entropy.avail * 100.0 / (double)entropy.poolsize); } void print_entropy_poolsize(struct text_object *obj, char *p, int p_max_size) diff --git a/src/entropy.h b/src/entropy.h index d93d472e..8b998d0f 100644 --- a/src/entropy.h +++ b/src/entropy.h @@ -34,7 +34,7 @@ void update_entropy(void); void print_entropy_avail(struct text_object *, char *, int); -void print_entropy_perc(struct text_object *, char *, int); +uint8_t entropy_percentage(struct text_object *); void print_entropy_poolsize(struct text_object *, char *, int); uint8_t entropy_barval(struct text_object *);