Skip to content

Commit

Permalink
mmc: mmc_test: Improve a size determination in five functions
Browse files Browse the repository at this point in the history
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Shawn Lin <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Ulf Hansson <[email protected]>
  • Loading branch information
elfring authored and storulf committed Feb 13, 2017
1 parent 7200449 commit 554d7c5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/mmc/core/mmc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz,
if (max_segs > max_page_cnt)
max_segs = max_page_cnt;

mem = kzalloc(sizeof(struct mmc_test_mem), GFP_KERNEL);
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem)
return NULL;

Expand Down Expand Up @@ -545,7 +545,7 @@ static void mmc_test_save_transfer_result(struct mmc_test_card *test,
if (!test->gr)
return;

tr = kmalloc(sizeof(struct mmc_test_transfer_result), GFP_KERNEL);
tr = kmalloc(sizeof(*tr), GFP_KERNEL);
if (!tr)
return;

Expand Down Expand Up @@ -2973,8 +2973,7 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
}
}

gr = kzalloc(sizeof(struct mmc_test_general_result),
GFP_KERNEL);
gr = kzalloc(sizeof(*gr), GFP_KERNEL);
if (gr) {
INIT_LIST_HEAD(&gr->tr_lst);

Expand Down Expand Up @@ -3108,7 +3107,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
if (ret)
return ret;

test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL);
test = kzalloc(sizeof(*test), GFP_KERNEL);
if (!test)
return -ENOMEM;

Expand Down Expand Up @@ -3213,7 +3212,7 @@ static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
return -ENODEV;
}

df = kmalloc(sizeof(struct mmc_test_dbgfs_file), GFP_KERNEL);
df = kmalloc(sizeof(*df), GFP_KERNEL);
if (!df) {
debugfs_remove(file);
dev_err(&card->dev,
Expand Down

0 comments on commit 554d7c5

Please sign in to comment.