1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

make: fix sign-compare errors

cpu, nrf5x_common: fix sign-compare in periph/flashpage
    drivers, periph_common: fix sign-compare in flashpage
    cpu, sam0_common: fix sign-compare error in periph/gpio
    cpu, cc2538: fix sign-compare in periph/timer
    cpu, sam3: fix sign-compare in periph/gpio
    cpu, stm32_common: fix sign-compare in periph/pwm
    cpu, stm32_common: fix sign-compare in periph/timer
    cpu, stm32_common: fix sign-compare in periph/flashpage
    cpu, nrf5x_common: fix sign-compare in radio/nrfmin
    cpu, samd21: fix sign-compare in periph/pwm
    cpu, ezr32wg: fix sign-compare in periph/gpio
    cpu, ezr32wg: fix sign-compare in periph/timer
    drivers, ethos: fix sign-compare
    sys, net: fix sign-compare
    cpu, atmega_common: fix sign-compare error
    cpu, msp430fxyz: fix sign-compare in periph/gpio
    boards, msb-430-common: fix sign-compare in board_init
    driver, cc2420: fix sign-compared
    sys/net: fix sign-compare in gnrc_tftp
    driver, pcd8544: fix sign-compare
    driver, pn532: fix sign-compare
    driver, sdcard_spi: fix sign-compare
    tests: fix sign_compare
    sys/net, lwmac: fix sign_compare
    pkg, lwip: fix sign-compare
    boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
    tests, sock_ip: fix sign compare
    tests, msg_avail: fix sign compare
    tests, sock_udp: fix sign compare
    boards: fix sign-compare for calliope and microbit matrix
This commit is contained in:
smlng 2017-10-31 11:57:40 +01:00
parent 5ffe9ddaf5
commit e381317fbf
40 changed files with 138 additions and 132 deletions

View File

@ -32,7 +32,7 @@ extern "C" {
* @name Clock configuration
* @{
*/
#define CLOCK_CORECLOCK (16000000L)
#define CLOCK_CORECLOCK (16000000UL)
/** @} */
/**

View File

@ -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];
}
}

View File

@ -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];
}
}

View File

@ -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;

View File

@ -29,7 +29,7 @@ extern "C" {
* @name Clock configuration
* @{
*/
#define CLOCK_CORECLOCK (14745600L)
#define CLOCK_CORECLOCK (14745600UL)
/** @} */
/**

View File

@ -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);

View File

@ -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" */

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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));
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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");

View File

@ -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;
}

View File

@ -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) {

View File

@ -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 */
}

View File

@ -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) {

View File

@ -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 */

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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';

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}