Skip to content

Commit

Permalink
async: client: avoid ambiguous base-class error
Browse files Browse the repository at this point in the history
When using multiple generated client classes with client_t, we
can end up with an ambiguous base-class error.  Change the way
the `client_context_friend` utility derives the context pointer
from the `Client` template type, to avoid the ambiguity.

Previous failure when inheriting both `state::BMC` and `state::Host`
into a single `client_t`:

```
error: 'sdbusplus::async::client::details::client_context_friend' is an ambiguous base of 'sdbusplus::async::client::client<true, true, false, sdbusplus::client::xyz::openbmc_project::state::BMC, sdbusplus::client::xyz::openbmc_project::state::Host>'
         return static_cast<T*>(this)->ctx;
```

Signed-off-by: Patrick Williams <[email protected]>
Change-Id: I047f00ca8df071eef13e8fdd71a56910cc7b3e26
  • Loading branch information
williamspatrick committed Nov 4, 2023
1 parent 93f5e28 commit ae01928
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions include/sdbusplus/async/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ namespace client::details
*/
struct client_context_friend
{
template <typename T>
sdbusplus::async::context& context()
template <typename Client, typename Self>
static sdbusplus::async::context& context(Self* self)
{
return static_cast<T*>(this)->ctx;
return static_cast<Client*>(self)->ctx;
}
};
} // namespace client::details
Expand Down
4 changes: 2 additions & 2 deletions tools/sdbusplus/templates/interface.client.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace details
template <typename Client, typename Proxy>
class ${interface.classname} :
public sdbusplus::common::${interface.cppNamespacedClass()},
public sdbusplus::async::client::details::client_context_friend
private sdbusplus::async::client::details::client_context_friend
{
public:
friend Client;
Expand All @@ -70,7 +70,7 @@ ${p.render(loader, "property.client.hpp.mako", property=p, interface=interface)}
sdbusplus::async::context& context()
{
return sdbusplus::async::client::details::client_context_friend::
context<Client>();
context<Client, ${interface.classname}>(this);
}

decltype(std::declval<Proxy>().interface(interface)) proxy = {};
Expand Down

0 comments on commit ae01928

Please sign in to comment.