Commit 28ccce5f authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Heiko Carstens

s390/appldata: use struct_size() helper

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

This code was detected with the help of Coccinelle and, audited and
fixed manually.
Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Message-Id: <20200617212930.GA11728@embeddedor>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 6ffb3f6b
...@@ -129,8 +129,7 @@ static void appldata_get_os_data(void *data) ...@@ -129,8 +129,7 @@ static void appldata_get_os_data(void *data)
os_data->nr_cpus = j; os_data->nr_cpus = j;
new_size = sizeof(struct appldata_os_data) + new_size = struct_size(os_data, os_cpu, os_data->nr_cpus);
(os_data->nr_cpus * sizeof(struct appldata_os_per_cpu));
if (ops.size != new_size) { if (ops.size != new_size) {
if (ops.active) { if (ops.active) {
rc = appldata_diag(APPLDATA_RECORD_OS_ID, rc = appldata_diag(APPLDATA_RECORD_OS_ID,
...@@ -165,8 +164,7 @@ static int __init appldata_os_init(void) ...@@ -165,8 +164,7 @@ static int __init appldata_os_init(void)
{ {
int rc, max_size; int rc, max_size;
max_size = sizeof(struct appldata_os_data) + max_size = struct_size(appldata_os_data, os_cpu, num_possible_cpus());
(num_possible_cpus() * sizeof(struct appldata_os_per_cpu));
if (max_size > APPLDATA_MAX_REC_SIZE) { if (max_size > APPLDATA_MAX_REC_SIZE) {
pr_err("Maximum OS record size %i exceeds the maximum " pr_err("Maximum OS record size %i exceeds the maximum "
"record size %i\n", max_size, APPLDATA_MAX_REC_SIZE); "record size %i\n", max_size, APPLDATA_MAX_REC_SIZE);
......
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