udev_device.c: use strrchr to trim newline
This commit is contained in:
parent
75a40e1040
commit
34f8727f28
1 changed files with 3 additions and 3 deletions
|
|
@ -243,6 +243,7 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const
|
|||
struct stat st;
|
||||
size_t len;
|
||||
FILE *file;
|
||||
char *pos;
|
||||
|
||||
if (!udev_device || !sysattr) {
|
||||
return NULL;
|
||||
|
|
@ -277,9 +278,8 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const
|
|||
fclose(file);
|
||||
data[len] = '\0';
|
||||
|
||||
// TODO strrchr?
|
||||
while (len-- > 0 && data[len] == '\n') {
|
||||
data[len] = '\0';
|
||||
if ((pos = strrchr(data, '\n'))) {
|
||||
*pos = '\0';
|
||||
}
|
||||
|
||||
list_entry = udev_list_entry_add(&udev_device->sysattrs, sysattr, data, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue