Skip to content

Commit

Permalink
Fix warnings reported in jeelabs#113 (format warnings, differing types)
Browse files Browse the repository at this point in the history
  • Loading branch information
deece committed Apr 1, 2016
1 parent 163986a commit 80d9945
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions cmd/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static uint16_t resp_crc;
// Start a response, returns the partial CRC
void ICACHE_FLASH_ATTR
cmdResponseStart(uint16_t cmd, uint32_t value, uint16_t argc) {
DBG("cmdResponse: cmd=%d val=%ld argc=%d\n", cmd, value, argc);
DBG("cmdResponse: cmd=%d val=%d argc=%d\n", cmd, value, argc);

uart0_write_char(SLIP_END);
cmdProtoWriteBuf((uint8_t*)&cmd, 2);
Expand Down Expand Up @@ -107,7 +107,7 @@ cmdParsePacket(uint8_t *buf, short len) {
uint8_t *data_ptr = (uint8_t*)&packet->args;
uint8_t *data_limit = data_ptr+len;

DBG("cmdParsePacket: cmd=%d argc=%d value=%lu\n",
DBG("cmdParsePacket: cmd=%d argc=%d value=%u\n",
packet->cmd,
packet->argc,
packet->value
Expand Down
2 changes: 1 addition & 1 deletion cmd/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cmdAddCb(char* name, uint32_t cb) {
os_strncpy(callbacks[i].name, name, sizeof(callbacks[i].name));
callbacks[i].name[CMD_CBNLEN-1] = 0; // strncpy doesn't null terminate
callbacks[i].callback = cb;
DBG("cmdAddCb: '%s'->0x%lx added at %d\n", callbacks[i].name, cb, i);
DBG("cmdAddCb: '%s'->0x%x added at %d\n", callbacks[i].name, cb, i);
return 1;
}
}
Expand Down
4 changes: 2 additions & 2 deletions esp-link/cgiflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static char* ICACHE_FLASH_ATTR check_header(void *buf) {
uint8_t *cd = (uint8_t *)buf;
#ifdef CGIFLASH_DBG
uint32_t *buf32 = buf;
os_printf("%p: %08lX %08lX %08lX %08lX\n", buf, buf32[0], buf32[1], buf32[2], buf32[3]);
os_printf("%p: %08X %08X %08X %08X\n", buf, buf32[0], buf32[1], buf32[2], buf32[3]);
#endif
if (cd[0] != 0xEA) return "IROM magic missing";
if (cd[1] != 4 || cd[2] > 3 || (cd[3]>>4) > 6) return "bad flash header";
Expand Down Expand Up @@ -197,4 +197,4 @@ int ICACHE_FLASH_ATTR cgiReset(HttpdConnData *connData) {
os_timer_setfn(&flash_reboot_timer, (os_timer_func_t *)system_restart, NULL);
os_timer_arm(&flash_reboot_timer, 2000, 1);
return HTTPD_CGI_DONE;
}
}
12 changes: 6 additions & 6 deletions esp-link/cgioptiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int ICACHE_FLASH_ATTR cgiOptibootSync(HttpdConnData *connData) {
if (!errMessage[0] && progState >= stateProg) {
char buf[64];
DBG("OB got sync\n");
os_sprintf(buf, "SYNC at %ld baud: bootloader v%d.%d",
os_sprintf(buf, "SYNC at %d baud: bootloader v%d.%d",
baudRate, optibootVers>>8, optibootVers&0xff);
httpdSend(connData, buf, -1);
} else if (errMessage[0] && progState == stateSync) {
Expand Down Expand Up @@ -314,7 +314,7 @@ int ICACHE_FLASH_ATTR cgiOptibootData(HttpdConnData *connData) {
float dt = ((system_get_time() - optibootData->startTime)/1000)/1000.0; // in seconds
uint16_t pgmDone = optibootData->pgmDone;
optibootInit();
os_sprintf(errMessage, "Success. %d bytes at %ld baud in %d.%ds, %dB/s %d%% efficient",
os_sprintf(errMessage, "Success. %d bytes at %d baud in %d.%ds, %dB/s %d%% efficient",
pgmDone, baudRate, (int)dt, (int)(dt*10)%10, (int)(pgmDone/dt),
(int)(100.0*(10.0*pgmDone/baudRate)/dt));
} else {
Expand Down Expand Up @@ -387,7 +387,7 @@ static bool ICACHE_FLASH_ATTR processRecord(char *buf, short len) {
optibootData->eof = true;
break;
case 0x04: // address
DBG("OB address 0x%lx\n", getHexValue(buf+8, 4) << 16);
DBG("OB address 0x%x\n", getHexValue(buf+8, 4) << 16);
// program any remaining partial page
if (optibootData->pageLen > 0)
if (!programPage()) return false;
Expand Down Expand Up @@ -435,7 +435,7 @@ static bool ICACHE_FLASH_ATTR programPage(void) {

uint16_t pgmLen = optibootData->pageLen;
if (pgmLen > optibootData->pgmSz) pgmLen = optibootData->pgmSz;
DBG("OB pgm %d@0x%lx\n", pgmLen, optibootData->address);
DBG("OB pgm %d@0x%x\n", pgmLen, optibootData->address);

// send address to optiboot (little endian format)
#ifdef DBG_GPIO5
Expand Down Expand Up @@ -525,7 +525,7 @@ static void ICACHE_FLASH_ATTR optibootTimerCB(void *arg) {
return;
}
// time to switch baud rate and issue a reset
DBG("OB no sync response @%ld baud\n", baudRate);
DBG("OB no sync response @%d baud\n", baudRate);
setBaud();
serbridgeReset();
progState = stateInit;
Expand All @@ -539,7 +539,7 @@ static void ICACHE_FLASH_ATTR optibootTimerCB(void *arg) {
return;
default: // we're trying to get some info from optiboot and it should have responded!
optibootInit(); // abort
os_sprintf(errMessage, "No response in state %s(%d) @%ld baud\n",
os_sprintf(errMessage, "No response in state %s(%d) @%d baud\n",
progStates[progState], progState, baudRate);
DBG("OB %s\n", errMessage);
return; // do not re-arm timer
Expand Down
2 changes: 1 addition & 1 deletion esp-link/cgipins.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) {

int8_t ok = 0;
int8_t reset, isp, conn, ser;
bool swap, rxpup;
uint8_t swap, rxpup;
ok |= getInt8Arg(connData, "reset", &reset);
ok |= getInt8Arg(connData, "isp", &isp);
ok |= getInt8Arg(connData, "conn", &conn);
Expand Down
14 changes: 7 additions & 7 deletions esp-link/cgiservices.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) {
"\"name\": \"%s\", "
"\"reset cause\": \"%d=%s\", "
"\"size\": \"%s\", "
"\"id\": \"0x%02lX 0x%04lX\", "
"\"id\": \"0x%02X 0x%04X\", "
"\"partition\": \"%s\", "
"\"slip\": \"%s\", "
"\"mqtt\": \"%s/%s\", "
"\"baud\": \"%ld\", "
"\"baud\": \"%d\", "
"\"description\": \"%s\""
" }",
flashConfig.hostname,
Expand All @@ -92,10 +92,10 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) {
}

void ICACHE_FLASH_ATTR cgiServicesSNTPInit() {
if (flashConfig.sntp_server[0] != '\0') {
if (flashConfig.sntp_server[0] != '\0') {
sntp_stop();
if (true == sntp_set_timezone(flashConfig.timezone_offset)) {
sntp_setservername(0, flashConfig.sntp_server);
sntp_setservername(0, flashConfig.sntp_server);
sntp_init();
}
DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset);
Expand All @@ -107,7 +107,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) {

if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.

os_sprintf(buff,
os_sprintf(buff,
"{ "
"\"syslog_host\": \"%s\", "
"\"syslog_minheap\": %d, "
Expand All @@ -118,7 +118,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) {
"\"sntp_server\": \"%s\", "
"\"mdns_enable\": \"%s\", "
"\"mdns_servername\": \"%s\""
" }",
" }",
flashConfig.syslog_host,
flashConfig.syslog_minheap,
flashConfig.syslog_filter,
Expand Down Expand Up @@ -168,7 +168,7 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) {
int8_t mdns = 0;
mdns |= getBoolArg(connData, "mdns_enable", &flashConfig.mdns_enable);
if (mdns < 0) return HTTPD_CGI_DONE;

if (mdns > 0) {
if (flashConfig.mdns_enable){
DBG("Services: MDNS Enabled\n");
Expand Down
10 changes: 5 additions & 5 deletions esp-link/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ typedef struct {
char hostname[32]; // if using DHCP
uint32_t staticip, netmask, gateway; // using DHCP if staticip==0
uint8_t log_mode; // UART log debug mode
int8_t swap_uart; // swap uart0 to gpio 13&15
uint8_t swap_uart; // swap uart0 to gpio 13&15
uint8_t tcp_enable, rssi_enable; // TCP client settings
char api_key[48]; // RSSI submission API key (Grovestreams for now)
uint8_t slip_enable, mqtt_enable, // SLIP protocol, MQTT client
mqtt_status_enable, // MQTT status reporting
mqtt_timeout, // MQTT send timeout
mqtt_clean_session; // MQTT clean session
uint16_t mqtt_port, mqtt_keepalive; // MQTT Host port, MQTT Keepalive timer
char mqtt_host[32],
mqtt_clientid[48],
mqtt_username[32],
char mqtt_host[32],
mqtt_clientid[48],
mqtt_username[32],
mqtt_password[32],
mqtt_status_topic[32];
char sys_descr[129]; // system description
Expand All @@ -35,7 +35,7 @@ typedef struct {
syslog_showtick, // show system tick (µs)
syslog_showdate; // populate SYSLOG date field
uint8_t mdns_enable;
char mdns_servername[32];
char mdns_servername[32];
int8_t timezone_offset;
} FlashConfig;
extern FlashConfig flashConfig;
Expand Down
8 changes: 4 additions & 4 deletions esp-link/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ HttpdBuiltInUrl builtInUrls[] = {
{ "/wifi/setmode", cgiWiFiSetMode, NULL },
{ "/wifi/special", cgiWiFiSpecial, NULL },
{ "/wifi/apinfo", cgiApSettingsInfo, NULL },
{ "/wifi/apchange", cgiApSettingsChange, NULL },
{ "/wifi/apchange", cgiApSettingsChange, NULL },
{ "/system/info", cgiSystemInfo, NULL },
{ "/system/update", cgiSystemSet, NULL },
{ "/services/info", cgiServicesInfo, NULL },
{ "/services/update", cgiServicesSet, NULL },
{ "/pins", cgiPins, NULL },
#ifdef MQTT
{ "/mqtt", cgiMqtt, NULL },
#endif
#endif
{ "*", cgiEspFsHook, NULL }, //Catch-all cgi function for the filesystem
{ NULL, NULL, NULL }
};
Expand Down Expand Up @@ -149,10 +149,10 @@ void user_init(void) {
rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3,
rst_info->excvaddr, rst_info->depc);
uint32_t fid = spi_flash_get_id();
NOTICE("Flash map %s, manuf 0x%02lX chip 0x%04lX", flash_maps[system_get_flash_size_map()],
NOTICE("Flash map %s, manuf 0x%02X chip 0x%04X", flash_maps[system_get_flash_size_map()],
fid & 0xff, (fid&0xff00)|((fid>>16)&0xff));
NOTICE("** esp-link ready");

// Init SNTP service
cgiServicesSNTPInit();
#ifdef MQTT
Expand Down
6 changes: 3 additions & 3 deletions mqtt/mqtt_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cmdMqttDataCb(MQTT_Client* client, const char* topic, uint32_t topic_len,
const char* data, uint32_t data_len)
{
MqttCmdCb* cb = (MqttCmdCb*)client->user_data;
DBG("MQTT: Data cb=%p topic=%s len=%ld\n", (void*)cb->dataCb, topic, data_len);
DBG("MQTT: Data cb=%p topic=%s len=%u\n", (void*)cb->dataCb, topic, data_len);

cmdResponseStart(CMD_RESP_CB, cb->dataCb, 2);
cmdResponseBody(topic, topic_len);
Expand Down Expand Up @@ -168,7 +168,7 @@ MQTTCMD_Subscribe(CmdPacket *cmd) {
uint32_t qos = 0;
cmdPopArg(&req, (uint8_t*)&qos, 4);

DBG("MQTT: MQTTCMD_Subscribe topic=%s, qos=%ld\n", topic, qos);
DBG("MQTT: MQTTCMD_Subscribe topic=%s, qos=%u\n", topic, qos);

MQTT_Subscribe(client, (char*)topic, (uint8_t)qos);
os_free(topic);
Expand Down Expand Up @@ -245,7 +245,7 @@ MQTTCMD_Setup(CmdPacket *cmd) {
cmdPopArg(&req, &callback->dataCb, 4);
client->user_data = callback;

DBG("MQTT connectedCb=%lx\n", callback->connectedCb);
DBG("MQTT connectedCb=%x\n", callback->connectedCb);

client->cmdConnectedCb = cmdMqttConnectedCb;
client->cmdDisconnectedCb = cmdMqttDisconnectedCb;
Expand Down
12 changes: 6 additions & 6 deletions rest/rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ REST_Setup(CmdPacket *cmd) {
os_free(client->pCon);
}
os_memset(client, 0, sizeof(RestClient));
DBG_REST("REST: setup #%d host=%s port=%ld security=%ld\n", clientNum, rest_host, port, security);
DBG_REST("REST: setup #%d host=%s port=%d security=%d\n", clientNum, rest_host, port, security);

client->resp_cb = cmd->value;

Expand Down Expand Up @@ -348,7 +348,7 @@ REST_Request(CmdPacket *cmd) {
// Get client
uint32_t clientNum = cmd->value;
RestClient *client = restClient + (clientNum % MAX_REST);
DBG_REST(" #%ld", clientNum);
DBG_REST(" #%d", clientNum);

// Get HTTP method
uint16_t len = cmdArgLen(&req);
Expand All @@ -374,7 +374,7 @@ REST_Request(CmdPacket *cmd) {
realLen = cmdArgLen(&req);
if (realLen > 2048) goto fail;
}
DBG_REST(" bodyLen=%ld", realLen);
DBG_REST(" bodyLen=%d", realLen);

// we need to allocate memory for the header plus the body. First we count the length of the
// header (including some extra counted "%s" and then we add the body length. We allocate the
Expand All @@ -393,7 +393,7 @@ REST_Request(CmdPacket *cmd) {
if (client->data) os_free(client->data);
client->data = (char*)os_zalloc(headerLen + realLen);
if (client->data == NULL) goto fail;
DBG_REST(" totLen=%ld data=%p", headerLen + realLen, client->data);
DBG_REST(" totLen=%d data=%p", headerLen + realLen, client->data);
client->data_len = os_sprintf((char*)client->data, headerFmt, method, path, client->host,
client->header, realLen, client->content_type, client->user_agent);
DBG_REST(" hdrLen=%d", client->data_len);
Expand All @@ -412,15 +412,15 @@ REST_Request(CmdPacket *cmd) {
espconn_regist_reconcb(client->pCon, tcpclient_recon_cb);

if(UTILS_StrToIP((char *)client->host, &client->pCon->proto.tcp->remote_ip)) {
DBG_REST("REST: Connect to ip %s:%ld\n",client->host, client->port);
DBG_REST("REST: Connect to ip %s:%d\n",client->host, client->port);
//if(client->security){
// espconn_secure_connect(client->pCon);
//}
//else {
espconn_connect(client->pCon);
//}
} else {
DBG_REST("REST: Connect to host %s:%ld\n", client->host, client->port);
DBG_REST("REST: Connect to host %s:%d\n", client->host, client->port);
espconn_gethostbyname(client->pCon, (char *)client->host, &client->ip, rest_dns_found);
}

Expand Down
6 changes: 3 additions & 3 deletions serial/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ajaxConsoleBaud(HttpdConnData *connData) {
}

jsonHeader(connData, status);
os_sprintf(buff, "{\"rate\": %ld}", flashConfig.baud_rate);
os_sprintf(buff, "{\"rate\": %d}", flashConfig.baud_rate);
httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE;
}
Expand All @@ -86,14 +86,14 @@ ajaxConsoleSend(HttpdConnData *connData) {
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
char buff[2048];
int len, status = 400;

// figure out where to start in buffer based on URI param
len = httpdFindArg(connData->getArgs, "text", buff, sizeof(buff));
if (len > 0) {
uart0_tx_buffer(buff, len);
status = 200;
}

jsonHeader(connData, status);
return HTTPD_CGI_DONE;
}
Expand Down
6 changes: 3 additions & 3 deletions syslog/syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,16 @@ syslog_compose(uint8_t facility, uint8_t severity, const char *tag, const char *
tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec);
if (realtime_stamp == 0)
p += os_sprintf(p, ".%06luZ ", se->tick % 1000000);
p += os_sprintf(p, ".%06uZ ", se->tick % 1000000);
else
p += os_sprintf(p, "%+03d:00 ", flashConfig.timezone_offset);
}

// add HOSTNAME APP-NAME PROCID MSGID
if (flashConfig.syslog_showtick)
p += os_sprintf(p, "%s %s %lu.%06lu %lu ", flashConfig.hostname, tag, se->tick / 1000000, se->tick % 1000000, syslog_msgid++);
p += os_sprintf(p, "%s %s %u.%06u %u ", flashConfig.hostname, tag, se->tick / 1000000, se->tick % 1000000, syslog_msgid++);
else
p += os_sprintf(p, "%s %s - %lu ", flashConfig.hostname, tag, syslog_msgid++);
p += os_sprintf(p, "%s %s - %u ", flashConfig.hostname, tag, syslog_msgid++);

// append syslog message
va_list arglist;
Expand Down

0 comments on commit 80d9945

Please sign in to comment.