udev_device.c: use strrchr to trim newline
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user