From 754010fba962a7fe859e7f2efb977ec4eff04920 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 16 Apr 2020 19:18:20 +0200 Subject: Better read function --- src/jo_lowbat.h | 5 ++++- src/jo_main.c | 8 +++----- src/jo_main.h | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/jo_lowbat.h b/src/jo_lowbat.h index ddc6679..b39243e 100644 --- a/src/jo_lowbat.h +++ b/src/jo_lowbat.h @@ -13,11 +13,14 @@ #ifndef JO_LOWBAT_H #define JO_LOWBAT_H +#include + enum { JO_RET_FINE, JO_RET_RD_FAILED }; -char *jo_f_status(void); + +int8_t jo_f_status(void); #endif diff --git a/src/jo_main.c b/src/jo_main.c index 2d19ab8..e5576b3 100644 --- a/src/jo_main.c +++ b/src/jo_main.c @@ -21,13 +21,11 @@ int main(void) { - char *status; + int8_t status; - if (!(status = jo_f_status())) { + if ((status = jo_f_status()) < 0) { return (JO_RET_RD_FAILED); } - printf("status: %s\n", status); - free(status); - status = NULL; + printf("status: %d\n", status); return (JO_RET_FINE); } diff --git a/src/jo_main.h b/src/jo_main.h index 8feabe9..742f1d9 100644 --- a/src/jo_main.h +++ b/src/jo_main.h @@ -17,5 +17,6 @@ #include #include #include +#include #endif -- cgit v1.2.3