diff --git a/boards/arduino-atmega-common/include/periph_conf.h b/boards/arduino-atmega-common/include/periph_conf.h index 4a1681fde3..b3506efdcb 100644 --- a/boards/arduino-atmega-common/include/periph_conf.h +++ b/boards/arduino-atmega-common/include/periph_conf.h @@ -32,7 +32,7 @@ extern "C" { * @name Clock configuration * @{ */ -#define CLOCK_CORECLOCK (16000000L) +#define CLOCK_CORECLOCK (16000000UL) /** @} */ /** diff --git a/boards/calliope-mini/mini/mini.c b/boards/calliope-mini/mini/mini.c index ee07ac9c71..c4ba5aeb9e 100644 --- a/boards/calliope-mini/mini/mini.c +++ b/boards/calliope-mini/mini/mini.c @@ -39,8 +39,8 @@ /** * @brief The electrical number of rows and columns */ -#define ROWS_HW (3) -#define COLS_HW (9) +#define ROWS_HW (3U) +#define COLS_HW (9U) /** * @brief The refresh rate used for drawing the contents @@ -111,8 +111,8 @@ static void char2buf(char c, uint8_t *buf) const uint8_t *raw = mineplex_char(c); /* set each row */ - for (int row = 0; row < ROWS; row++) { - for (int col = 0; col < COLS; col++) { + for (unsigned row = 0; row < ROWS; row++) { + for (unsigned col = 0; col < COLS; col++) { buf[(row * COLS) + col] = (raw[row] & (1 << col)); } } @@ -127,9 +127,9 @@ static void char2buf(char c, uint8_t *buf) */ static void shift_next(uint8_t *cur, const uint8_t *next, uint32_t delay) { - for (int i = 0; i < COLS; i++) { - for (int r = 0; r < ROWS; r++) { - for (int c = 0; c < (COLS - 1); c++) { + for (unsigned i = 0; i < COLS; i++) { + for (unsigned r = 0; r < ROWS; r++) { + for (unsigned c = 0; c < (COLS - 1); c++) { cur[(r * COLS) + c] = cur[(r * COLS) + c + 1]; } cur[(r * COLS) + COLS - 1] = next[(r * COLS) + i]; @@ -152,8 +152,8 @@ static void refresh(void *arg, int channel) /* goto next row */ cur_row = ((++cur_row) < ROWS_HW) ? cur_row : 0; /* setup columns */ - int base = (COLS_HW * cur_row); - for (int i = 0; i < COLS_HW; i++) { + unsigned base = (COLS_HW * cur_row); + for (unsigned i = 0; i < COLS_HW; i++) { gpio_write(cols[i], !(framebuf[base + i])); } /* and finally enable the new row */ @@ -163,12 +163,12 @@ static void refresh(void *arg, int channel) void mini_matrix_init(void) { /* initialize rows */ - for (int i = 0; i < ROWS_HW; i++) { + for (unsigned i = 0; i < ROWS_HW; i++) { gpio_init(rows[i], GPIO_OUT); gpio_clear(rows[i]); } /* initialize columns */ - for (int i = 0; i < COLS_HW; i++) { + for (unsigned i = 0; i < COLS_HW; i++) { gpio_init(cols[i], GPIO_OUT); gpio_set(cols[i]); } @@ -195,9 +195,10 @@ void mini_matrix_off(uint8_t row, uint8_t col) framebuf[pixmap[row][col]] = 0x00; } -void mini_matrix_set_raw(const uint8_t *buf) { - for (int row = 0; row < ROWS; row++) { - for (int col = 0; col < COLS; col++) { +void mini_matrix_set_raw(const uint8_t *buf) +{ + for (unsigned row = 0; row < ROWS; row++) { + for (unsigned col = 0; col < COLS; col++) { framebuf[pixmap[row][col]] = buf[(row * COLS) + col]; } } diff --git a/boards/microbit/microbit/microbit.c b/boards/microbit/microbit/microbit.c index 2669df6694..94d0dc8b3b 100644 --- a/boards/microbit/microbit/microbit.c +++ b/boards/microbit/microbit/microbit.c @@ -39,8 +39,8 @@ /** * @brief The electrical number of rows and columns */ -#define ROWS_HW (3) -#define COLS_HW (9) +#define ROWS_HW (3U) +#define COLS_HW (9U) /** * @brief The refresh rate used for drawing the contents @@ -111,8 +111,8 @@ static void char2buf(char c, uint8_t *buf) const uint8_t *raw = mineplex_char(c); /* set each row */ - for (int row = 0; row < ROWS; row++) { - for (int col = 0; col < COLS; col++) { + for (unsigned row = 0; row < ROWS; row++) { + for (unsigned col = 0; col < COLS; col++) { buf[(row * COLS) + col] = (raw[row] & (1 << col)); } } @@ -127,9 +127,9 @@ static void char2buf(char c, uint8_t *buf) */ static void shift_next(uint8_t *cur, const uint8_t *next, uint32_t delay) { - for (int i = 0; i < COLS; i++) { - for (int r = 0; r < ROWS; r++) { - for (int c = 0; c < (COLS - 1); c++) { + for (unsigned i = 0; i < COLS; i++) { + for (unsigned r = 0; r < ROWS; r++) { + for (unsigned c = 0; c < (COLS - 1); c++) { cur[(r * COLS) + c] = cur[(r * COLS) + c + 1]; } cur[(r * COLS) + COLS - 1] = next[(r * COLS) + i]; @@ -152,8 +152,8 @@ static void refresh(void *arg, int channel) /* goto next row */ cur_row = ((++cur_row) < ROWS_HW) ? cur_row : 0; /* setup columns */ - int base = (COLS_HW * cur_row); - for (int i = 0; i < COLS_HW; i++) { + unsigned base = (COLS_HW * cur_row); + for (unsigned i = 0; i < COLS_HW; i++) { gpio_write(cols[i], !(framebuf[base + i])); } /* and finally enable the new row */ @@ -163,12 +163,12 @@ static void refresh(void *arg, int channel) void microbit_matrix_init(void) { /* initialize rows */ - for (int i = 0; i < ROWS_HW; i++) { + for (unsigned i = 0; i < ROWS_HW; i++) { gpio_init(rows[i], GPIO_OUT); gpio_clear(rows[i]); } /* initialize columns */ - for (int i = 0; i < COLS_HW; i++) { + for (unsigned i = 0; i < COLS_HW; i++) { gpio_init(cols[i], GPIO_OUT); gpio_set(cols[i]); } @@ -195,9 +195,10 @@ void microbit_matrix_off(uint8_t row, uint8_t col) framebuf[pixmap[row][col]] = 0x00; } -void microbit_matrix_set_raw(const uint8_t *buf) { - for (int row = 0; row < ROWS; row++) { - for (int col = 0; col < COLS; col++) { +void microbit_matrix_set_raw(const uint8_t *buf) +{ + for (unsigned row = 0; row < ROWS; row++) { + for (unsigned col = 0; col < COLS; col++) { framebuf[pixmap[row][col]] = buf[(row * COLS) + col]; } } diff --git a/boards/msb-430-common/board_init.c b/boards/msb-430-common/board_init.c index 245907d2cc..ddad1485de 100644 --- a/boards/msb-430-common/board_init.c +++ b/boards/msb-430-common/board_init.c @@ -133,7 +133,7 @@ void msp430_init_dco(void) BCSCTL2 = SELM_2 + SELS; /* MCLK und SMCLK = XT2 (safe) */ #else - int delta = __msp430_cpu_speed >> 12; + unsigned int delta = __msp430_cpu_speed >> 12; unsigned int oldcapture = 0; unsigned int i; diff --git a/boards/waspmote-pro/include/periph_conf.h b/boards/waspmote-pro/include/periph_conf.h index dd97b1ecc3..7b9ee15c18 100644 --- a/boards/waspmote-pro/include/periph_conf.h +++ b/boards/waspmote-pro/include/periph_conf.h @@ -29,7 +29,7 @@ extern "C" { * @name Clock configuration * @{ */ -#define CLOCK_CORECLOCK (14745600L) +#define CLOCK_CORECLOCK (14745600UL) /** @} */ /** diff --git a/cpu/atmega_common/periph/i2c.c b/cpu/atmega_common/periph/i2c.c index a01e1c2148..00d504cc26 100644 --- a/cpu/atmega_common/periph/i2c.c +++ b/cpu/atmega_common/periph/i2c.c @@ -51,7 +51,7 @@ static mutex_t lock = MUTEX_INIT; int i2c_init_master(i2c_t dev, i2c_speed_t speed) { /* TWI Bit Rate Register - division factor for the bit rate generator */ - uint8_t twibrr; + unsigned long twibrr; /* TWI Prescaler Bits - default 0 */ uint8_t twipb = 0; @@ -64,39 +64,41 @@ int i2c_init_master(i2c_t dev, i2c_speed_t speed) switch (speed) { case I2C_SPEED_LOW: - if (CLOCK_CORECLOCK > 20000000U || CLOCK_CORECLOCK < 1000000U) { + if ((CLOCK_CORECLOCK > 20000000UL) + || (CLOCK_CORECLOCK < 1000000UL)) { return -2; } - twibrr = ((CLOCK_CORECLOCK / 10000) - 16) / (2 * 4); /* CLK Prescaler 4 */ + twibrr = ((CLOCK_CORECLOCK / 10000UL) - 16) / (2 * 4); /* CLK Prescaler 4 */ twipb = 1; break; case I2C_SPEED_NORMAL: - if (CLOCK_CORECLOCK > 50000000U || CLOCK_CORECLOCK < 2000000U) { + if ((CLOCK_CORECLOCK > 50000000UL) + || (CLOCK_CORECLOCK < 2000000UL)) { return -2; } - twibrr = ((CLOCK_CORECLOCK / 100000) - 16) / 2; + twibrr = ((CLOCK_CORECLOCK / 100000UL) - 16) / 2; break; case I2C_SPEED_FAST: - if (CLOCK_CORECLOCK < 7500000U) { + if (CLOCK_CORECLOCK < 7500000UL) { return -2; } - twibrr = ((CLOCK_CORECLOCK / 400000) - 16) / 2; + twibrr = ((CLOCK_CORECLOCK / 400000UL) - 16) / 2; break; case I2C_SPEED_FAST_PLUS: - if (CLOCK_CORECLOCK < 18000000U) { + if (CLOCK_CORECLOCK < 18000000UL) { return -2; } - twibrr = ((CLOCK_CORECLOCK / 1000000) - 16) / 2; + twibrr = ((CLOCK_CORECLOCK / 1000000UL) - 16) / 2; break; case I2C_SPEED_HIGH: - if (CLOCK_CORECLOCK < 62000000U) { + if (CLOCK_CORECLOCK < 62000000UL) { return -2; } - twibrr = ((CLOCK_CORECLOCK / 3400000) - 16) / 2; + twibrr = ((CLOCK_CORECLOCK / 3400000UL) - 16) / 2; break; default: @@ -112,9 +114,9 @@ int i2c_init_master(i2c_t dev, i2c_speed_t speed) /* disable device */ TWCR &= ~(1 << TWEN); /* configure I2C clock */ - TWBR = twibrr; // Set TWI Bit Rate Register - TWSR &= ~(0x03); // Reset TWI Prescaler Bits - TWSR |= twipb; // Set TWI Prescaler Bits + TWBR = (uint8_t)twibrr; /* Set TWI Bit Rate Register */ + TWSR &= ~(0x03); /* Reset TWI Prescaler Bits */ + TWSR |= twipb; /* Set TWI Prescaler Bits */ /* enable device */ TWCR |= (1 << TWEN); diff --git a/cpu/cc2538/include/cc2538_sys_ctrl.h b/cpu/cc2538/include/cc2538_sys_ctrl.h index 65dfc659f5..a7b16d97f6 100644 --- a/cpu/cc2538/include/cc2538_sys_ctrl.h +++ b/cpu/cc2538/include/cc2538_sys_ctrl.h @@ -151,9 +151,10 @@ typedef struct { /** * @brief Compute the current system clock frequency based on the SYS_CTRL register states */ -#define sys_clock_freq() ((SYS_CTRL->cc2538_sys_ctrl_clk_ctrl.CLOCK_CTRLbits.OSC ? \ - RCOSC16M_FREQ : XOSC32M_FREQ) >> \ - SYS_CTRL->cc2538_sys_ctrl_clk_ctrl.CLOCK_CTRLbits.SYS_DIV ) +#define sys_clock_freq() ((uint32_t)\ + (SYS_CTRL->cc2538_sys_ctrl_clk_ctrl.CLOCK_CTRLbits.OSC ? \ + RCOSC16M_FREQ : XOSC32M_FREQ) >> \ + SYS_CTRL->cc2538_sys_ctrl_clk_ctrl.CLOCK_CTRLbits.SYS_DIV) #ifdef __cplusplus } /* end extern "C" */ diff --git a/cpu/cc2538/periph/timer.c b/cpu/cc2538/periph/timer.c index 1161191b76..c36d0f9999 100644 --- a/cpu/cc2538/periph/timer.c +++ b/cpu/cc2538/periph/timer.c @@ -173,7 +173,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) { DEBUG("%s(%u, %u, %u)\n", __FUNCTION__, tim, channel, value); - if ((tim >= TIMER_NUMOF) || (channel >= timer_config[tim].chn) ) { + if ((tim >= TIMER_NUMOF) || (channel >= (int)timer_config[tim].chn) ) { return -1; } /* clear any pending match interrupts */ @@ -194,7 +194,7 @@ int timer_clear(tim_t tim, int channel) { DEBUG("%s(%u, %u)\n", __FUNCTION__, tim, channel); - if ( (tim >= TIMER_NUMOF) || (channel >= timer_config[tim].chn) ) { + if ( (tim >= TIMER_NUMOF) || (channel >= (int)timer_config[tim].chn) ) { return -1; } /* clear interupt flags */ @@ -259,7 +259,7 @@ static void irq_handler(tim_t tim, int channel) { DEBUG("%s(%u,%d)\n", __FUNCTION__, tim, channel); assert(tim < TIMER_NUMOF); - assert(channel < timer_config[tim].chn); + assert(channel < (int)timer_config[tim].chn); uint32_t mis; /* Latch the active interrupt flags */ diff --git a/cpu/ezr32wg/periph/gpio.c b/cpu/ezr32wg/periph/gpio.c index 2ab3c3e62c..2cabdb85f8 100644 --- a/cpu/ezr32wg/periph/gpio.c +++ b/cpu/ezr32wg/periph/gpio.c @@ -151,7 +151,7 @@ void gpio_write(gpio_t pin, int value) */ void isr_gpio_even(void) { - for (int i = 0; i < NUMOF_IRQS; i++) { + for (unsigned i = 0; i < NUMOF_IRQS; i++) { if (GPIO->IF & (1 << i)) { isr_ctx[i].cb(isr_ctx[i].arg); GPIO->IFC = (1 << i); diff --git a/cpu/ezr32wg/periph/timer.c b/cpu/ezr32wg/periph/timer.c index 1f7afdfa6f..8d9c681dee 100644 --- a/cpu/ezr32wg/periph/timer.c +++ b/cpu/ezr32wg/periph/timer.c @@ -87,7 +87,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) { TIMER_TypeDef *tim; - if (channel < 0 || channel >= CC_CHANNELS) { + if ((channel < 0) || (channel >= (int)CC_CHANNELS)) { return -1; } @@ -99,7 +99,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) int timer_clear(tim_t dev, int channel) { - if (channel < 0 || channel >= CC_CHANNELS) { + if ((channel < 0) || (channel >= (int)CC_CHANNELS)) { return -1; } @@ -131,7 +131,7 @@ void timer_reset(tim_t dev) void TIMER_0_ISR(void) { TIMER_TypeDef *tim = timer_config[0].timer; - for (int i = 0; i < CC_CHANNELS; i++) { + for (unsigned i = 0; i < CC_CHANNELS; i++) { if (tim->IF & (TIMER_IF_CC0 << i)) { tim->CC[i].CTRL = _TIMER_CC_CTRL_MODE_OFF; tim->IFC = (TIMER_IFC_CC0 << i); diff --git a/cpu/msp430fxyz/periph/gpio.c b/cpu/msp430fxyz/periph/gpio.c index c9de942d80..e6682eb950 100644 --- a/cpu/msp430fxyz/periph/gpio.c +++ b/cpu/msp430fxyz/periph/gpio.c @@ -205,7 +205,7 @@ void gpio_write(gpio_t pin, int value) static inline void isr_handler(msp_port_isr_t *port, int ctx) { - for (int i = 0; i < PINS_PER_PORT; i++) { + for (unsigned i = 0; i < PINS_PER_PORT; i++) { if ((port->IE & (1 << i)) && (port->IFG & (1 << i))) { port->IFG &= ~(1 << i); isr_ctx[i + ctx].cb(isr_ctx[i + ctx].arg); diff --git a/cpu/nrf5x_common/periph/flashpage.c b/cpu/nrf5x_common/periph/flashpage.c index 4dcda69007..3a29c89b05 100644 --- a/cpu/nrf5x_common/periph/flashpage.c +++ b/cpu/nrf5x_common/periph/flashpage.c @@ -25,7 +25,7 @@ void flashpage_write(int page, void *data) { - assert(page < FLASHPAGE_NUMOF); + assert(page < (int)FLASHPAGE_NUMOF); uint32_t *page_addr = (uint32_t *)flashpage_addr(page); uint32_t *data_addr = (uint32_t *)data; diff --git a/cpu/nrf5x_common/radio/nrfmin/nrfmin.c b/cpu/nrf5x_common/radio/nrfmin/nrfmin.c index d523611acf..c6f3824027 100644 --- a/cpu/nrf5x_common/radio/nrfmin/nrfmin.c +++ b/cpu/nrf5x_common/radio/nrfmin/nrfmin.c @@ -362,7 +362,7 @@ static int nrfmin_recv(netdev_t *dev, void *buf, size_t len, void *info) assert(state != STATE_OFF); - int pktlen = (int)rx_buf.pkt.hdr.len; + unsigned pktlen = rx_buf.pkt.hdr.len; /* check if packet data is readable */ if (rx_lock || (pktlen == 0)) { @@ -400,7 +400,7 @@ static int nrfmin_init(netdev_t *dev) /* initialize our own address from the CPU ID */ my_addr = 0; cpuid_get(cpuid); - for (int i = 0; i < CPUID_LEN; i++) { + for (unsigned i = 0; i < CPUID_LEN; i++) { my_addr ^= cpuid[i] << (8 * (i & 0x01)); } diff --git a/cpu/sam0_common/periph/gpio.c b/cpu/sam0_common/periph/gpio.c index 5ec3c4dbcc..62be9b8e4a 100644 --- a/cpu/sam0_common/periph/gpio.c +++ b/cpu/sam0_common/periph/gpio.c @@ -222,7 +222,7 @@ void gpio_write(gpio_t pin, int value) void isr_eic(void) { - for (int i = 0; i < NUMOF_IRQS; i++) { + for (unsigned i = 0; i < NUMOF_IRQS; i++) { if (EIC->INTFLAG.reg & (1 << i)) { EIC->INTFLAG.reg = (1 << i); gpio_config[i].cb(gpio_config[i].arg); diff --git a/cpu/sam3/periph/gpio.c b/cpu/sam3/periph/gpio.c index 2bc7e0efe9..c096642d6d 100644 --- a/cpu/sam3/periph/gpio.c +++ b/cpu/sam3/periph/gpio.c @@ -106,7 +106,7 @@ static inline int _pin_num(gpio_t pin) /** * @brief Get context for a specific pin */ -static inline int _ctx(int port, int pin) +static inline unsigned _ctx(int port, int pin) { return (exti_map[(port * 4) + (pin >> 3)] >> ((pin & 0x7) * 4)) & 0xf; } @@ -125,7 +125,7 @@ static void _write_map(int port, int pin, int ctx) */ static int _get_free_ctx(void) { - for (int i = 0; i < CTX_NUMOF; i++) { + for (unsigned i = 0; i < CTX_NUMOF; i++) { if (exti_ctx[i].cb == NULL) { return i; } @@ -138,7 +138,7 @@ static int _get_free_ctx(void) */ static void _ctx_clear(int port, int pin) { - int ctx = _ctx(port, pin); + unsigned ctx = _ctx(port, pin); if (ctx < CTX_NUMOF) { exti_ctx[ctx].cb = NULL; _write_map(port, pin, CTX_NUMOF); diff --git a/cpu/samd21/periph/pwm.c b/cpu/samd21/periph/pwm.c index 68fb66e51e..02434fddd1 100644 --- a/cpu/samd21/periph/pwm.c +++ b/cpu/samd21/periph/pwm.c @@ -114,7 +114,7 @@ uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res) f_real = (CLOCK_CORECLOCK / (scale * res)); /* configure the used pins */ - for (int i = 0; i < PWM_MAX_CHANNELS; i++) { + for (unsigned i = 0; i < PWM_MAX_CHANNELS; i++) { if (pwm_config[dev].chan[i].pin != GPIO_UNDEF) { gpio_init(pwm_config[dev].chan[i].pin, GPIO_OUT); gpio_init_mux(pwm_config[dev].chan[i].pin, pwm_config[dev].chan[i].mux); diff --git a/cpu/stm32_common/periph/flashpage.c b/cpu/stm32_common/periph/flashpage.c index 252a405533..35ae45ff46 100644 --- a/cpu/stm32_common/periph/flashpage.c +++ b/cpu/stm32_common/periph/flashpage.c @@ -29,7 +29,7 @@ void flashpage_write(int page, void *data) { - assert(page < FLASHPAGE_NUMOF); + assert(page < (int)FLASHPAGE_NUMOF); uint16_t *page_addr = flashpage_addr(page); uint16_t *data_addr = (uint16_t *)data; diff --git a/cpu/stm32_common/periph/pwm.c b/cpu/stm32_common/periph/pwm.c index d7056f6209..7d1a358e36 100644 --- a/cpu/stm32_common/periph/pwm.c +++ b/cpu/stm32_common/periph/pwm.c @@ -52,7 +52,7 @@ uint32_t pwm_init(pwm_t pwm, pwm_mode_t mode, uint32_t freq, uint16_t res) /* reset configuration and CC channels */ dev(pwm)->CR1 = 0; dev(pwm)->CR2 = 0; - for (int i = 0; i < TIMER_CHAN; i++) { + for (unsigned i = 0; i < TIMER_CHAN; ++i) { dev(pwm)->CCR[i] = 0; } diff --git a/cpu/stm32_common/periph/timer.c b/cpu/stm32_common/periph/timer.c index d9ddc59cc4..562ba99efc 100644 --- a/cpu/stm32_common/periph/timer.c +++ b/cpu/stm32_common/periph/timer.c @@ -70,7 +70,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) int timer_set_absolute(tim_t tim, int channel, unsigned int value) { - if (channel >= TIMER_CHAN) { + if (channel >= (int)TIMER_CHAN) { return -1; } @@ -83,7 +83,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) int timer_clear(tim_t tim, int channel) { - if (channel >= TIMER_CHAN) { + if (channel >= (int)TIMER_CHAN) { return -1; } diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index 2b4802772f..6fa3dc62ba 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -147,7 +147,7 @@ size_t cc2420_tx_prepare(cc2420_t *dev, const struct iovec *data, unsigned count /* push packet length to TX FIFO */ cc2420_fifo_write(dev, (uint8_t *)&pkt_len, 1); /* push packet to TX FIFO */ - for (int i = 0; i < count; i++) { + for (unsigned i = 0; i < count; i++) { cc2420_fifo_write(dev, (uint8_t *)data[i].iov_base, data[i].iov_len); } DEBUG("cc2420: tx_prep: loaded %i byte into the TX FIFO\n", (int)pkt_len); diff --git a/drivers/ethos/ethos.c b/drivers/ethos/ethos.c index 0a23d6445e..1d7c816144 100644 --- a/drivers/ethos/ethos.c +++ b/drivers/ethos/ethos.c @@ -300,7 +300,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void* info) ethos_t * dev = (ethos_t *) netdev; if (buf) { - if (len < (int)dev->last_framesize) { + if (len < dev->last_framesize) { DEBUG("ethos _recv(): receive buffer too small.\n"); return -1; } @@ -308,7 +308,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void* info) len = dev->last_framesize; dev->last_framesize = 0; - if ((tsrb_get(&dev->inbuf, buf, len) != len)) { + if ((tsrb_get(&dev->inbuf, buf, len) != (int)len)) { DEBUG("ethos _recv(): inbuf doesn't contain enough bytes.\n"); return -1; } diff --git a/drivers/pcd8544/pcd8544.c b/drivers/pcd8544/pcd8544.c index a2508261cb..e018df3226 100644 --- a/drivers/pcd8544/pcd8544.c +++ b/drivers/pcd8544/pcd8544.c @@ -314,7 +314,7 @@ void pcd8544_write_img(const pcd8544_t *dev, const char img[]) _set_x(dev, 0); _set_y(dev, 0); /* write image data to display */ - for (int i = 0; i < (PCD8544_RES_X * PCD8544_RES_Y / 8); i++) { + for (unsigned i = 0; i < (PCD8544_RES_X * PCD8544_RES_Y / 8); i++) { _write(dev, MODE_DTA, img[i]); } done(dev); @@ -331,7 +331,7 @@ void pcd8544_write_c(const pcd8544_t *dev, uint8_t x, uint8_t y, char c) _set_x(dev, x * CHAR_WIDTH); _set_y(dev, y); /* write char */ - for (int i = 0; i < CHAR_WIDTH - 1; i++) { + for (unsigned i = 0; i < CHAR_WIDTH - 1; i++) { _write(dev, MODE_DTA, _ascii[c - ASCII_MIN][i]); } _write(dev, MODE_DTA, 0x00); @@ -350,7 +350,7 @@ void pcd8544_clear(const pcd8544_t *dev) lock(dev); _set_x(dev, 0); _set_y(dev, 0); - for (int i = 0; i < PCD8544_RES_X * PCD8544_ROWS; i++) { + for (unsigned i = 0; i < PCD8544_RES_X * PCD8544_ROWS; i++) { _write(dev, MODE_DTA, 0x00); } done(dev); diff --git a/drivers/periph_common/flashpage.c b/drivers/periph_common/flashpage.c index 11da974482..5313fe7ac9 100644 --- a/drivers/periph_common/flashpage.c +++ b/drivers/periph_common/flashpage.c @@ -30,14 +30,14 @@ void flashpage_read(int page, void *data) { - assert(page < FLASHPAGE_NUMOF); + assert(page < (int)FLASHPAGE_NUMOF); memcpy(data, flashpage_addr(page), FLASHPAGE_SIZE); } int flashpage_verify(int page, void *data) { - assert(page < FLASHPAGE_NUMOF); + assert(page < (int)FLASHPAGE_NUMOF); if (memcmp(flashpage_addr(page), data, FLASHPAGE_SIZE) == 0) { return FLASHPAGE_OK; diff --git a/drivers/pn532/pn532.c b/drivers/pn532/pn532.c index 7039691ba5..a78df2ac93 100644 --- a/drivers/pn532/pn532.c +++ b/drivers/pn532/pn532.c @@ -288,7 +288,7 @@ static int read_command(const pn532_t *dev, char *buff, unsigned len, int expect * * Note that all offsets are shifted by one since the first byte is always * 0x01. */ - if ((r < len) || (buff[1] != 0x00) || (buff[2] != 0x00) || (buff[3] != 0xFF)) { + if ((r < (int)len) || (buff[1] != 0x00) || (buff[2] != 0x00) || (buff[3] != 0xFF)) { return -r; } @@ -423,7 +423,7 @@ static int _rf_configure(pn532_t *dev, char *buff, unsigned cfg_item, char *conf { buff[BUFF_CMD_START ] = CMD_RF_CONFIG; buff[BUFF_DATA_START] = cfg_item; - for (int i = 1; i <= cfg_len; i++) { + for (unsigned i = 1; i <= cfg_len; i++) { buff[BUFF_DATA_START + i] = *config++; } @@ -587,7 +587,7 @@ static int pn532_mifare_read(pn532_t *dev, char *odata, nfc_iso14443a_t *card, buff[BUFF_DATA_START + 1] = MIFARE_CMD_READ; buff[BUFF_DATA_START + 2] = block; /* current block */ - if (send_rcv(dev, buff, 3, len + 1) == len + 1) { + if (send_rcv(dev, buff, 3, len + 1) == (int)(len + 1)) { memcpy(odata, &buff[1], len); ret = 0; } @@ -617,18 +617,14 @@ static int send_rcv_apdu(pn532_t *dev, char *buff, unsigned slen, unsigned rlen) int ret; rlen += 3; - if (rlen >= RAPDU_MAX_DATA_LEN) { - return -1; - - } - else if (slen >= CAPDU_MAX_DATA_LEN) { + if ((rlen >= RAPDU_MAX_DATA_LEN) || (slen >= CAPDU_MAX_DATA_LEN)) { return -1; } ret = send_rcv(dev, buff, slen, rlen); - if (ret == rlen && buff[0] == 0x00) { + if ((ret == (int)rlen) && (buff[0] == 0x00)) { ret = (buff[rlen - 2] << 8) | buff[rlen - 1]; - if (ret == 0x9000) { + if (ret == (int)0x9000) { ret = 0; } } diff --git a/drivers/sdcard_spi/sdcard_spi.c b/drivers/sdcard_spi/sdcard_spi.c index 82a6084583..f661b5a239 100644 --- a/drivers/sdcard_spi/sdcard_spi.c +++ b/drivers/sdcard_spi/sdcard_spi.c @@ -457,7 +457,7 @@ char sdcard_spi_send_cmd(sdcard_spi_t *card, char sd_cmd_idx, uint32_t argument, } DEBUG("CMD%02d echo: ", sd_cmd_idx); - for (int i = 0; i < sizeof(echo); i++) { + for (unsigned i = 0; i < sizeof(echo); i++) { DEBUG("0x%02X ", echo[i]); } DEBUG("\n"); @@ -843,7 +843,7 @@ sd_rw_response_t _read_cid(sdcard_spi_t *card) DEBUG("_read_cid: _read_blocks: nbl=%d state=%d\n", nbl, state); DEBUG("_read_cid: cid_raw_data: "); - for (int i = 0; i < sizeof(cid_raw_data); i++) { + for (unsigned i = 0; i < sizeof(cid_raw_data); i++) { DEBUG("0x%02X ", cid_raw_data[i]); } DEBUG("\n"); @@ -879,7 +879,7 @@ sd_rw_response_t _read_csd(sdcard_spi_t *card) DEBUG("_read_csd: _read_blocks: read_resu=%d state=%d\n", read_resu, state); DEBUG("_read_csd: raw data: "); - for (int i = 0; i < sizeof(c); i++) { + for (unsigned i = 0; i < sizeof(c); i++) { DEBUG("0x%02X ", c[i]); } DEBUG("\n"); @@ -974,7 +974,7 @@ sd_rw_response_t sdcard_spi_read_sds(sdcard_spi_t *card, sd_status_t *sd_status) DEBUG("sdcard_spi_read_sds: _read_blocks: nbl=%d state=%d\n", nbl, state); DEBUG("sdcard_spi_read_sds: sds_raw_data: "); - for (int i = 0; i < sizeof(sds_raw_data); i++) { + for (unsigned i = 0; i < sizeof(sds_raw_data); i++) { DEBUG("0x%02X ", sds_raw_data[i]); } DEBUG("\n"); diff --git a/pkg/fatfs/fatfs_diskio/sdcard_spi/sdcard_spi_diskio.c b/pkg/fatfs/fatfs_diskio/sdcard_spi/sdcard_spi_diskio.c index a240c6b9b9..08a484dc28 100644 --- a/pkg/fatfs/fatfs_diskio/sdcard_spi/sdcard_spi_diskio.c +++ b/pkg/fatfs/fatfs_diskio/sdcard_spi/sdcard_spi_diskio.c @@ -38,7 +38,7 @@ extern sdcard_spi_t sdcard_spi_devs[NUM_OF_SD_CARDS]; static inline sdcard_spi_t *get_sd_card(int idx) { - if (idx < NUM_OF_SD_CARDS) { + if (idx < (int)NUM_OF_SD_CARDS) { return &(sdcard_spi_devs[idx]); } @@ -108,8 +108,10 @@ DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count) if ((card != NULL) && card->init_done) { sd_rw_response_t state; - if (count != sdcard_spi_read_blocks(card, sector, (char *)buff, - SD_HC_BLOCK_SIZE, count, &state)) { + if ((int)count != sdcard_spi_read_blocks(card, sector, + (char *)buff, + SD_HC_BLOCK_SIZE, + count, &state)) { printf("[ERROR] disk_read: sdcard_spi_read_blocks: %d\n", state); return RES_NOTRDY; } @@ -136,8 +138,10 @@ DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count) if ((card != NULL) && card->init_done) { sd_rw_response_t state; - if (count != sdcard_spi_write_blocks(card, sector, (char *)buff, - SD_HC_BLOCK_SIZE, count, &state)) { + if ((int)count != sdcard_spi_write_blocks(card, sector, + (char *)buff, + SD_HC_BLOCK_SIZE, + count, &state)) { printf("[ERROR] disk_write: sdcard_spi_write_blocks: %d\n", state); return RES_NOTRDY; } diff --git a/pkg/lwip/contrib/lwip.c b/pkg/lwip/contrib/lwip.c index 6c3d5819d5..8adf07bb72 100644 --- a/pkg/lwip/contrib/lwip.c +++ b/pkg/lwip/contrib/lwip.c @@ -71,7 +71,7 @@ void lwip_bootstrap(void) /* TODO: do for every eligable netdev */ #ifdef LWIP_NETIF_NUMOF #ifdef MODULE_NETDEV_TAP - for (int i = 0; i < LWIP_NETIF_NUMOF; i++) { + for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) { netdev_tap_setup(&netdev_taps[i], &netdev_tap_params[i]); if (netif_add(&netif[i], &netdev_taps[i], lwip_netdev_init, tcpip_input) == NULL) { @@ -80,7 +80,7 @@ void lwip_bootstrap(void) } } #elif defined(MODULE_MRF24J40) - for (int i = 0; i < LWIP_NETIF_NUMOF; i++) { + for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) { mrf24j40_setup(&mrf24j40_devs[i], &mrf24j40_params[i]); if (netif_add(&netif[i], &mrf24j40_devs[i], lwip_netdev_init, tcpip_6lowpan_input) == NULL) { @@ -89,7 +89,7 @@ void lwip_bootstrap(void) } } #elif defined(MODULE_AT86RF2XX) - for (int i = 0; i < LWIP_NETIF_NUMOF; i++) { + for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) { at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]); if (netif_add(&netif[i], &at86rf2xx_devs[i], lwip_netdev_init, tcpip_6lowpan_input) == NULL) { diff --git a/sys/net/crosslayer/inet_csum/inet_csum.c b/sys/net/crosslayer/inet_csum/inet_csum.c index da7821a274..c9cd7c7e78 100644 --- a/sys/net/crosslayer/inet_csum/inet_csum.c +++ b/sys/net/crosslayer/inet_csum/inet_csum.c @@ -44,7 +44,7 @@ uint16_t inet_csum_slice(uint16_t sum, const uint8_t *buf, uint16_t len, size_t accum_len++; } - for (int i = 0; i < (len >> 1); buf += 2, i++) { + for (unsigned i = 0; i < (len >> 1); buf += 2, i++) { csum += (uint16_t)(*buf << 8) + *(buf + 1); /* group bytes by 16-byte words */ /* and add them */ } diff --git a/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c b/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c index 5059dbe607..6cf78233db 100644 --- a/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c +++ b/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c @@ -722,7 +722,7 @@ tftp_state _tftp_state_processes(tftp_context_t *ctxt, msg_t *m) _tftp_send_dack(ctxt, outbuf, TO_ACK); /* check if the data transfer has finished */ - if (proc < ctxt->block_size) { + if (proc < (int)ctxt->block_size) { DEBUG("tftp: transfer finished\n"); if (ctxt->stop_cb) { diff --git a/sys/net/gnrc/link_layer/lwmac/lwmac.c b/sys/net/gnrc/link_layer/lwmac/lwmac.c index 5e821c976c..be9682536d 100644 --- a/sys/net/gnrc/link_layer/lwmac/lwmac.c +++ b/sys/net/gnrc/link_layer/lwmac/lwmac.c @@ -202,7 +202,7 @@ static gnrc_mac_tx_neighbor_t *_next_tx_neighbor(gnrc_netif_t *netif) uint32_t phase_nearest = GNRC_LWMAC_PHASE_MAX; - for (int i = 0; i < GNRC_MAC_NEIGHBOR_COUNT; i++) { + for (unsigned i = 0; i < GNRC_MAC_NEIGHBOR_COUNT; i++) { if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[i].queue) > 0) { /* Unknown destinations are initialized with their phase at the end * of the local interval, so known destinations that still wakeup @@ -210,9 +210,9 @@ static gnrc_mac_tx_neighbor_t *_next_tx_neighbor(gnrc_netif_t *netif) uint32_t phase_check = _gnrc_lwmac_ticks_until_phase(netif->mac.tx.neighbors[i].phase); if (phase_check <= phase_nearest) { - next = i; + next = (int)i; phase_nearest = phase_check; - DEBUG("[LWMAC-int] Advancing queue #%d\n", i); + DEBUG("[LWMAC-int] Advancing queue #%u\n", i); } } } @@ -392,7 +392,7 @@ static void _sleep_management(gnrc_netif_t *netif) /* Offset in microseconds when the earliest (phase) destination * node wakes up that we have packets for. */ - int time_until_tx = RTT_TICKS_TO_US(_gnrc_lwmac_ticks_until_phase(neighbour->phase)); + uint32_t time_until_tx = RTT_TICKS_TO_US(_gnrc_lwmac_ticks_until_phase(neighbour->phase)); /* If there's not enough time to prepare a WR to catch the phase * postpone to next interval */ diff --git a/tests/driver_sdcard_spi/main.c b/tests/driver_sdcard_spi/main.c index edab82a8b2..4d80b05d1f 100644 --- a/tests/driver_sdcard_spi/main.c +++ b/tests/driver_sdcard_spi/main.c @@ -278,8 +278,8 @@ static int _write(int argc, char **argv) /* copy data to a full-block-sized buffer an fill remaining block space according to -r param*/ char buffer[SD_HC_BLOCK_SIZE]; - for (int i = 0; i < sizeof(buffer); i++) { - if (repeat_data || i < size) { + for (unsigned i = 0; i < sizeof(buffer); i++) { + if (repeat_data || ((int)i < size)) { buffer[i] = data[i % size]; } else { diff --git a/tests/gnrc_sock_ip/stack.c b/tests/gnrc_sock_ip/stack.c index 6219679829..0a77fc22fc 100644 --- a/tests/gnrc_sock_ip/stack.c +++ b/tests/gnrc_sock_ip/stack.c @@ -119,7 +119,7 @@ bool _check_packet(const ipv6_addr_t *src, const ipv6_addr_t *dst, return _res(pkt, false); } netif_hdr = pkt->data; - if (netif_hdr->if_pid != netif) { + if (netif_hdr->if_pid != (int)netif) { return _res(pkt, false); } ipv6 = pkt->next; diff --git a/tests/gnrc_sock_udp/stack.c b/tests/gnrc_sock_udp/stack.c index f9a556abcc..00134a3733 100644 --- a/tests/gnrc_sock_udp/stack.c +++ b/tests/gnrc_sock_udp/stack.c @@ -141,7 +141,7 @@ bool _check_packet(const ipv6_addr_t *src, const ipv6_addr_t *dst, return _res(pkt, false); } netif_hdr = pkt->data; - if (netif_hdr->if_pid != iface) { + if (netif_hdr->if_pid != (int)iface) { return _res(pkt, false); } ipv6 = pkt->next; diff --git a/tests/msg_avail/main.c b/tests/msg_avail/main.c index ce8669a35b..a01291f220 100644 --- a/tests/msg_avail/main.c +++ b/tests/msg_avail/main.c @@ -52,7 +52,8 @@ int main(void) msg_t msg; msg_receive(&msg); LOG_INFO("- got msg: %d\n", (MSG_QUEUE_LENGTH - idx)); - if (msg.type != (MSG_QUEUE_LENGTH - idx) || msg_avail() != idx - 1) { + if ((int)msg.type != (MSG_QUEUE_LENGTH - idx) + || msg_avail() != idx - 1) { puts("[FAILED]"); return 1; } diff --git a/tests/periph_adc/main.c b/tests/periph_adc/main.c index ea784ffa14..e11b7150aa 100644 --- a/tests/periph_adc/main.c +++ b/tests/periph_adc/main.c @@ -39,22 +39,22 @@ int main(void) "a 10-bit resolution and print the sampled results to STDIO\n\n"); /* initialize all available ADC lines */ - for (int i = 0; i < ADC_NUMOF; i++) { + for (unsigned i = 0; i < ADC_NUMOF; i++) { if (adc_init(ADC_LINE(i)) < 0) { - printf("Initialization of ADC_LINE(%i) failed\n", i); + printf("Initialization of ADC_LINE(%u) failed\n", i); return 1; } else { - printf("Successfully initialized ADC_LINE(%i)\n", i); + printf("Successfully initialized ADC_LINE(%u)\n", i); } } while (1) { - for (int i = 0; i < ADC_NUMOF; i++) { + for (unsigned i = 0; i < ADC_NUMOF; i++) { sample = adc_sample(ADC_LINE(i), RES); if (sample < 0) { - printf("ADC_LINE(%i): 10-bit resolution not applicable\n", i); + printf("ADC_LINE(%u): 10-bit resolution not applicable\n", i); } else { - printf("ADC_LINE(%i): %i\n", i, sample); + printf("ADC_LINE(%u): %i\n", i, sample); } } xtimer_periodic_wakeup(&last, DELAY); diff --git a/tests/periph_dac/main.c b/tests/periph_dac/main.c index b355cff313..a5da2eb793 100644 --- a/tests/periph_dac/main.c +++ b/tests/periph_dac/main.c @@ -39,20 +39,20 @@ int main(void) "DAC line. The period of the signal should be around 100ms\n"); /* initialize all DAC lines */ - for (int i = 0; i < DAC_NUMOF; i++) { + for (unsigned i = 0; i < DAC_NUMOF; i++) { if (dac_init(DAC_LINE(i)) < 0) { - printf("Error initializing DAC_LINE(%i)\n", i); + printf("Error initializing DAC_LINE(%u)\n", i); return 1; } else { - printf("Successfully initialized DAC_LINE(%i)\n", i); + printf("Successfully initialized DAC_LINE(%u)\n", i); } } puts(""); /* create saw tooth signal */ while (1) { - for (int i = 0; i < DAC_NUMOF; i++) { + for (unsigned i = 0; i < DAC_NUMOF; i++) { dac_set(DAC_LINE(i), val); } val += step; diff --git a/tests/periph_flashpage/main.c b/tests/periph_flashpage/main.c index df99d946ef..41df0f34e9 100644 --- a/tests/periph_flashpage/main.c +++ b/tests/periph_flashpage/main.c @@ -35,7 +35,7 @@ static uint8_t page_mem[FLASHPAGE_SIZE]; static int getpage(const char *str) { int page = atoi(str); - if ((page >= FLASHPAGE_NUMOF) || (page < 0)) { + if ((page >= (int)FLASHPAGE_NUMOF) || (page < 0)) { printf("error: page %i is invalid\n", page); return -1; } @@ -195,7 +195,7 @@ static int cmd_edit(int argc, char **argv) } offset = atoi(argv[1]); - if (offset >= FLASHPAGE_SIZE) { + if (offset >= (int)FLASHPAGE_SIZE) { printf("error: given offset is out of bounce\n"); return -1; } @@ -225,7 +225,7 @@ static int cmd_test(int argc, char **argv) return 1; } - for (int i = 0; i < sizeof(page_mem); i++) { + for (unsigned i = 0; i < sizeof(page_mem); i++) { page_mem[i] = (uint8_t)fill++; if (fill > 'z') { fill = 'a'; diff --git a/tests/periph_i2c/main.c b/tests/periph_i2c/main.c index 285ff60fb1..f84307ecbf 100644 --- a/tests/periph_i2c/main.c +++ b/tests/periph_i2c/main.c @@ -37,8 +37,8 @@ int cmd_init_master(int argc, char **argv) puts("Error: Init: Invalid number of arguments!"); printf("Usage:\n%s: [DEVICE] [SPEED]\n", argv[0]); puts(" with DEVICE:"); - for (int i = 0; i < I2C_NUMOF; i++) { - printf(" %i -> I2C_%i\n", i, i); + for (unsigned i = 0; i < I2C_NUMOF; i++) { + printf(" %u -> I2C_%u\n", i, i); } puts(" SPEED:"); puts(" 0 -> SPEED_LOW (10kbit/s)"); @@ -181,7 +181,7 @@ int cmd_read(int argc, char **argv) addr = atoi(argv[1]); length = atoi(argv[2]); - if (length < 1 || length > BUFSIZE) { + if (length < 1 || length > (int)BUFSIZE) { puts("Error: invalid LENGTH parameter given\n"); return 1; } @@ -229,7 +229,7 @@ int cmd_read_reg(int argc, char **argv) reg = atoi(argv[2]); length = atoi(argv[3]); - if (length < 1 || length > BUFSIZE) { + if (length < 1 || length > (int)BUFSIZE) { puts("Error: invalid LENGTH parameter given"); return 1; } diff --git a/tests/periph_pwm/main.c b/tests/periph_pwm/main.c index 071698f6f4..d61925f257 100644 --- a/tests/periph_pwm/main.c +++ b/tests/periph_pwm/main.c @@ -48,27 +48,27 @@ int main(void) puts("Connect an LED or scope to PWM pins to see something\n"); printf("Available PWM devices: %i\n", PWM_NUMOF); - for (int i = 0; i < PWM_NUMOF; i++) { + for (unsigned i = 0; i < PWM_NUMOF; i++) { uint32_t real_f = pwm_init(PWM_DEV(i), MODE, FREQU, STEPS); if (real_f == 0) { - printf("Error initializing PWM_%i\n", i); + printf("Error initializing PWM_%u\n", i); return 1; } else { - printf("Initialized PWM_%i @ %" PRIu32 "Hz\n", i, real_f); + printf("Initialized PWM_%u @ %" PRIu32 "Hz\n", i, real_f); } } puts("\nLetting the PWM pins oscillate now..."); while (1) { - for (int i = 0; i < PWM_NUMOF; i++) { + for (unsigned i = 0; i < PWM_NUMOF; i++) { for (uint8_t chan = 0; chan < pwm_channels(PWM_DEV(i)); chan++) { pwm_set(PWM_DEV(i), chan, state); } } state += step; - if (state <= 0 || state >= STEPS) { + if (state <= 0 || state >= (int)STEPS) { step = -step; } diff --git a/tests/periph_spi/main.c b/tests/periph_spi/main.c index 0b78eba3e0..98f6b15930 100644 --- a/tests/periph_spi/main.c +++ b/tests/periph_spi/main.c @@ -110,7 +110,7 @@ int cmd_init(int argc, char **argv) /* parse the given SPI device */ dev = atoi(argv[1]); - if (dev < 0 || dev >= SPI_NUMOF) { + if (dev < 0 || dev >= (int)SPI_NUMOF) { puts("error: invalid SPI device specified"); return 1; }