all warnings as errors
This commit is contained in:
@ -55,11 +55,11 @@ bool globalStatsCmd(uint8_t argc, char **args) {
|
||||
char buf[256];
|
||||
sprintf(buf, \
|
||||
"Global statistics\n\r" \
|
||||
" Requests: %d\n\r" \
|
||||
" Errors: %d\n\r",
|
||||
" Requests: %ld\n\r" \
|
||||
" Errors: %ld\n\r",
|
||||
stats->requestCnt, stats->errorCnt
|
||||
);
|
||||
send(CMD_SOCK, buf, strlen(buf));
|
||||
send(CMD_SOCK, (uint8_t*)buf, strlen(buf));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ const static cmd_t COMMANDS[] = {
|
||||
// returns 1 to toggle to config mode
|
||||
// returns 2 to toggle back to default mode
|
||||
int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
|
||||
const static uint8_t HELP_MSG[] = \
|
||||
const static char HELP_MSG[] = \
|
||||
"Usage\n\r" \
|
||||
"\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" \
|
||||
"disable .............................. Disable configuration mode\n\r" \
|
||||
;
|
||||
const static uint8_t GOODBYE_MSG[] = "Good bye\n\r";
|
||||
const static uint8_t OK_MSG[] = "OK\n\r";
|
||||
const static uint8_t FAILED_MSG[] = "Failed\n\r";
|
||||
const static uint8_t REQUIRES_CONFIG_MODE_MGS[] = "Not executed, requires config mode\n\r";
|
||||
const static char GOODBYE_MSG[] = "Good bye\n\r";
|
||||
const static char OK_MSG[] = "OK\n\r";
|
||||
const static char FAILED_MSG[] = "Failed\n\r";
|
||||
const static char REQUIRES_CONFIG_MODE_MGS[] = "Not executed, requires config mode\n\r";
|
||||
uint8_t *messageToSend = NULL;
|
||||
|
||||
static bool configMode = false;
|
||||
@ -158,7 +158,7 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
|
||||
#define MAX_NUM_OF_ARGS 8
|
||||
char *args[MAX_NUM_OF_TASKS];
|
||||
uint8_t argc = 0;
|
||||
char *inCmdLine = cmdLine;
|
||||
char *inCmdLine = (char*)cmdLine;
|
||||
do {
|
||||
args[argc++] = strtok(inCmdLine, " ");
|
||||
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);
|
||||
|
||||
if (0 == strcmp(cmd, "quit")) {
|
||||
messageToSend = GOODBYE_MSG;
|
||||
messageToSend = (uint8_t*)GOODBYE_MSG;
|
||||
retCode = -1;
|
||||
} 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;
|
||||
while (true) {
|
||||
cmd_t command = COMMANDS[cmdIdx];
|
||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
||||
break;
|
||||
}
|
||||
send(CMD_SOCK, command.help, strlen(command.help));
|
||||
send(CMD_SOCK, (uint8_t*)command.help, strlen(command.help));
|
||||
cmdIdx++;
|
||||
}
|
||||
messageToSend = NULL;
|
||||
@ -203,9 +203,9 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
|
||||
}
|
||||
if (0 == strcmp(cmd, command.name)) {
|
||||
if (command.requiredConfigMode && !configMode) {
|
||||
messageToSend = REQUIRES_CONFIG_MODE_MGS;
|
||||
messageToSend = (uint8_t*)REQUIRES_CONFIG_MODE_MGS;
|
||||
} else {
|
||||
messageToSend = command.cmdFunc(argc, args) ? OK_MSG : FAILED_MSG;
|
||||
messageToSend = command.cmdFunc(argc, args) ? (uint8_t*)OK_MSG : (uint8_t*)FAILED_MSG;
|
||||
}
|
||||
}
|
||||
cmdIdx++;
|
||||
@ -213,7 +213,7 @@ int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetConfigMode) {
|
||||
}
|
||||
|
||||
if (messageToSend) {
|
||||
send(CMD_SOCK, messageToSend, strlen(messageToSend));
|
||||
send(CMD_SOCK, messageToSend, strlen((char*)messageToSend));
|
||||
}
|
||||
|
||||
return retCode;
|
||||
@ -225,14 +225,14 @@ void cmdHandlerEngine(void *handle) {
|
||||
static chState_t state = CH_INIT;
|
||||
static bool resetConfigMode = false;
|
||||
|
||||
static uint8_t banner[] = \
|
||||
static char banner[] = \
|
||||
"MBGW3\n\r" \
|
||||
"Type help for usage help\n\r" \
|
||||
"or quit to close the connection.\n\r";
|
||||
|
||||
static uint8_t *prompt;
|
||||
static uint8_t defaultPrompt[] = "MBGW3 # ";
|
||||
static uint8_t elevatedPrompt[] = "MBGW3 (admin) > ";
|
||||
static char *prompt;
|
||||
static char defaultPrompt[] = "MBGW3 # ";
|
||||
static char elevatedPrompt[] = "MBGW3 (admin) > ";
|
||||
|
||||
|
||||
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);
|
||||
state = CH_DISCONNECT;
|
||||
} 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);
|
||||
prompt = defaultPrompt;
|
||||
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);
|
||||
state = CH_DISCONNECT;
|
||||
} 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);
|
||||
state = CH_RECEIVE;
|
||||
}
|
||||
@ -326,13 +326,13 @@ void cmdHandlerEngine(void *handle) {
|
||||
resultRecv = recv(CMD_SOCK, receiveBuffer, sizeof(receiveBuffer));
|
||||
coloredMsg(LOG_YELLOW, false, "ch che recv returns 0x%02x", resultRecv);
|
||||
if (resultRecv > 0) {
|
||||
if ((receiveBuffer[strlen(receiveBuffer) - 1] == 0x0a) ||
|
||||
(receiveBuffer[strlen(receiveBuffer) - 1] == 0x0d)) {
|
||||
receiveBuffer[strlen(receiveBuffer) - 1] = 0;
|
||||
if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
|
||||
(receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
|
||||
receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
|
||||
}
|
||||
if ((receiveBuffer[strlen(receiveBuffer) - 1] == 0x0a) ||
|
||||
(receiveBuffer[strlen(receiveBuffer) - 1] == 0x0d)) {
|
||||
receiveBuffer[strlen(receiveBuffer) - 1] = 0;
|
||||
if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
|
||||
(receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
|
||||
receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
|
||||
}
|
||||
coloredMsg(LOG_YELLOW, false, "ch che received: %s", receiveBuffer);
|
||||
int8_t resCEC = cmdExecuteCommand(receiveBuffer, resetConfigMode);
|
||||
|
Reference in New Issue
Block a user