Skip to content

Commit

Permalink
Merge pull request #1293 from simonduq/pr/fix-warnings
Browse files Browse the repository at this point in the history
Fix a number of compiler warnings and enable -Werror in Travis
  • Loading branch information
simonduq committed Nov 10, 2015
2 parents 59fc385 + a29502e commit fbd78a7
Show file tree
Hide file tree
Showing 80 changed files with 201 additions and 146 deletions.
33 changes: 14 additions & 19 deletions apps/powertrace/powertrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@

struct powertrace_sniff_stats {
struct powertrace_sniff_stats *next;
uint32_t num_input, num_output;
uint32_t input_txtime, input_rxtime;
uint32_t output_txtime, output_rxtime;
unsigned long num_input, num_output;
unsigned long input_txtime, input_rxtime;
unsigned long output_txtime, output_rxtime;
#if NETSTACK_CONF_WITH_IPV6
uint16_t proto; /* includes proto + possibly flags */
#endif
uint16_t channel;
uint32_t last_input_txtime, last_input_rxtime;
uint32_t last_output_txtime, last_output_rxtime;
unsigned long last_input_txtime, last_input_rxtime;
unsigned long last_output_txtime, last_output_rxtime;
};

#define INPUT 1
Expand All @@ -72,17 +72,17 @@ PROCESS(powertrace_process, "Periodic power output");
void
powertrace_print(char *str)
{
static uint32_t last_cpu, last_lpm, last_transmit, last_listen;
static uint32_t last_idle_transmit, last_idle_listen;
static unsigned long last_cpu, last_lpm, last_transmit, last_listen;
static unsigned long last_idle_transmit, last_idle_listen;

uint32_t cpu, lpm, transmit, listen;
uint32_t all_cpu, all_lpm, all_transmit, all_listen;
uint32_t idle_transmit, idle_listen;
uint32_t all_idle_transmit, all_idle_listen;
unsigned long cpu, lpm, transmit, listen;
unsigned long all_cpu, all_lpm, all_transmit, all_listen;
unsigned long idle_transmit, idle_listen;
unsigned long all_idle_transmit, all_idle_listen;

static uint32_t seqno;
static unsigned long seqno;

uint32_t time, all_time, radio, all_radio;
unsigned long time, all_time, radio, all_radio;

struct powertrace_sniff_stats *s;

Expand Down Expand Up @@ -287,13 +287,8 @@ output_sniffer(int mac_status)
static void
sniffprint(char *prefix, int seqno)
{
const linkaddr_t *sender, *receiver, *esender, *ereceiver;

sender = packetbuf_addr(PACKETBUF_ADDR_SENDER);
receiver = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
const linkaddr_t *esender;
esender = packetbuf_addr(PACKETBUF_ADDR_ESENDER);
ereceiver = packetbuf_addr(PACKETBUF_ADDR_ERECEIVER);


printf("%lu %s %d %u %d %d %d.%d %u %u\n",
clock_time(),
Expand Down
4 changes: 0 additions & 4 deletions apps/servreg-hack/servreg-hack.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,10 @@ static void
parse_incoming_packet(const uint8_t *buf, int len)
{
int numregs;
int flags;
int i;
int bufptr;

numregs = buf[MSG_NUMREGS_OFFSET];
flags = buf[MSG_FLAGS_OFFSET];

/* printf("parse_incoming_packet Numregs %d flags %d\n", numregs, flags);*/

bufptr = MSG_ADDRS_OFFSET;
for(i = 0; i < numregs; ++i) {
Expand Down
1 change: 1 addition & 0 deletions apps/shell/shell-crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define HAVE_ALLOCA 0
#else
#define HAVE_ALLOCA 1
#include <alloca.h>
#endif

#define DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions apps/shell/shell-memdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PROCESS_THREAD(shell_poke_process, ev, data)
PROCESS_EXIT();
}

address = (uint8_t *)(int)shell_strtolong(args, &next);
address = (uint8_t *)(uintptr_t)shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&poke_command, "usage 1", "");
PROCESS_EXIT();
Expand Down Expand Up @@ -106,7 +106,7 @@ PROCESS_THREAD(shell_peek_process, ev, data)
PROCESS_EXIT();
}

address = (uint8_t *)(int)shell_strtolong(args, &next);
address = (uint8_t *)(uintptr_t)shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&peek_command, "usage 1", "");
PROCESS_EXIT();
Expand Down
4 changes: 2 additions & 2 deletions apps/shell/shell-netperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ memcpy_misaligned(void *dest, const void *source, int len)
int i;
uint8_t *destptr;
const uint8_t *sourceptr;
if(((int)dest & 1) == 1 ||
((int)source & 1) == 1) {
if(((uintptr_t)dest & 1) == 1 ||
((uintptr_t)source & 1) == 1) {
destptr = dest;
sourceptr = source;
for(i = 0; i < len; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions apps/shell/shell-rime-netcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ PROCESS_THREAD(shell_netcmd_process, ev, data)

/* Terminate the string with a NUL character. */
msg->netcmd[len] = 0;
msg->crc = crc16_data(msg->netcmd, len, 0);
msg->crc = crc16_data((unsigned char *)msg->netcmd, len, 0);
printf("netcmd sending '%s'\n", msg->netcmd);
trickle_send(&trickle);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ recv_trickle(struct trickle_conn *c)
msg->netcmd[len] = 0;
memcpy(&crc, &msg->crc, sizeof(crc));

if(crc == crc16_data(msg->netcmd, len, 0)) {
if(crc == crc16_data((unsigned char *)msg->netcmd, len, 0)) {
/* Start the server process with the incoming command. */
process_start(&shell_netcmd_server_process, (void *)msg->netcmd);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/shell/shell-rime-sendcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ PROCESS_THREAD(shell_sendcmd_process, ev, data)

/* Terminate the string with a NUL character. */
msg->sendcmd[len] = 0;
msg->crc = crc16_data(msg->sendcmd, len, 0);
msg->crc = crc16_data((unsigned char *)msg->sendcmd, len, 0);
/* printf("sendcmd sending '%s'\n", msg->sendcmd);*/
unicast_send(&uc, &addr);

Expand All @@ -160,7 +160,7 @@ recv_uc(struct unicast_conn *c, const linkaddr_t *from)
msg->sendcmd[len] = 0;
memcpy(&crc, &msg->crc, sizeof(crc));

if(crc == crc16_data(msg->sendcmd, len, 0)) {
if(crc == crc16_data((unsigned char *)msg->sendcmd, len, 0)) {
/* Start the server process with the incoming command. */
process_start(&shell_sendcmd_server_process, (void *)msg->sendcmd);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/shell/shell-rime.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ recv_collect(const linkaddr_t *originator, uint8_t seqno, uint8_t hops)

/* Copy the collect message header. */
memcpy(&collect_msg, packetbuf_dataptr(), sizeof(collect_msg));
dataptr = ((struct collect_msg *)packetbuf_dataptr())->data;
dataptr = (char *)((struct collect_msg *)packetbuf_dataptr())->data;

#if TIMESYNCH_CONF_ENABLED
latency = timesynch_time() - collect_msg.timestamp;
Expand All @@ -321,7 +321,7 @@ recv_collect(const linkaddr_t *originator, uint8_t seqno, uint8_t hops)
if(packetbuf_datalen() >= COLLECT_MSG_HDRSIZE) {
len = packetbuf_datalen() - COLLECT_MSG_HDRSIZE;

if(collect_msg.crc == crc16_data(dataptr, len, 0)) {
if(collect_msg.crc == crc16_data((unsigned char *)dataptr, len, 0)) {
msg.len = 5 + (packetbuf_datalen() - COLLECT_MSG_HDRSIZE) / 2;
linkaddr_copy((linkaddr_t *)&msg.originator, originator);
msg.seqno = seqno;
Expand Down
10 changes: 3 additions & 7 deletions apps/shell/shell-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ PROCESS_THREAD(shell_repeat_server_process, ev, data)
static char *command;
static struct process *started_process;
char command_copy[MAX_COMMANDLENGTH];
int ret;

if(ev == shell_event_input) {
goto exit;
Expand All @@ -172,7 +171,7 @@ PROCESS_THREAD(shell_repeat_server_process, ev, data)
data == &shell_repeat_process);
{
strncpy(command_copy, command, MAX_COMMANDLENGTH);
ret = shell_start_command(command_copy, (int)strlen(command_copy),
shell_start_command(command_copy, (int)strlen(command_copy),
&repeat_command, &started_process);

if(started_process != NULL &&
Expand Down Expand Up @@ -202,11 +201,10 @@ repeat_print_usage(void)
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_repeat_process, ev, data)
{
static int reps, period, period_left;
static int reps, period;
static char command[MAX_COMMANDLENGTH];
static struct etimer etimer;
static int i;
static clock_time_t start_time;
const char *args, *next;

if(ev == shell_event_input) {
Expand Down Expand Up @@ -258,7 +256,6 @@ PROCESS_THREAD(shell_repeat_process, ev, data)
/* printf("repeats %d period %d command '%s'\n",
reps, period, command);*/

start_time = clock_time();
etimer_set(&etimer, CLOCK_SECOND * period);
for(i = 0; reps == 0 || i < reps; ++i) {

Expand Down Expand Up @@ -291,7 +288,6 @@ PROCESS_THREAD(shell_randwait_process, ev, data)
static struct etimer etimer;
static struct process *started_process;
const char *args, *next;
int ret;

/* if(ev == shell_event_input) {
struct shell_input *input;
Expand Down Expand Up @@ -339,7 +335,7 @@ PROCESS_THREAD(shell_randwait_process, ev, data)
/* printf("Starting '%s' child %p (%s)\n", command, randwait_command.child, */
/* randwait_command.child == NULL? "null": randwait_command.child->command); */

ret = shell_start_command(command, (int)strlen(command),
shell_start_command(command, (int)strlen(command),
randwait_command.child, &started_process);

if(started_process != NULL &&
Expand Down
6 changes: 3 additions & 3 deletions apps/shell/shell-vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SHELL_VARS_RAM_END SHELL_VARS_CONF_RAM_END
#else /* SHELL_VARS_CONF_RAM_BEGIN */
#define SHELL_VARS_RAM_BEGIN 0
#define SHELL_VARS_RAM_END (unsigned int)-1
#define SHELL_VARS_RAM_END (uintptr_t)-1
#endif /* SHELL_VARS_CONF_RAM_BEGIN */

/*---------------------------------------------------------------------------*/
Expand All @@ -77,8 +77,8 @@ PROCESS_THREAD(shell_vars_process, ev, data)

for(i = 0; i < symbols_nelts; ++i) {
if(symbols[i].name != NULL &&
(unsigned int)symbols[i].value >= SHELL_VARS_RAM_BEGIN &&
(unsigned int)symbols[i].value <= SHELL_VARS_RAM_END) {
(uintptr_t)symbols[i].value >= SHELL_VARS_RAM_BEGIN &&
(uintptr_t)symbols[i].value <= SHELL_VARS_RAM_END) {
shell_output_str(&vars_command, (char *)symbols[i].name, "");
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/webbrowser/webclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ window_copy(int curptr, const char *data, unsigned char datalen)
len = windowend - windowstart;
}

strncpy(windowptr + windowstart, data, len);
strncpy((char *)(windowptr + windowstart), data, len);
windowstart += len;

return curptr + datalen;
Expand All @@ -217,7 +217,7 @@ senddata(void)
windowstart = s.getrequestptr;
curptr = 0;
windowend = windowstart + uip_mss();
windowptr = (char *)uip_appdata - windowstart;
windowptr = (unsigned char *)uip_appdata - windowstart;

curptr = window_copy(curptr, http_get, sizeof(http_get) - 1);
curptr = window_copy(curptr, s.file, (unsigned char)strlen(s.file));
Expand Down
4 changes: 4 additions & 0 deletions apps/webbrowser/www.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,9 @@ add_pagewidget(char *text, unsigned char size, char *attrib, unsigned char type,
void
htmlparser_newline(void)
{
#ifdef WITH_PETSCII
char *wptr;
#endif /* WITH_PETSCII */

if(++newlines > 2) {
return;
Expand All @@ -863,8 +865,10 @@ htmlparser_newline(void)
++y;
x = 0;

#ifdef WITH_PETSCII
wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH;
petsciiconv_topetscii(wptr, WWW_CONF_WEBPAGE_WIDTH);
#endif /* WITH_PETSCII */

if(y == WWW_CONF_WEBPAGE_HEIGHT) {
loading = 0;
Expand Down
4 changes: 2 additions & 2 deletions apps/webserver/urlconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ urlconv_tofilename(char *dest, char *source, unsigned char maxlen)
*dest = ISO_slash;
strncpy(dest + 1, wwwroot, wwwrootlen);
len = 0;
from = source; to = dest + wwwrootlen;
from = (unsigned char *)source; to = (unsigned char *)dest + wwwrootlen;
maxlen -= 2 + wwwrootlen;
do {
c = *(from++);
Expand Down Expand Up @@ -139,7 +139,7 @@ urlconv_tofilename(char *dest, char *source, unsigned char maxlen)
}
} while(c);
if(*to == ISO_slash && (len + sizeof(http_index_htm) - 3) < maxlen) {
strcpy(to, http_index_htm); // add index.htm
strcpy((char *)to, http_index_htm); // add index.htm
} else {
++to;
*to = 0;
Expand Down
4 changes: 2 additions & 2 deletions core/ctk/ctk-filedialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ ctk_filedialog_eventhandler(struct ctk_filedialog_state *s,
}
return 1;
} else if(ev == ctk_signal_keypress) {
if((ctk_arch_key_t)data == CH_CURS_UP) {
if((char)(size_t)data == CH_CURS_UP) {
clearptr();
if(fileptr > 0) {
--fileptr;
}
showptr();
return 1;
} else if((ctk_arch_key_t)data == CH_CURS_DOWN) {
} else if((char)(size_t)data == CH_CURS_DOWN) {
clearptr();
if(fileptr < FILES_HEIGHT - 1) {
++fileptr;
Expand Down
4 changes: 3 additions & 1 deletion core/ctk/ctk.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,9 @@ add_redrawwidget(struct ctk_widget *w)
static void
widget_redraw(struct ctk_widget *widget)
{
#if CTK_CONF_WINDOWS
struct ctk_window *window;
#endif /* CTK_CONF_WINDOWS */

if(mode != CTK_MODE_NORMAL || widget == NULL) {
return;
Expand All @@ -870,8 +872,8 @@ widget_redraw(struct ctk_widget *widget)
if(menus.open == NULL)
#endif /* CTK_CONF_MENUS */
{
window = widget->window;
#if CTK_CONF_WINDOWS
window = widget->window;
if(window == dialog) {
ctk_draw_widget(widget, CTK_FOCUS_DIALOG, 0, height);
} else if(dialog == NULL &&
Expand Down
6 changes: 6 additions & 0 deletions core/net/ipv6/uip-ds6.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ static uip_ipaddr_t loc_fipaddr;
/* Pointers used in this file */
static uip_ds6_addr_t *locaddr;
static uip_ds6_maddr_t *locmaddr;
#if UIP_DS6_AADDR_NB
static uip_ds6_aaddr_t *locaaddr;
#endif /* UIP_DS6_AADDR_NB */
static uip_ds6_prefix_t *locprefix;

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -458,6 +460,7 @@ uip_ds6_maddr_lookup(const uip_ipaddr_t *ipaddr)
uip_ds6_aaddr_t *
uip_ds6_aaddr_add(uip_ipaddr_t *ipaddr)
{
#if UIP_DS6_AADDR_NB
if(uip_ds6_list_loop
((uip_ds6_element_t *)uip_ds6_if.aaddr_list, UIP_DS6_AADDR_NB,
sizeof(uip_ds6_aaddr_t), ipaddr, 128,
Expand All @@ -466,6 +469,7 @@ uip_ds6_aaddr_add(uip_ipaddr_t *ipaddr)
uip_ipaddr_copy(&locaaddr->ipaddr, ipaddr);
return locaaddr;
}
#endif /* UIP_DS6_AADDR_NB */
return NULL;
}

Expand All @@ -483,11 +487,13 @@ uip_ds6_aaddr_rm(uip_ds6_aaddr_t *aaddr)
uip_ds6_aaddr_t *
uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr)
{
#if UIP_DS6_AADDR_NB
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_if.aaddr_list,
UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128,
(uip_ds6_element_t **)&locaaddr) == FOUND) {
return locaaddr;
}
#endif /* UIP_DS6_AADDR_NB */
return NULL;
}

Expand Down
6 changes: 6 additions & 0 deletions core/net/ipv6/uip-ds6.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,15 @@ typedef struct uip_ds6_netif {
uint32_t reachable_time; /* in msec */
uint32_t retrans_timer; /* in msec */
uint8_t maxdadns;
#if UIP_DS6_ADDR_NB
uip_ds6_addr_t addr_list[UIP_DS6_ADDR_NB];
#endif /* UIP_DS6_ADDR_NB */
#if UIP_DS6_AADDR_NB
uip_ds6_aaddr_t aaddr_list[UIP_DS6_AADDR_NB];
#endif /* UIP_DS6_AADDR_NB */
#if UIP_DS6_MADDR_NB
uip_ds6_maddr_t maddr_list[UIP_DS6_MADDR_NB];
#endif /* UIP_DS6_MADDR_NB */
} uip_ds6_netif_t;

/** \brief Generic type for a DS6, to use a common loop though all DS */
Expand Down
Loading

0 comments on commit fbd78a7

Please sign in to comment.