slb

Sleep on Low Battery
Log | Files | Refs | README | LICENSE

commit 18f511184363c92af53295d52f66d79b6c8a016d
parent 4efecc56974abee5f515293089d04393e01ae051
Author: zerous Naveen Narayanan <zerous@nocebo.space>
Date:   Wed, 30 Oct 2019 19:14:25 +0100

Use sizeof instead of hardcoding values

Thanks Evil_Bob

Diffstat:
Mslb.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/slb.c b/slb.c @@ -20,7 +20,7 @@ pwread(const char *bat) err(1, "open failed"); } - if ((t = read(fd,buf,3)) == -1) { + if ((t = read(fd,buf,sizeof(buf))) == -1) { err(1, "read failed"); } @@ -43,7 +43,7 @@ main(int argc, char **argv) for (;;) { tpow = 0; - for (int i = 0; i < sizeof(bat)/64; i++) { + for (int i = 0; i < sizeof(bat)/sizeof(*bat); i++) { tpow += pwread(bat[i]); }