Skip to content

Commit

Permalink
message/metadata: remember the number of parsed arg{,path}X
Browse files Browse the repository at this point in the history
Use the information to cap the iterations through the array.

Signed-off-by: Tom Gundersen <[email protected]>
  • Loading branch information
teg committed Jan 29, 2018
1 parent f8a35d2 commit dfcdee3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bus/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static int driver_monitor(Bus *bus, Peer *sender, Message *message) {
filter.member = message->metadata.fields.member,
filter.path = message->metadata.fields.path;

for (size_t i = 0; i < 64; ++i) {
for (size_t i = 0; i < message->metadata.n_args; ++i) {
if (message->metadata.args[i].element == 's') {
filter.args[i] = message->metadata.args[i].value;
filter.argpaths[i] = message->metadata.args[i].value;
Expand Down
2 changes: 1 addition & 1 deletion src/bus/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ int peer_broadcast(PolicySnapshot *sender_policy, NameSet *sender_names, MatchRe
filter->member = message->metadata.fields.member,
filter->path = message->metadata.fields.path;

for (size_t i = 0; i < 64; ++i) {
for (size_t i = 0; i < message->metadata.n_args; ++i) {
if (message->metadata.args[i].element == 's') {
filter->args[i] = message->metadata.args[i].value;
filter->argpaths[i] = message->metadata.args[i].value;
Expand Down
1 change: 1 addition & 0 deletions src/dbus/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ static int message_parse_body(Message *message, MessageMetadata *metadata) {
if (i < C_ARRAY_SIZE(metadata->args)) {
metadata->args[i].element = t->element;
c_dvar_read(&v, (char[2]){ t->element, 0 }, &metadata->args[i].value);
metadata->n_args = i + 1;
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/dbus/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct MessageMetadata {
char element;
const void *value;
} args[64];
size_t n_args;
};

struct Message {
Expand Down

0 comments on commit dfcdee3

Please sign in to comment.