Merge pull request #3467 from gebart/pr/kinetis-clang-enum-tautological-compare-fix

cpu/kinetis_common: Cast device index enums to unsigned int before comparing for out of range values
This commit is contained in:
Oleg Hahm 2015-07-21 09:55:13 +02:00
commit 470304089c
3 changed files with 10 additions and 10 deletions

View File

@ -675,7 +675,7 @@ int gpio_init_int(gpio_t dev, gpio_pp_t pushpull, gpio_flank_t flank, gpio_cb_t
void gpio_irq_enable(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return;
}
@ -689,7 +689,7 @@ void gpio_irq_enable(gpio_t dev)
void gpio_irq_disable(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return;
}
@ -703,7 +703,7 @@ void gpio_irq_disable(gpio_t dev)
int gpio_read(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return -1;
}
@ -722,7 +722,7 @@ int gpio_read(gpio_t dev)
void gpio_set(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return;
}
@ -731,7 +731,7 @@ void gpio_set(gpio_t dev)
void gpio_clear(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return;
}
@ -740,7 +740,7 @@ void gpio_clear(gpio_t dev)
void gpio_toggle(gpio_t dev)
{
if (dev >= GPIO_NUMOF) {
if ((unsigned int)dev >= GPIO_NUMOF) {
DEBUG("gpio_t out of range: %d >= %d\n", dev, GPIO_NUMOF);
return;
}

View File

@ -58,7 +58,7 @@ static mutex_t locks[] = {
int i2c_acquire(i2c_t dev)
{
if (dev >= I2C_NUMOF) {
if ((unsigned int)dev >= I2C_NUMOF) {
return -1;
}
mutex_lock(&locks[dev]);
@ -67,7 +67,7 @@ int i2c_acquire(i2c_t dev)
int i2c_release(i2c_t dev)
{
if (dev >= I2C_NUMOF) {
if ((unsigned int)dev >= I2C_NUMOF) {
return -1;
}
mutex_unlock(&locks[dev]);

View File

@ -852,7 +852,7 @@ int spi_init_slave(spi_t dev, spi_conf_t conf, char(*cb)(char data))
int spi_acquire(spi_t dev)
{
if (dev >= SPI_NUMOF) {
if ((unsigned int)dev >= SPI_NUMOF) {
return -1;
}
@ -862,7 +862,7 @@ int spi_acquire(spi_t dev)
int spi_release(spi_t dev)
{
if (dev >= SPI_NUMOF) {
if ((unsigned int)dev >= SPI_NUMOF) {
return -1;
}