From 4787c26b359ffd9388b5ca94722dcbf95ca49b5c Mon Sep 17 00:00:00 2001 From: Roland Jax Date: Wed, 5 Feb 2014 13:23:40 +0100 Subject: [PATCH] Added CFLAGS -Wall -Wextra to configure.ac Fixed some compiler warnings related to changed CFLAGS settings. --- configure.ac | 3 +++ lib/ebus-cmd.c | 6 +++--- lib/ebus-decode.c | 18 +++++++++--------- src/utils.c | 2 +- tools/check.c | 2 +- tools/ebus_send.c | 4 ++-- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 5bcbe121..42b6bbfc 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,9 @@ AM_INIT_AUTOMAKE AC_PROG_CC AM_PROG_CC_C_O +# Compiler flags +CFLAGS="$CFLAGS -Wall -Wextra" + # Checks for libraries. AC_PROG_RANLIB diff --git a/lib/ebus-cmd.c b/lib/ebus-cmd.c index 20dcd61e..ed387322 100644 --- a/lib/ebus-cmd.c +++ b/lib/ebus-cmd.c @@ -518,7 +518,7 @@ eb_cmd_encode_value(int id, int elem, char *data, unsigned char *msg, char *buf) id, elem, p1, p2, p3, data); if (strncasecmp(com[id].elem[elem].d_type, "str", 3) == 0) { - for (i = 0; i < strlen(data); i++) + for (i = 0; i < (int) strlen(data); i++) sprintf((char *) &msg[i * 2], "%02x", data[i]); } else if (strncasecmp(com[id].elem[elem].d_type, "bcd", 3) == 0) { @@ -702,7 +702,7 @@ eb_cmd_prepare(int id, char *data, unsigned char *msg, int *msglen, char *buf) while (str[j] != '\0') { byte = str[j]; - if (i < sizeof(in)) { + if (i < (int) sizeof(in)) { ret = eb_htoi(&byte); if (ret != -1) { @@ -975,7 +975,7 @@ eb_cmd_dir_read(const char *cfgdir, const char *extension) while (i < files) { ext = strrchr(dir[i]->d_name, '.'); if (ext != NULL) { - if (strlen(ext) == extlen + if ((int) strlen(ext) == extlen && dir[i]->d_type == DT_REG && strncasecmp(ext, extprep, extlen) == 0 ) { memset(file, '\0', sizeof(file)); diff --git a/lib/ebus-decode.c b/lib/ebus-decode.c index f7d1a918..921877e6 100644 --- a/lib/ebus-decode.c +++ b/lib/ebus-decode.c @@ -144,9 +144,9 @@ int eb_day_to_str(unsigned char day, char *tgt) { int dd; - - if (dd >= 0x00 && dd <= 0x06) { - eb_bcd_to_int(day, &day); + + if ((day & 0x0F) >= 0x00 && (day & 0x0F) <= 0x06) { + eb_bcd_to_int(day, &dd); sprintf(tgt, "%s", days[dd]); } else { return -1; @@ -160,9 +160,9 @@ eb_day_to_str(unsigned char day, char *tgt) int eb_dat_to_str(unsigned char dd, unsigned char mm, unsigned char yy, char *tgt) { - if (dd >= 0x00 && dd <= 0x1F && - mm >= 0x00 && mm <= 0x0C && - yy >= 0x00 && yy <= 0x63 ) + if ((dd & 0x7F) >= 0x00 && (dd & 0x7F) <= 0x1F && + (mm & 0x7F) >= 0x00 && (mm & 0x7F) <= 0x0C && + (yy & 0x7F) >= 0x00 && (yy & 0x7F) <= 0x63 ) sprintf(tgt, "%02d.%02d.%04d", dd, mm, yy + 2000); else return -1; @@ -192,9 +192,9 @@ eb_str_to_dat(int dd, int mm, int yy, unsigned char *tgt) int eb_tim_to_str(unsigned char hh, unsigned char mm, unsigned char ss, char *tgt) { - if (hh >= 0x00 && hh <= 0x17 && - mm >= 0x00 && mm <= 0x3B && - ss >= 0x00 && ss <= 0x3B ) + if ((hh & 0x7F) >= 0x00 && (hh & 0x7F) <= 0x17 && + (mm & 0x7F) >= 0x00 && (mm & 0x7F) <= 0x3B && + (ss & 0x7F) >= 0x00 && (ss & 0x7F) <= 0x3B ) sprintf(tgt, "%02d:%02d:%02d", hh, mm, ss); else return -1; diff --git a/src/utils.c b/src/utils.c index 07cf9979..4de56e16 100644 --- a/src/utils.c +++ b/src/utils.c @@ -317,7 +317,7 @@ sock_open(int *fd, int port, int localhost) struct sockaddr_in sock; *fd = socket(PF_INET, SOCK_STREAM, 0); - err_ret_if(fd < 0, -1); + err_ret_if(*fd < 0, -1); /* todo: verify if this realy work */ /* prevent "Error Address already in use" error message */ diff --git a/tools/check.c b/tools/check.c index 9187cb39..0cecf876 100644 --- a/tools/check.c +++ b/tools/check.c @@ -53,7 +53,7 @@ int main() { break; } - if (i < sizeof(data)) { + if (i < (int) sizeof(data)) { ret = eb_htoi(&byte); if (ret != -1) { data[i] = ret; diff --git a/tools/ebus_send.c b/tools/ebus_send.c index 1bcab4b2..27e02b12 100644 --- a/tools/ebus_send.c +++ b/tools/ebus_send.c @@ -180,7 +180,7 @@ main(int argc, char *argv[]) break; } - if (i < sizeof(in)) { + if (i < (int) sizeof(in)) { ret = eb_htoi(&byte); if (ret != -1) { @@ -231,7 +231,7 @@ main(int argc, char *argv[]) j = 0; while (argv[k][j] != '\0') { byte = argv[k][j]; - if (i < sizeof(in)) { + if (i < (int) sizeof(in)) { ret = eb_htoi(&byte); if (ret != -1) {