interface: remove +1 length when writing a char array 95/160395/1
authorSegwon <segwon.han@samsung.com>
Thu, 16 Nov 2017 04:15:27 +0000 (13:15 +0900)
committerSegwon <segwon.han@samsung.com>
Thu, 16 Nov 2017 04:20:35 +0000 (13:20 +0900)
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I7bbbe2f8698ee1fb90268af6f6ca8c0eaf8edb38

src/interface/peripheral_interface_gpio.c
src/interface/peripheral_interface_pwm.c

index 950de19..b8361fb 100644 (file)
@@ -23,11 +23,11 @@ int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, peripheral_g
        int status;
 
        if (direction == PERIPHERAL_GPIO_DIRECTION_IN)
-               status = write(gpio->fd_direction, "in", strlen("in")+1);
+               status = write(gpio->fd_direction, "in", strlen("in"));
        else if (direction == PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH)
-               status = write(gpio->fd_direction, "high", strlen("high")+1);
+               status = write(gpio->fd_direction, "high", strlen("high"));
        else if (direction == PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW)
-               status = write(gpio->fd_direction, "low", strlen("low")+1);
+               status = write(gpio->fd_direction, "low", strlen("low"));
        else {
                _E("Error: gpio direction is wrong\n");
                return -EIO;
@@ -43,13 +43,13 @@ int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_g
        int status;
 
        if (edge == PERIPHERAL_GPIO_EDGE_NONE)
-               status = write(gpio->fd_edge, "none", strlen("none")+1);
+               status = write(gpio->fd_edge, "none", strlen("none"));
        else if (edge == PERIPHERAL_GPIO_EDGE_RISING)
-               status = write(gpio->fd_edge, "rising", strlen("rising")+1);
+               status = write(gpio->fd_edge, "rising", strlen("rising"));
        else if (edge == PERIPHERAL_GPIO_EDGE_FALLING)
-               status = write(gpio->fd_edge, "falling", strlen("falling")+1);
+               status = write(gpio->fd_edge, "falling", strlen("falling"));
        else if (edge == PERIPHERAL_GPIO_EDGE_BOTH)
-               status = write(gpio->fd_edge, "both", strlen("both")+1);
+               status = write(gpio->fd_edge, "both", strlen("both"));
        else {
                _E("Error: gpio edge is wrong\n");
                return -EIO;
@@ -65,9 +65,9 @@ int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value)
        int status;
 
        if (value == 1)
-               status = write(gpio->fd_value, "1", strlen("1")+1);
+               status = write(gpio->fd_value, "1", strlen("1"));
        else if (value == 0)
-               status = write(gpio->fd_value, "0", strlen("0")+1);
+               status = write(gpio->fd_value, "0", strlen("0"));
        else {
                _E("Error: gpio write value error \n");
                return -EIO;
index bbfeefb..d01776d 100644 (file)
@@ -70,9 +70,9 @@ int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_p
        int status;
 
        if (polarity == PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH)
-               status = write(pwm->fd_polarity, "normal", strlen("normal")+1);
+               status = write(pwm->fd_polarity, "normal", strlen("normal"));
        else if (polarity == PERIPHERAL_PWM_POLARITY_ACTIVE_LOW)
-               status = write(pwm->fd_polarity, "inversed", strlen("inversed")+1);
+               status = write(pwm->fd_polarity, "inversed", strlen("inversed"));
        else {
                _E("Invalid pwm polarity : %d", polarity);
                return -EINVAL;