[PATCH] staging: kpc2000: Use memset to initialize resources

Dan Carpenter dan.carpenter at oracle.com
Tue Apr 30 09:12:42 UTC 2019


On Wed, Apr 24, 2019 at 11:57:43AM -0700, Nathan Chancellor wrote:
> diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> index ad2cc0a3bfa1..13f544f3c0b9 100644
> --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
> +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> @@ -93,8 +93,8 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co
>  int  probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte)
>  {
>      struct mfd_cell  cell = {0};
> -    struct resource  resources[2] = {0};
> -    
> +    struct resource  resources[2];
> +
>      struct kpc_core_device_platdata  core_pdata = {

Greg already applied this and that's cool but I would have probably
gone with "struct resource resources[2] = {};".  memset() is only
required if we want to clear out the struct holes because we're going to
copy the whole struct to userspace.  (Some compilers will change
foo = {} into "foo.a = 0; foo.b = 0;" when it's faster than doing a
memset, so the struct holes don't always get cleared).

Also it was risky from a process perspective to delete the stray tab
from the next line because some one could have argued that it was
unrelated or that the whole line should be removed instead.  You would
have had to redo the patch for something silly... #YOLO #LivingOnTheEdge

But in this case, it's already applied so everything worked out. :)

regards,
dan carpenter



More information about the devel mailing list