lkml.org 
[lkml]   [2022]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH v3 6/6] scsi: megaraid_sas: Use struct_size() in code related to struct MR_PD_CFG_SEQ_NUM_SYNC
    Prefer struct_size() over open-coded versions of idiom:

    sizeof(struct-with-flex-array) + sizeof(type-of-flex-array) * count

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

    Link: https://github.com/KSPP/linux/issues/160
    Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
    ---
    Changes in v3:
    - This patch is new in the series.

    drivers/scsi/megaraid/megaraid_sas_base.c | 14 +++++++-------
    1 file changed, 7 insertions(+), 7 deletions(-)

    diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
    index 09eef1bef430..d57cb787db0b 100644
    --- a/drivers/scsi/megaraid/megaraid_sas_base.c
    +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
    @@ -5792,10 +5792,10 @@ megasas_setup_jbod_map(struct megasas_instance *instance)
    {
    int i;
    struct fusion_context *fusion = instance->ctrl_context;
    - u32 pd_seq_map_sz;
    + size_t pd_seq_map_sz;

    - pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
    - (sizeof(struct MR_PD_CFG_SEQ) * MAX_PHYSICAL_DEVICES);
    + pd_seq_map_sz = struct_size((struct MR_PD_CFG_SEQ_NUM_SYNC *)0, seq,
    + MAX_PHYSICAL_DEVICES);

    instance->use_seqnum_jbod_fp =
    instance->support_seqnum_jbod_fp;
    @@ -7974,7 +7974,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
    struct Scsi_Host *host;
    struct megasas_instance *instance;
    struct fusion_context *fusion;
    - u32 pd_seq_map_sz;
    + size_t pd_seq_map_sz;

    instance = pci_get_drvdata(pdev);

    @@ -8046,9 +8046,9 @@ static void megasas_detach_one(struct pci_dev *pdev)

    if (instance->adapter_type != MFI_SERIES) {
    megasas_release_fusion(instance);
    - pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
    - (sizeof(struct MR_PD_CFG_SEQ) *
    - MAX_PHYSICAL_DEVICES);
    + pd_seq_map_sz =
    + struct_size((struct MR_PD_CFG_SEQ_NUM_SYNC *)0,
    + seq, MAX_PHYSICAL_DEVICES);
    for (i = 0; i < 2 ; i++) {
    if (fusion->ld_map[i])
    dma_free_coherent(&instance->pdev->dev,
    --
    2.34.1
    \
     
     \ /
      Last update: 2022-08-16 04:01    [W:2.611 / U:0.108 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site