device: fix sysattr newline cutter

Right now, we always drop the last character of all values we write to
sysfs. Fix this!
This commit is contained in:
David Herrmann 2015-04-07 13:11:18 +02:00
parent bd1acc9f2f
commit 24eb4a3098
1 changed files with 2 additions and 2 deletions

View File

@ -1781,8 +1781,8 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
value_len = strlen(_value);
/* drop trailing newlines */
while (value_len > 0 && _value[--value_len] == '\n')
_value[value_len] = '\0';
while (value_len > 0 && _value[value_len - 1] == '\n')
_value[--value_len] = '\0';
/* value length is limited to 4k */
if (value_len > 4096)