Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery status remains unchanged with eudev pre 3.2.14 and libgudev 238 #254

Closed
NaofumiHonda opened this issue Aug 20, 2023 · 1 comment
Closed

Comments

@NaofumiHonda
Copy link
Contributor

This issue is completely irrelevant with a current tag implementation.
A cause of the problem is that the behavior of udev_device_set_sysattr_value() in udev is recently modified so that
a cache value of sysfs attr is cleared when it is called with a null pointer value.
According to this change, libgudev's g_udev_device_get_sysfs_attr_uncached is quite simplified in version 238 like

   udev_device_set_sysattr_value (device->priv->udevice, name, NULL);                                 
   return g_udev_device_get_sysfs_attr (device, name);   

Under the above implementation, for example, upower always get cached values of battery state because the current eudev does not clear cached values in udev_device_set_sysattr_value() call with a null pointer value.

A solution is very easy to add the following code in udev_device_set_sysattr_value:

       if (value == NULL) {                                                                       
               struct udev_list_entry *list_entry;                                                  
                                                                                                    
               list_entry = udev_list_get_entry(&udev_device->sysattr_value_list);                  
               list_entry = udev_list_entry_get_by_name(list_entry, sysattr);                       
               if (list_entry != NULL)                                                              
                       udev_list_entry_delete(list_entry);                                          
               ret = 0;                                                                             
               goto out;                                                                            
       }                 
@bbonev
Copy link
Member

bbonev commented Aug 20, 2023

Thanks! Can you make a PR with this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants