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

battstat: fix deprecated up_client_get_devices #487

Merged
merged 2 commits into from
Jul 14, 2020
Merged

Conversation

raveit65
Copy link
Member

The previous code would have leaked all the UpDevice objects because no
free function was set on the returned GPtrArray.

With depending on upower-glib 0.99.8 get_devices() was deprecated and get_devices2() was introduced, we
can simply switch to get_devices2() which does set a free function on
the returned GPtrArray, stopping the leak.

The previous code would have leaked all the UpDevice objects because no
free function was set on the returned GPtrArray.

With depending on upower-glib 0.99.8 get_devices() was deprecated and get_devices2() was introduced, we
can simply switch to get_devices2() which does set a free function on
the returned GPtrArray, stopping the leak.
@raveit65 raveit65 changed the title batstatt: fix deprecated up_client_get_devices battstat: fix deprecated up_client_get_devices Jul 14, 2020
@rbuj
Copy link
Contributor

rbuj commented Jul 14, 2020

I think that we can also bump upower to 0.99.8 and remove legacy code.

UPOWER_REQUIRED=0.9.4

@raveit65
Copy link
Member Author

You're right, done.

Copy link
Contributor

@rbuj rbuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test:

$ CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -g -ggdb3 -O0" LDFLAGS="-fsanitize=leak -ggdb3" ./autogen.sh --prefix=/usr && make && sudo make install

@raveit65
Copy link
Member Author

@rbuj
Copy link
Contributor

rbuj commented Jul 14, 2020

Using a global variable makes more sense like in #443, since the list of devices is updated dynamically and specific events are triggered.

@raveit65
Copy link
Member Author

raveit65 commented Jul 14, 2020

I only wanted to fix the deprecation. Any improvements can be done in another PR.
And it has a significant improvement from your previous post:
Before:
SUMMARY: LeakSanitizer: 21220 byte(s) leaked in 725 allocation(s).
After:
SUMMARY: LeakSanitizer: 20143 byte(s) leaked in 709 allocation(s).

@raveit65 raveit65 merged commit f7a5d24 into master Jul 14, 2020
@raveit65 raveit65 deleted the batstatt-upower branch July 14, 2020 14:19
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

Successfully merging this pull request may close these issues.

2 participants