Commit e03ac408 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Mauro Carvalho Chehab

media: venus: hfi_cmds: Use struct_size() helper

Prefer struct_size() over open-coded versions of idiom:

sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count

where count is the max number of items the flexible array is supposed to
contain.

Link: https://github.com/KSPP/linux/issues/160Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 40c02059
......@@ -209,8 +209,8 @@ int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt,
}
} else {
pkt->extradata_size = 0;
pkt->shdr.hdr.size = sizeof(*pkt) +
bd->num_buffers * sizeof(u32);
pkt->shdr.hdr.size = struct_size(pkt, buffer_info,
bd->num_buffers);
for (i = 0; i < pkt->num_buffers; i++)
pkt->buffer_info[i] = bd->device_addr;
}
......@@ -251,8 +251,8 @@ int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt,
pkt->extradata_size = 0;
pkt->shdr.hdr.size =
sizeof(struct hfi_session_set_buffers_pkt) +
bd->num_buffers * sizeof(u32);
struct_size((struct hfi_session_set_buffers_pkt *)0,
buffer_info, bd->num_buffers);
}
pkt->response_req = bd->response_required;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment