88c6a823 | 10-Sep-2024 |
Lei YU <yulei.sh@bytedance.com> |
message: Fix unpack void type
The template unpack<void> is deduced as one argument instead of 0, and results in below compile error: ``` error: variable or field ‘r’ declared void error: return-stat
message: Fix unpack void type
The template unpack<void> is deduced as one argument instead of 0, and results in below compile error: ``` error: variable or field ‘r’ declared void error: return-statement with a value, in function returning ‘void’ [-fpermissive] ```
Fix this by checking void if `sizeof...(Args) == 1` and return void. Also add a unit test case to make sure the code compiles.
Change-Id: I74cca180783645496863393be37215f1d6f4ca02 Signed-off-by: Lei YU <yulei.sh@bytedance.com>
show more ...
|
06f265f6 | 16-Aug-2024 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we need to reformat the code with the latest version. The way clang-18 handles lambda forma
clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we need to reformat the code with the latest version. The way clang-18 handles lambda formatting also changed, so we have made changes to the organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style. See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: I4f63258febea27dae710c252033b9151e02be7e8 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
show more ...
|
5f1c0bd5 | 28-Nov-2023 |
Patrick Williams <patrick@stwcx.xyz> |
test: message: read: add structured binding test for unpack
Add test case for structured binding syntax from unpack, which might be used as a example in implementations.
Signed-off-by: Patrick Will
test: message: read: add structured binding test for unpack
Add test case for structured binding syntax from unpack, which might be used as a example in implementations.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I342fffebad3d6e9a58fe5ab57bbf13019e1b0e6f
show more ...
|
6db88387 | 20-Oct-2023 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: copy latest and re-format
clang-format-17 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest
clang-format: copy latest and re-format
clang-format-17 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository.
Change-Id: I1d7d35c8035993df4c164bfb055d3be476d3ea84 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
show more ...
|
7770d2b9 | 25-Jul-2023 |
Patrick Williams <patrick@stwcx.xyz> |
test: message: read: add test for unix_fd
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I602b3d2d44dbd74916aa73d018b37ff0cafb210d |
d2149044 | 10-May-2023 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest
clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository.
Change-Id: I5daa012bf76924eb7a7d22ed31b6b77ad2f723df Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
show more ...
|
cb2fbeb9 | 06-Jan-2023 |
Ed Tanous <edtanous@google.com> |
Remove some extra semi-colons in tests
These snuck in here and cause clang warnings. Fix them.
Change-Id: I526cfee1ebc799eae48b92e790273f31462c655f Signed-off-by: Ed Tanous <edtanous@google.com> |
640a7d56 | 04-Jan-2023 |
Ed Tanous <edtanous@google.com> |
Add support for appending std::string_view
std::string_view is used more in the project now that c++17 is available. It should be allowed as a base type in serialization of dbus interfaces.
To avo
Add support for appending std::string_view
std::string_view is used more in the project now that c++17 is available. It should be allowed as a base type in serialization of dbus interfaces.
To avoid an extra string copy, this function makes use of sd_bus_message_append_string_iovec, which allows appending in string pieces that might not be null terminated. This function is piped through the test framework, and interfaces to match.
Change-Id: Iee3e2cea9759fa9759cec98ab30c12c822aa3b73 Signed-off-by: Ed Tanous <edtanous@google.com>
show more ...
|
9cde21ff | 29-Aug-2022 |
Patrick Williams <patrick@stwcx.xyz> |
message: add unpack method
Add an unpack method that allows reading from the message as r-values. This simplifies the pattern:
``` foo f{}; bar b{}; msg.read(f,b);
// Can now be w
message: add unpack method
Add an unpack method that allows reading from the message as r-values. This simplifies the pattern:
``` foo f{}; bar b{}; msg.read(f,b);
// Can now be written as...
auto [f, b] = msg.unpack<foo, bar>(); ```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ic2ae7f2c52d41702b8c7c3af6a2efb21558a7579
show more ...
|
b7329a90 | 28-Apr-2022 |
Patrick Williams <patrick@stwcx.xyz> |
message: append: support span
Change how we detect the ability to iterate over a type so that it supports additional types, such as span. Add test case to cover span. Add some static_asserts in th
message: append: support span
Change how we detect the ability to iterate over a type so that it supports additional types, such as span. Add test case to cover span. Add some static_asserts in the test cases to ensure we are triggering the correct add_multiple/add_single paths for a few assorted types.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I42ff496ab58af613940c9ceb979c71f468f125fc
show more ...
|
0f282c48 | 19-Nov-2021 |
Patrick Williams <patrick@stwcx.xyz> |
bus: shorten bus type
Create an alias `sdbusplus::bus_t` to `sdbusplus::bus::bus` to reduce duplication.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I9f17892eed5112d4946949861488
bus: shorten bus type
Create an alias `sdbusplus::bus_t` to `sdbusplus::bus::bus` to reduce duplication.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I9f17892eed5112d49469498614884c02bba86011
show more ...
|
10d7aa12 | 19-Nov-2021 |
Patrick Williams <patrick@stwcx.xyz> |
message: shorten message type
Create an alias `sdbusplus::message_t` to `sdbusplus::message::message` to reduce duplication.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ib400b12f
message: shorten message type
Create an alias `sdbusplus::message_t` to `sdbusplus::message::message` to reduce duplication.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ib400b12fe4a412c0c0c3d26a88f3fae46445cfa8
show more ...
|
8db46a0f | 05-May-2021 |
William A. Kennington III <wak@google.com> |
native_types: string_path_wrapper: Don't escape all strings
Not all strings require escaping when appending them to a path. This allows us to now append `openbmc_project` to `/xyz` and have expected
native_types: string_path_wrapper: Don't escape all strings
Not all strings require escaping when appending them to a path. This allows us to now append `openbmc_project` to `/xyz` and have expected behavior.
Change-Id: I49a2ee100455cff4067dcf3df61f3e145231eeba Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
285f78b1 | 01-May-2021 |
William A. Kennington III <wak@google.com> |
native_types: Reduce append allocation
This builds the string from left to right, instead of dealing with string inserts, optimizing for allocations. Uses our own hex encoder instead of relying on s
native_types: Reduce append allocation
This builds the string from left to right, instead of dealing with string inserts, optimizing for allocations. Uses our own hex encoder instead of relying on systemd libraries. This maintains explicit compatability with the systemd encoding scheme.
Change-Id: Ia6c2f4fb19984f549c6bac2d67d0b5d610022038 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
e39b3dcb | 05-May-2021 |
William A. Kennington III <wak@google.com> |
test/message/types: Convert ASSERTs to EXPECTs
None of the comparisons made in this test prevent the continuation of the test. This makes it easier to debug changes since all errors will now be repo
test/message/types: Convert ASSERTs to EXPECTs
None of the comparisons made in this test prevent the continuation of the test. This makes it easier to debug changes since all errors will now be reported instead of early termination.
Change-Id: Ifd849f5a7585ff13cb314980a1128e0f126723b6 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
472b7022 | 15-Apr-2021 |
William A. Kennington III <wak@google.com> |
message: Add call_async method
This makes it possible to perform an async method call that is agnostic to the event loop running the sd_bus state machine.
Change-Id: I32bc0fdf89c44cc6bab1c4622b143d
message: Add call_async method
This makes it possible to perform an async method call that is agnostic to the event loop running the sd_bus state machine.
Change-Id: I32bc0fdf89c44cc6bab1c4622b143d6e06098659 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
d06072e7 | 21-Apr-2021 |
Ed Tanous <edtanous@google.com> |
Fix #60 by adding encoding/decoding rules
This commit attempts to make encoding more compatible with things within openbmc that don't encode paths per the systemd method. It does this by forcing th
Fix #60 by adding encoding/decoding rules
This commit attempts to make encoding more compatible with things within openbmc that don't encode paths per the systemd method. It does this by forcing the first character of every path segment to be encoded, so /abc would be encoded as /_61bc. This is then used as a mechanism to determine if the path needs to be decoded per systemds rules.
The decode mechanisms are also modified to check whether the first element is encoded before decoding the portion.
Looking for input on whether this is an OK path. The hope would be that we slowly transition the system over to using the encoding mechanisms that can handle all ascii characters, and can round trip through encode/decode without loss. The hope is that this patch can be reversed at some point in the future.
As an aside, I tried reverting some of the patches, but they're somewhat ungainly to revert at this point, and would require reverting some bmcweb patches, which, if this patch is determined to be bad, I'm happy to do, but I'm hoping this will get us something in the interim
Tested: unit tests added and updated to cover some of the cases. Unit tests pass.
Change-Id: Ie9c8cd0627b8b086e8b0bb2287f28dd86eb98ee9 Signed-off-by: Ed Tanous <edtanous@google.com>
show more ...
|
74a27118 | 07-Apr-2021 |
Ed Tanous <edtanous@google.com> |
Implement operator /= for object_path
This probably should've been implemented as part of fa0fa3b0fa5a9d59c37b6edbc53cc21b7c2a16b0 Implement path encoding and decoding but alas, it was not. This co
Implement operator /= for object_path
This probably should've been implemented as part of fa0fa3b0fa5a9d59c37b6edbc53cc21b7c2a16b0 Implement path encoding and decoding but alas, it was not. This commit adds the relatively simple operator/= overloads to object_path. This allows calling code to do operations like:
object_path myPath("/foo"); myPath /= "bar";
Which would result in the object path /foo/bar.
In the implementation, this actually just calls into operator/, and does a relatively naive replace of the content in the new object. Given how the sd_bus_path_encode API is organized, there doesn't appear to be a way to call into it and "append" to an existing thing, so constructing a new string and assigning it to the current object was the best I could come up with in terms of efficiency.
This includes overloads for both const char* and const std::string&, both of which have essentially the same behavior.
Tested: New unit tests included in commit, and pass.
Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idfb7f7f2dc94ea3773841c9ae62cd671327db2cd
show more ...
|
fa0fa3b0 | 31-Mar-2021 |
Ed Tanous <edtanous@google.com> |
Implement path encoding and decoding
sdbus has methods for encoding and decoding paths in a lossless way. This commit adds those methods to object_path in such a way that those functions are called
Implement path encoding and decoding
sdbus has methods for encoding and decoding paths in a lossless way. This commit adds those methods to object_path in such a way that those functions are called implicitly when building strings, the hope being that any API choosing to use object_path need not write its own escaping functions, and said escaping will happen implicitly.
The explicit changes to make this happen are. 1. filename() now calls into sd_bus_path_decode, rather than writing its own method. This means that the strings returned from the method now no longer need decoding explicitly, and can largely be used as-is. For paths that did not require escaping, the behavior should be identical. For paths that did require escaping, this method will now return the raw version of the path. Existing usages should remain the same, and impact is unlikely, given that most sdbusplus users don't explicitly escape strings, and filename() is relatively new.
2. a operator/ method is added to the object_path object. Similar to operator/ on std::filesystem::path, this allows generating a new object_path from an existing one, by adding a new leaf node to the path. Functionally this allows nearly any value to be escaped into a dbus path. An example of a common usage of this might be
object_path myPath = "/"; object_path myNewPath = myPath / "Foo-bar";
The above line will implicitly escape the - in the name. Overloads for both const std::string& and const char* have been added.
One motivating example where the above would be useful is to remove the escapePathForDbus method in bmcweb. https://github.com/openbmc/bmcweb/blob/88b3dd12851cd7bdd4b5c065ba99f40feafb775e/include/dbus_utility.hpp#L47
and the similarly named method in dbus-sensors https://github.com/openbmc/dbus-sensors/blob/6cb732a31b7664089124b00e806311768bc24a87/src/SensorPaths.cpp#L49 both written by the same author (not me), and centralize them in sdbusplus where they belong.
Functionally this commit also includes a new utility/memory.hpp, that allows for C-style RAII using freep, mfree and the _cleanup_free_ attributes. These were largely copied as-is from alloc-util.h in systemd on latest patchset recommendations.
Tested: Unit tests have been updated to include all new code paths, and some common items that might need escaped. Unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If77b8bc5f75709b59353570a9c14383cac44dcd4
show more ...
|
eb4bd724 | 17-Dec-2020 |
Ed Tanous <edtanous@google.com> |
Add filename() and parent_path() methods to object_path
In practice, one very common operation done on a dbus path is to get the final member name in the dbus path, to use as unique IDs, or to pass
Add filename() and parent_path() methods to object_path
In practice, one very common operation done on a dbus path is to get the final member name in the dbus path, to use as unique IDs, or to pass items to public interfaces. This tends to lead to something like:
size_t pos = object_path.str.rfind('/'); if(pos == std::string::npos){ // handle error } pos++; if (pos >= object_path.str.size()){ // handle error }
std::string name = object_path.str.substr(pos);
As an aside, what I've written above is one of several "right" ways to do it, and is among many other wrong ways that I've seen people try to check in. The goal of this patchset is to add the above code as a method within object_path, to help people to use it, and to avoid using object_path.str, which ideally would be a private member of that class.
Functionally, accomplishing the above this requires splitting string_wrapper into two separate classes, as we continue to need the string_wrapper instance to handle the signature type, but filename() and parent_path() on signature are non-sensical. Therefore, this splits the functionality into string_wrapper and string_path_wrapper, each of which no longer need to be a template, given there is only one use. We could also get rid of the using, and move these classes out of details, but that seemed better reserved for a later patch.
Tested: Unit tests written and passing.
Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I242d1965875ba1fe76a32fd78e381e90796706fc
show more ...
|
b98bdc6f | 16-Jun-2020 |
Patrick Williams <patrick@stwcx.xyz> |
sdbus++: add support for 'set'
Add 'set' as a supported type to `sdbus++` and set as `std::set`. The use of ordered-set is to match 'dict' as `std::map` and because 'struct' is `std::tuple`, which h
sdbus++: add support for 'set'
Add 'set' as a supported type to `sdbus++` and set as `std::set`. The use of ordered-set is to match 'dict' as `std::map` and because 'struct' is `std::tuple`, which has `operator<=>` but not `std::hash`. This ensures better compatiblilty with possible property type choices by users.
Also, add a few test cases to ensure `std::set` and `std::unordered_set` are well-covered.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I59605db1b22d54f783d807eda1e1ec1f9eb6792f
show more ...
|
127b8abe | 21-May-2020 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: sync from docs master .clang-format
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I8077816a5ddf7a067bdf537cb46e4e32f5c4ef65 |
78b7803b | 20-May-2020 |
Patrick Williams <patrick@stwcx.xyz> |
clean up more pedantic compile warnings
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I84790e29a24c73a65c9770c6836b482386cc0ab7 |
f8bbf17c | 30-May-2019 |
William A. Kennington III <wak@google.com> |
native_types: Fix string_wrapper overloads
We should only coalesce to an r-value reference to our internal string if our object is a move reference. This fixes ambiguous overloads with gcc9. This al
native_types: Fix string_wrapper overloads
We should only coalesce to an r-value reference to our internal string if our object is a move reference. This fixes ambiguous overloads with gcc9. This also ensures that const references cannot be ambiguous with move references by requiring a const volatile reference.
Change-Id: I31ed529c015cc311c9933acbc0f0a4aa50fed3a6 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
4274c117 | 26-Nov-2018 |
William A. Kennington III <wak@google.com> |
std::variant: Remove uses of the variant_ns
Now that we are using std::variant we should reference it directly instead of using our own namespace alias.
Tested: Built and ran through unit tests
std::variant: Remove uses of the variant_ns
Now that we are using std::variant we should reference it directly instead of using our own namespace alias.
Tested: Built and ran through unit tests.
Change-Id: Ic3fd62ea74cf808b85ad7b7ffcce8c0a0bfb125d Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|