From: Segwon Date: Thu, 16 Nov 2017 04:15:27 +0000 (+0900) Subject: interface: remove +1 length when writing a char array X-Git-Tag: submit/tizen_4.0/20171220.125806^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e3667aa19274b9dc41d3499da4203ee4e186d58;p=platform%2Fcore%2Fapi%2Fperipheral-io.git interface: remove +1 length when writing a char array Signed-off-by: Segwon Change-Id: I7bbbe2f8698ee1fb90268af6f6ca8c0eaf8edb38 --- diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index 950de19..b8361fb 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -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; diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index bbfeefb..d01776d 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -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;