all warnings as errors

This commit is contained in:
Wolfgang Hottgenroth 2020-11-20 11:23:44 +01:00
parent ada748edbb
commit 5ba461adf6
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
11 changed files with 52 additions and 47 deletions

1
.gitmodules vendored
View File

@ -8,6 +8,7 @@
[submodule "cube/libmbus"] [submodule "cube/libmbus"]
path = cube/libmbus path = cube/libmbus
url = ../libmbus url = ../libmbus
branch = WolfgangsOwnBranch
[submodule "cube/pubsub"] [submodule "cube/pubsub"]
path = cube/pubsub path = cube/pubsub
url = ../Pubsubclient url = ../Pubsubclient

View File

@ -135,9 +135,9 @@ C_INCLUDES = \
# compile gcc flags # compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2 CFLAGS += -g -gdwarf-2

View File

@ -7,8 +7,8 @@
#include <stdbool.h> #include <stdbool.h>
typedef struct { typedef struct {
char *name; const char *name;
char *unit; const char *unit;
int8_t exponent; int8_t exponent;
bool found; bool found;
} parsedVIB_t; } parsedVIB_t;

View File

@ -3,8 +3,8 @@
void mqttCommInit(); void mqttCommInit();
void mqttPublish(char *topic, char *message); void mqttPublish(const char *topic, char *message);
void mqttPublishf(char *topic, char *messageFormat, ...); void mqttPublishf(const char *topic, char *messageFormat, ...);

View File

@ -55,11 +55,11 @@ bool globalStatsCmd(uint8_t argc, char **args) {
char buf[256]; char buf[256];
sprintf(buf, \ sprintf(buf, \
"Global statistics\n\r" \ "Global statistics\n\r" \
" Requests: %d\n\r" \ " Requests: %ld\n\r" \
" Errors: %d\n\r", " Errors: %ld\n\r",
stats->requestCnt, stats->errorCnt stats->requestCnt, stats->errorCnt
); );
send(CMD_SOCK, buf, strlen(buf)); send(CMD_SOCK, (uint8_t*)buf, strlen(buf));
return true; return true;
} }
@ -133,7 +133,7 @@ const static cmd_t COMMANDS[] = {
// returns 1 to toggle to config mode // returns 1 to toggle to config mode
// returns 2 to toggle back to default mode // returns 2 to toggle back to default mode
int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) { int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
const static uint8_t HELP_MSG[] = \ const static char HELP_MSG[] = \
"Usage\n\r" \ "Usage\n\r" \
"\n\r" \ "\n\r" \
"help ................................. Show this help page\n\r" \ "help ................................. Show this help page\n\r" \
@ -141,10 +141,10 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
"enable ............................... Enable configuration mode\n\r" \ "enable ............................... Enable configuration mode\n\r" \
"disable .............................. Disable configuration mode\n\r" \ "disable .............................. Disable configuration mode\n\r" \
; ;
const static uint8_t GOODBYE_MSG[] = "Good bye\n\r"; const static char GOODBYE_MSG[] = "Good bye\n\r";
const static uint8_t OK_MSG[] = "OK\n\r"; const static char OK_MSG[] = "OK\n\r";
const static uint8_t FAILED_MSG[] = "Failed\n\r"; const static char FAILED_MSG[] = "Failed\n\r";
const static uint8_t REQUIRES_CONFIG_MODE_MGS[] = "Not executed, requires config mode\n\r"; const static char REQUIRES_CONFIG_MODE_MGS[] = "Not executed, requires config mode\n\r";
uint8_t *messageToSend = NULL; uint8_t *messageToSend = NULL;
static bool configMode = false; static bool configMode = false;
@ -158,7 +158,7 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
#define MAX_NUM_OF_ARGS 8 #define MAX_NUM_OF_ARGS 8
char *args[MAX_NUM_OF_TASKS]; char *args[MAX_NUM_OF_TASKS];
uint8_t argc = 0; uint8_t argc = 0;
char *inCmdLine = cmdLine; char *inCmdLine = (char*)cmdLine;
do { do {
args[argc++] = strtok(inCmdLine, " "); args[argc++] = strtok(inCmdLine, " ");
inCmdLine = NULL; inCmdLine = NULL;
@ -172,17 +172,17 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
coloredMsg(LOG_YELLOW, false, "ch cec cmd is %s, number of arguments %d", cmd, argc); coloredMsg(LOG_YELLOW, false, "ch cec cmd is %s, number of arguments %d", cmd, argc);
if (0 == strcmp(cmd, "quit")) { if (0 == strcmp(cmd, "quit")) {
messageToSend = GOODBYE_MSG; messageToSend = (uint8_t*)GOODBYE_MSG;
retCode = -1; retCode = -1;
} else if (0 == strcmp(cmd, "help")) { } else if (0 == strcmp(cmd, "help")) {
send(CMD_SOCK, HELP_MSG, strlen(HELP_MSG)); send(CMD_SOCK, (uint8_t*)HELP_MSG, strlen(HELP_MSG));
uint8_t cmdIdx = 0; uint8_t cmdIdx = 0;
while (true) { while (true) {
cmd_t command = COMMANDS[cmdIdx]; cmd_t command = COMMANDS[cmdIdx];
if (0 == strcmp("END_OF_CMDS", command.name)) { if (0 == strcmp("END_OF_CMDS", command.name)) {
break; break;
} }
send(CMD_SOCK, command.help, strlen(command.help)); send(CMD_SOCK, (uint8_t*)command.help, strlen(command.help));
cmdIdx++; cmdIdx++;
} }
messageToSend = NULL; messageToSend = NULL;
@ -203,9 +203,9 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
} }
if (0 == strcmp(cmd, command.name)) { if (0 == strcmp(cmd, command.name)) {
if (command.requiredConfigMode && !configMode) { if (command.requiredConfigMode && !configMode) {
messageToSend = REQUIRES_CONFIG_MODE_MGS; messageToSend = (uint8_t*)REQUIRES_CONFIG_MODE_MGS;
} else { } else {
messageToSend = command.cmdFunc(argc, args) ? OK_MSG : FAILED_MSG; messageToSend = command.cmdFunc(argc, args) ? (uint8_t*)OK_MSG : (uint8_t*)FAILED_MSG;
} }
} }
cmdIdx++; cmdIdx++;
@ -213,7 +213,7 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
} }
if (messageToSend) { if (messageToSend) {
send(CMD_SOCK, messageToSend, strlen(messageToSend)); send(CMD_SOCK, messageToSend, strlen((char*)messageToSend));
} }
return retCode; return retCode;
@ -225,14 +225,14 @@ void cmdHandlerEngine(void *handle) {
static chState_t state = CH_INIT; static chState_t state = CH_INIT;
static bool resetConfigMode = false; static bool resetConfigMode = false;
static uint8_t banner[] = \ static char banner[] = \
"MBGW3\n\r" \ "MBGW3\n\r" \
"Type help for usage help\n\r" \ "Type help for usage help\n\r" \
"or quit to close the connection.\n\r"; "or quit to close the connection.\n\r";
static uint8_t *prompt; static char *prompt;
static uint8_t defaultPrompt[] = "MBGW3 # "; static char defaultPrompt[] = "MBGW3 # ";
static uint8_t elevatedPrompt[] = "MBGW3 (admin) > "; static char elevatedPrompt[] = "MBGW3 (admin) > ";
int8_t res = 0; int8_t res = 0;
@ -292,7 +292,7 @@ void cmdHandlerEngine(void *handle) {
coloredMsg(LOG_YELLOW, true, "ch che sockState is 0x%02x when trying to send banner", sockState); coloredMsg(LOG_YELLOW, true, "ch che sockState is 0x%02x when trying to send banner", sockState);
state = CH_DISCONNECT; state = CH_DISCONNECT;
} else { } else {
resultSend = send(CMD_SOCK, banner, strlen(banner)); resultSend = send(CMD_SOCK, (uint8_t*)banner, strlen(banner));
coloredMsg(LOG_YELLOW, false, "ch che sent banner, send returns 0x%02x", resultSend); coloredMsg(LOG_YELLOW, false, "ch che sent banner, send returns 0x%02x", resultSend);
prompt = defaultPrompt; prompt = defaultPrompt;
resetConfigMode = true; resetConfigMode = true;
@ -307,7 +307,7 @@ void cmdHandlerEngine(void *handle) {
coloredMsg(LOG_YELLOW, true, "ch che sockState is 0x%02x when trying to send promt", sockState); coloredMsg(LOG_YELLOW, true, "ch che sockState is 0x%02x when trying to send promt", sockState);
state = CH_DISCONNECT; state = CH_DISCONNECT;
} else { } else {
resultSend = send(CMD_SOCK, prompt, strlen(prompt)); resultSend = send(CMD_SOCK, (uint8_t*)prompt, strlen(prompt));
coloredMsg(LOG_YELLOW, false, "ch che sent prompt %s, send returns 0x%02x", prompt, resultSend); coloredMsg(LOG_YELLOW, false, "ch che sent prompt %s, send returns 0x%02x", prompt, resultSend);
state = CH_RECEIVE; state = CH_RECEIVE;
} }
@ -326,13 +326,13 @@ void cmdHandlerEngine(void *handle) {
resultRecv = recv(CMD_SOCK, receiveBuffer, sizeof(receiveBuffer)); resultRecv = recv(CMD_SOCK, receiveBuffer, sizeof(receiveBuffer));
coloredMsg(LOG_YELLOW, false, "ch che recv returns 0x%02x", resultRecv); coloredMsg(LOG_YELLOW, false, "ch che recv returns 0x%02x", resultRecv);
if (resultRecv > 0) { if (resultRecv > 0) {
if ((receiveBuffer[strlen(receiveBuffer) - 1] == 0x0a) || if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
(receiveBuffer[strlen(receiveBuffer) - 1] == 0x0d)) { (receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
receiveBuffer[strlen(receiveBuffer) - 1] = 0; receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
} }
if ((receiveBuffer[strlen(receiveBuffer) - 1] == 0x0a) || if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
(receiveBuffer[strlen(receiveBuffer) - 1] == 0x0d)) { (receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
receiveBuffer[strlen(receiveBuffer) - 1] = 0; receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
} }
coloredMsg(LOG_YELLOW, false, "ch che received: %s", receiveBuffer); coloredMsg(LOG_YELLOW, false, "ch che received: %s", receiveBuffer);
int8_t resCEC = cmdExecuteCommand(receiveBuffer, resetConfigMode); int8_t resCEC = cmdExecuteCommand(receiveBuffer, resetConfigMode);

View File

@ -27,7 +27,7 @@
extern const uint8_t SYSLOG_SOCK; extern const uint8_t SYSLOG_SOCK;
const uint8_t syslogAddr[] = { 172, 16, 11, 15 }; uint8_t syslogAddr[] = { 172, 16, 11, 15 };
uint8_t singleOctetTXBuffer; uint8_t singleOctetTXBuffer;
@ -88,9 +88,9 @@ static int innerLogMsg(const char *pre, const char *post, bool syslogToo, const
const static char SYSLOG_HEADER[] = "<133>1 "; const static char SYSLOG_HEADER[] = "<133>1 ";
#define MAX_PREFIX_SIZE 20 #define MAX_PREFIX_SIZE 20
int res = -1; int res = -1;
int offset = 0;
char msgBuffer[MSGBUFFER_SIZE+MAX_PREFIX_SIZE]; char msgBuffer[MSGBUFFER_SIZE+MAX_PREFIX_SIZE];
char *bufferStart; char *bufferStart;
memset(msgBuffer, 0, MSGBUFFER_SIZE+MAX_PREFIX_SIZE); memset(msgBuffer, 0, MSGBUFFER_SIZE+MAX_PREFIX_SIZE);
uint16_t syslogHeaderSize = strlen(SYSLOG_HEADER); uint16_t syslogHeaderSize = strlen(SYSLOG_HEADER);
@ -126,7 +126,7 @@ static int innerLogMsg(const char *pre, const char *post, bool syslogToo, const
#ifdef LOGGER_OUTPUT_BY_INTERRUPT #ifdef LOGGER_OUTPUT_BY_INTERRUPT
debugTxCpltCallback(NULL); debugTxCpltCallback(NULL);
#endif LOGGER_OUTPUT_BY_INTERRUPT #endif //LOGGER_OUTPUT_BY_INTERRUPT
} }
return res; return res;
@ -164,6 +164,9 @@ int coloredMsg(const t_logColor color, bool syslogToo, const char *format, ...)
case LOG_YELLOW: case LOG_YELLOW:
pre = YELLOW; pre = YELLOW;
break; break;
case LOG_NORMAL:
pre = NULL;
break;
} }
va_list vl; va_list vl;
va_start(vl, format); va_start(vl, format);

View File

@ -19,7 +19,6 @@
#include <mbus/mbus-protocol.h> #include <mbus/mbus-protocol.h>
static const char MBUS_TOPIC[] = "IoT/MBGW3/Measurement"; static const char MBUS_TOPIC[] = "IoT/MBGW3/Measurement";
static const uint8_t MBUS_QUERY_CMD = 0x5b; static const uint8_t MBUS_QUERY_CMD = 0x5b;
@ -175,7 +174,7 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
} }
mbus_data_record *record; mbus_data_record *record;
int i; int i;
char *keys[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS]; const char *keys[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
float values[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS]; float values[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
uint8_t numOfConsideredFields = 0; uint8_t numOfConsideredFields = 0;
for (record = data_var->record, i = 0; for (record = data_var->record, i = 0;
@ -689,4 +688,3 @@ void mbusCommInit() {
coloredMsg(LOG_GREEN, true, "mbc mci initializing Meterbus communication"); coloredMsg(LOG_GREEN, true, "mbc mci initializing Meterbus communication");
schAdd(mbusCommScheduler, NULL, 0, 1000); schAdd(mbusCommScheduler, NULL, 0, 1000);
} }

View File

@ -53,9 +53,9 @@ static void mqttStatusPublisher(void *handle) {
coloredMsg(LOG_GREEN, false, "mqsp: publishing status"); coloredMsg(LOG_GREEN, false, "mqsp: publishing status");
t_mbusCommStats *mbusCommStats = mbusCommGetStats(); t_mbusCommStats *mbusCommStats = mbusCommGetStats();
char buf[64]; char buf[64];
snprintf(buf, 128, "{\"uptime\":\"%ld\", \"tasks\":\"%d\", \"requests\":\"%d\", \"errors\":\"%d\"}", snprintf(buf, 128, "{\"uptime\":\"%ld\", \"tasks\":\"%d\", \"requests\":\"%ld\", \"errors\":\"%ld\"}",
HAL_GetTick()/1000, schTaskCnt(), mbusCommStats->requestCnt, mbusCommStats->errorCnt); HAL_GetTick()/1000, schTaskCnt(), mbusCommStats->requestCnt, mbusCommStats->errorCnt);
bool res = publish(&mqttClient, StatusTopic, (const char*)buf, strlen(buf), false); bool res = publish(&mqttClient, StatusTopic, (const uint8_t*)buf, strlen(buf), false);
coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res); coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res);
} }
@ -90,7 +90,7 @@ void mqttCommHandler(void *handle) {
case 2: case 2:
coloredMsg(LOG_GREEN, false, "mqch, publish start-up"); coloredMsg(LOG_GREEN, false, "mqch, publish start-up");
res = publish(&mqttClient, StartupTopic, (const char*)message, strlen(message), false); res = publish(&mqttClient, StartupTopic, (const uint8_t*)message, strlen((char*)message), false);
coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res); coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res);
schAdd(mqttStatusPublisher, NULL, 0, 60000); schAdd(mqttStatusPublisher, NULL, 0, 60000);
coloredMsg(LOG_GREEN, false, "mqch, status publisher scheduled"); coloredMsg(LOG_GREEN, false, "mqch, status publisher scheduled");
@ -132,10 +132,10 @@ void mqttCommInit() {
schAdd(mqttCommHandler, NULL, 0, 100); schAdd(mqttCommHandler, NULL, 0, 100);
} }
void mqttPublish(char *topic, char *message) { void mqttPublish(const char *topic, char *message) {
bool res = false; bool res = false;
if (isNetworkAvailable()) { if (isNetworkAvailable()) {
res = publish(&mqttClient, topic, message, strlen(message), false); res = publish(&mqttClient, topic, (const uint8_t*)message, strlen(message), false);
} }
if (res) { if (res) {
coloredMsg(LOG_GREEN, false, "mqp: %s -> %s successfully published", message, topic); coloredMsg(LOG_GREEN, false, "mqp: %s -> %s successfully published", message, topic);
@ -144,7 +144,7 @@ void mqttPublish(char *topic, char *message) {
} }
} }
void mqttPublishf(char *topic, char *messageFormat, ...) { void mqttPublishf(const char *topic, char *messageFormat, ...) {
va_list vl; va_list vl;
va_start(vl, messageFormat); va_start(vl, messageFormat);
char buf[2048]; char buf[2048];
@ -156,3 +156,5 @@ void mqttPublishf(char *topic, char *messageFormat, ...) {
coloredMsg(LOG_RED, true, "mqc mpf buffer overflow, truncated message not published"); coloredMsg(LOG_RED, true, "mqc mpf buffer overflow, truncated message not published");
} }
} }

@ -1 +1 @@
Subproject commit e1f4dbdd52fe8a67e0665a0f3f5368ede1c59d83 Subproject commit d063561b274d62011b5f54df89c7451c939b355e

@ -1 +1 @@
Subproject commit 44647d686f41aa14446ed9e59bd6dd7b64b3541f Subproject commit 1ac129a02743d20b8d185fb41b7ee7b1ea85d412

View File

@ -73,6 +73,7 @@ cp $MAKEFILE $MAKEFILE_BAK
echo "# $PROCESSED" > $MAKEFILE echo "# $PROCESSED" > $MAKEFILE
cat $MAKEFILE_BAK | \ cat $MAKEFILE_BAK | \
sed -e 's/\(-specs=nano.specs\)/\1 -u _printf_float/' | \ sed -e 's/\(-specs=nano.specs\)/\1 -u _printf_float/' | \
sed -e 's/\(-Wall\)/\1 -Werror/' | \
sed -e 's%\(# list of ASM program objects\)%OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a pubsubc.a)\n\1%' | \ sed -e 's%\(# list of ASM program objects\)%OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a pubsubc.a)\n\1%' | \
sed -e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/w5500.a:\n\t(cd ioLibrary_Driver \&\& $(MAKE) \&\& cp w5500.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' | \ sed -e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/w5500.a:\n\t(cd ioLibrary_Driver \&\& $(MAKE) \&\& cp w5500.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' | \
sed -e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/pubsubc.a:\n\t(cd pubsubc \&\& $(MAKE) \&\& cp pubsubc.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' | \ sed -e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/pubsubc.a:\n\t(cd pubsubc \&\& $(MAKE) \&\& cp pubsubc.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' | \