From 4277a3ee2386762153ff844d83ea3c20c94b6d0c Mon Sep 17 00:00:00 2001 From: Houman Brinjcargorabi Date: Wed, 17 Aug 2016 14:48:25 +0100 Subject: [PATCH] mraa.c: Replaced string values with #defines Signed-off-by: Houman Brinjcargorabi Signed-off-by: Brendan Le Foll --- src/mraa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mraa.c b/src/mraa.c index 406531c..bc517bc 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -1210,7 +1210,7 @@ mraa_init_io(const char* desc) return NULL; } - if (strncmp(type, "GPIO", 4) == 0) { + if (strncmp(type, GPIO_KEY, strlen(GPIO_KEY)) == 0) { if (raw) { if (mraa_init_io_helper(&str, &pin, delim) == MRAA_SUCCESS) { return (void*) mraa_gpio_init_raw(pin); @@ -1219,7 +1219,7 @@ mraa_init_io(const char* desc) return NULL; } return (void*) mraa_gpio_init(pin); - } else if (strncmp(type, "I2C", 3) == 0) { + } else if (strncmp(type, I2C_KEY, strlen(I2C_KEY)) == 0) { if (raw) { if (mraa_init_io_helper(&str, &pin, delim) == MRAA_SUCCESS) { return (void*) mraa_i2c_init_raw(pin); @@ -1228,13 +1228,13 @@ mraa_init_io(const char* desc) return NULL; } return (void*) mraa_i2c_init(pin); - } else if (strncmp(type, "AIO", 3) == 0) { + } else if (strncmp(type, AIO_KEY, strlen(AIO_KEY)) == 0) { if (raw) { syslog(LOG_ERR, "mraa_init_io: Aio doesn't have a RAW mode"); return NULL; } return (void*) mraa_aio_init(pin); - } else if (strncmp(type, "PWM", 3) == 0) { + } else if (strncmp(type, PWM_KEY, strlen(PWM_KEY)) == 0) { if (raw) { if (mraa_init_io_helper(&str, &id, delim) != MRAA_SUCCESS) { syslog(LOG_ERR, "mraa_init_io: Pwm, unable to convert the chip id string into a useable Int"); @@ -1247,7 +1247,7 @@ mraa_init_io(const char* desc) return (void*) mraa_pwm_init_raw(id, pin); } return (void*) mraa_pwm_init(pin); - } else if (strncmp(type, "SPI", 3) == 0) { + } else if (strncmp(type, SPI_KEY, strlen(SPI_KEY)) == 0) { if (raw) { if (mraa_init_io_helper(&str, &id, delim) != MRAA_SUCCESS) { syslog(LOG_ERR, "mraa_init_io: Spi, unable to convert the bus string into a useable Int"); @@ -1260,7 +1260,7 @@ mraa_init_io(const char* desc) return (void*) mraa_spi_init_raw(id, pin); } return (void*) mraa_spi_init(pin); - } else if (strncmp(type, "UART", 4) == 0) { + } else if (strncmp(type, UART_KEY, strlen(UART_KEY)) == 0) { if (raw) { return (void*) mraa_uart_init_raw(str); }