sd-bus: simplify handling of 'types' in convenience methods
The arg types==NULL has different meanings for different functions. Some functions like sd_bus_message_appendv() require a non-null param and treat "" as "no data". Other functions like sd_bus_skip() treat null as "process one item", while the convenience functions treat NULL the same as "". So I think it's reasonable to make the convenience functions handle NULL explicitly, separately from "". That way the logical separation of concerns is clearer, and e.g. sd_bus_message_appendv() handles all non-null strings, while e.g. sd_bus_call_methodv() doesn't look into the string at all. Behaviour is unchanged.
This commit is contained in:
@@ -39,7 +39,7 @@ _public_ int sd_bus_emit_signal_tov(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!isempty(types)) {
|
||||
if (types) {
|
||||
r = sd_bus_message_appendv(m, types, ap);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -118,7 +118,7 @@ _public_ int sd_bus_call_method_asyncv(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!isempty(types)) {
|
||||
if (types) {
|
||||
r = sd_bus_message_appendv(m, types, ap);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -174,7 +174,7 @@ _public_ int sd_bus_call_methodv(
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
if (!isempty(types)) {
|
||||
if (types) {
|
||||
r = sd_bus_message_appendv(m, types, ap);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
@@ -229,7 +229,7 @@ _public_ int sd_bus_reply_method_returnv(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!isempty(types)) {
|
||||
if (types) {
|
||||
r = sd_bus_message_appendv(m, types, ap);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user