You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. From 4154cf252c17297f98a8ca33693ead003b4509da Mon Sep 17 00:00:00 2001
  2. From: illiliti <illiliti@protonmail.com>
  3. Date: Thu, 16 Dec 2021 07:09:16 +0300
  4. Subject: [PATCH 15/15] udev_enumerate.c: support NULL value in match/nomatch
  5. Fixes: #45
  6. ---
  7. udev_enumerate.c | 16 +++++-----------
  8. 1 file changed, 5 insertions(+), 11 deletions(-)
  9. --- a/udev_enumerate.c
  10. +++ b/udev_enumerate.c
  11. @@ -193,20 +193,17 @@ static int filter_property(struct udev_e
  12. static int filter_sysattr(struct udev_enumerate *udev_enumerate, struct udev_device *udev_device)
  13. {
  14. + const char *sysattr, *value, *value2;
  15. struct udev_list_entry *list_entry;
  16. - const char *sysattr, *value;
  17. list_entry = udev_list_entry_get_next(&udev_enumerate->sysattr_nomatch);
  18. while (list_entry) {
  19. sysattr = udev_list_entry_get_name(list_entry);
  20. + value2 = udev_list_entry_get_value(list_entry);
  21. value = udev_device_get_sysattr_value(udev_device, sysattr);
  22. - if (!value) {
  23. - return 1;
  24. - }
  25. -
  26. - if (fnmatch(udev_list_entry_get_value(list_entry), value, 0) == 0) {
  27. + if (value && value2 && fnmatch(value2, value, 0) == 0) {
  28. return 0;
  29. }
  30. @@ -218,13 +215,10 @@ static int filter_sysattr(struct udev_en
  31. if (list_entry) {
  32. while (list_entry) {
  33. sysattr = udev_list_entry_get_name(list_entry);
  34. + value2 = udev_list_entry_get_value(list_entry);
  35. value = udev_device_get_sysattr_value(udev_device, sysattr);
  36. - if (!value) {
  37. - return 0;
  38. - }
  39. -
  40. - if (fnmatch(udev_list_entry_get_value(list_entry), value, 0) == 0) {
  41. + if (value && value2 && fnmatch(value2, value, 0) == 0) {
  42. return 1;
  43. }