Skip to content

Commit 583b27d

Browse files
committed
mctpd: simplify on_dbus_peer_removed a little
No need for the pointer compare; at worst it's just the same destination pointer. Use a temporary var for the current message type, and flip the break/continue logic. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
1 parent 5b35f19 commit 583b27d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/mctpd.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,17 +3376,19 @@ static int on_dbus_peer_removed(sd_bus_track *track, void *userdata)
33763376
size_t i, msg_types = ctx->num_supported_msg_types;
33773377

33783378
for (i = 0; i < msg_types; i++) {
3379-
if (ctx->supported_msg_types[i].source_peer == track) {
3380-
free(ctx->supported_msg_types[i].versions);
3381-
if (i < (msg_types - 1)) {
3382-
ctx->supported_msg_types[i] =
3383-
ctx->supported_msg_types[msg_types - 1];
3384-
}
3385-
ctx->num_supported_msg_types--;
3386-
break;
3387-
}
3379+
struct msg_type_support *msg_type =
3380+
&ctx->supported_msg_types[i];
3381+
3382+
if (msg_type->source_peer != track)
3383+
continue;
3384+
3385+
free(msg_type->versions);
3386+
*msg_type = ctx->supported_msg_types[msg_types - 1];
3387+
ctx->num_supported_msg_types--;
3388+
break;
33883389
}
33893390
sd_bus_track_unref(track);
3391+
33903392
return 0;
33913393
}
33923394

0 commit comments

Comments
 (0)