-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
SysfsUtils: cleanup and improve interface according to the documentation #16097
Conversation
@pkerling mind taking a look at this? I redid the interface in a more c++ manner and it seems to work in my testing. I also added a test case (which I think can be improved). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the interface changes and adding tests!
Tests for the failure path would also be cool, I guess
anyone know what the android build error is about? |
|
That seems weird. So the android ndk isn't c++11 compatible? Not a big deal as we should hopefully drop amlogic support in #16043 which (I think) should remove the sysfs dependency for android |
it has always been like that. you should bump to api24.
that won't help at all. aml is linux only. |
sysfsutils is used in amlutils which is used in the android audio sink |
bc32d42
to
b9d748a
Compare
8296589
to
3f6444a
Compare
Small cosmetic issue when testing an old Atom system (kernel 5.3.y) - there's extra whitespace now present in the CPU model, that wasn't there before. /proc/cpuinfo: http://ix.io/21KC |
A little more info: Old kodi.log (before these CPU/SysInfo changes): http://ix.io/21Oj
New kodi.log (with these latest CPU/SysInfo changes): http://ix.io/21Ok
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate you digging into this! Comments added.
0ae1ab2
to
a0b7c71
Compare
GNU |
xbmc/platform/linux/SysfsPath.h
Outdated
template<typename T> | ||
bool Get(T& value) | ||
{ | ||
return GetPrivate(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the indirection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done so I don't have to have duplicated code in the ::Set(std::string)
specialization. I mirrored it for ::Get()
for uniformity. I can get rid of it though for ::Get()
if it's not wanted.
xbmc/platform/linux/SysfsPath.cpp
Outdated
} | ||
|
||
template<> | ||
bool CSysfsPath::Set(std::string value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this function gets called when you don't declare it in the header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I am, The tests prove this and so does setting a breakpoint with gdb
(gdb) break CSysfsPath::Set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
Breakpoint 1 at 0x19cc03d: CSysfsPath::Set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >). (2 locations)
(gdb) r
Starting program: /home/lukas/Documents/git/xbmc/build/kodi-test --gtest_filter=TestSysfsPath\*
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Missing separate debuginfo for /lib64/libwayland-cursor.so.0
Note: Google Test filter = TestSysfsPath*
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from TestSysfsPath
[ RUN ] TestSysfsPath.String
Breakpoint 1, CSysfsPath::Set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (this=0x5a0a090, value='0' <repeats 200 times>...) at /home/lukas/Documents/git/xbmc/xbmc/platform/linux/SysfsPath.cpp:34
warning: Source file is more recent than executable.
34 if (static_cast<int>(value.size()) > PAGESIZE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try it in the release build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't get called anywhere else then the test.
@yol I dropped the Hopefully we can merge this soon 😸 |
c5af37a
to
98ee865
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I mostly forgot what I complained about months ago so I'm just reviewing based on the current code ;-)
as written in the kernel docs: sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the method. Sysfs will call the method exactly once for each read or write. for more info please consult the kernel documentation: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
SysfsUtils: cleanup and improve interface according to the documentation
I'm splitting this out from #14970 as I need it for some other stuff. I have addressed the comments left on that PR here but this can probably use a fresh look over.