Skip to content

Commit 0432b1b

Browse files
committed
mctpd: collect similar type declarations
In method_register_responder: rather than declaring inline, group our two declarations of the same type. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
1 parent 583b27d commit 0432b1b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/mctpd.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,10 +3395,11 @@ static int on_dbus_peer_removed(sd_bus_track *track, void *userdata)
33953395
static int method_register_responder(sd_bus_message *call, void *data,
33963396
sd_bus_error *berr)
33973397
{
3398-
struct ctx *ctx = data;
3399-
uint8_t msg_type;
3398+
struct msg_type_support *msg_types, *cur_msg_type;
34003399
const uint32_t *versions = NULL;
34013400
size_t i, versions_len;
3401+
struct ctx *ctx = data;
3402+
uint8_t msg_type;
34023403
int rc;
34033404

34043405
rc = sd_bus_message_read(call, "y", &msg_type);
@@ -3425,19 +3426,17 @@ static int method_register_responder(sd_bus_message *call, void *data,
34253426
}
34263427
}
34273428

3428-
struct msg_type_support *msg_types =
3429-
realloc(ctx->supported_msg_types,
3430-
(ctx->num_supported_msg_types + 1) *
3431-
sizeof(struct msg_type_support));
3429+
msg_types = realloc(ctx->supported_msg_types,
3430+
(ctx->num_supported_msg_types + 1) *
3431+
sizeof(struct msg_type_support));
34323432
if (!msg_types) {
34333433
return sd_bus_error_setf(
34343434
berr, SD_BUS_ERROR_NO_MEMORY,
34353435
"Failed to allocate memory for message types");
34363436
}
34373437
ctx->supported_msg_types = msg_types;
3438-
struct msg_type_support *cur_msg_type =
3439-
&ctx->supported_msg_types[ctx->num_supported_msg_types];
34403438

3439+
cur_msg_type = &ctx->supported_msg_types[ctx->num_supported_msg_types];
34413440
cur_msg_type->source_peer = NULL;
34423441
cur_msg_type->versions = NULL;
34433442
rc = sd_bus_track_new(ctx->bus, &cur_msg_type->source_peer,

0 commit comments

Comments
 (0)