Staging: Correct the argument of sizeof().
cover Staging: Correct the argument of sizeof().
Correct the argument of sizeof().
Used below coccinelle semantic patch:
@disable sizeof_type_expr@
type T;
T **x;
@@
x =
<+...sizeof(
- T
+ *x
)...+>
Sandhya Bankar (3):
Staging: rtl8188eu: rtw_efuse: Correct the argument of sizeof().
Staging: lustre: rpc: Correct the argument of sizeof().
Staging: lustre: o2iblnd: Correct the argument of sizeof().
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.3.4
PATCH 1/3 Staging: rtl8188eu: rtw_efuse: Correct the argument of sizeof().
Correct the argument of sizeof().
--- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_efuse.c +1 -1
@@ -107,7 +107,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf)if (!efuseTbl)return ; - eFuseWord = (u16 **)rtw_malloc2d (EFUSE_MAX_SECTION_88E ,EFUSE_MAX_WORD_UNIT ,sizeof (u16)); + eFuseWord = (u16 **)rtw_malloc2d (EFUSE_MAX_SECTION_88E ,EFUSE_MAX_WORD_UNIT ,sizeof (*eFuseWord));if (!eFuseWord) {DBG_88E ("%s: alloc eFuseWord fail!\n" , __func__); goto eFuseWord_failed;
Signature · 1 line
1.8.3.4
PATCH 2/3 Staging: lustre: rpc: Correct the argument of sizeof().
In reply to Sandhya BankarCorrect the argument of sizeof().
--- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/rpc.c +1 -1
@@ -256,7 +256,7 @@ srpc_service_init(struct srpc_service *svc) svc->sv_shuttingdown =0 ; svc->sv_cpt_data =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (struct srpc_service_cd )); +sizeof (*svc->sv_cpt_data));if (!svc->sv_cpt_data)return -ENOMEM ;
Signature · 1 line
1.8.3.4
PATCH 3/3 Staging: lustre: o2iblnd: Correct the argument of sizeof().
In reply to Sandhya BankarCorrect the argument of sizeof().
--- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +2 -2
@@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)*/ net->ibn_fmr_ps =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (kib_fmr_poolset_t)); +sizeof (*net->ibn_fmr_ps));if (!net->ibn_fmr_ps) {CERROR ("Failed to allocate FMR pool array\n" ); rc = -ENOMEM ;
@@ -1992,7 +1992,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) create_tx_pool: net->ibn_tx_ps =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (kib_tx_poolset_t)); +sizeof (*net->ibn_tx_ps));if (!net->ibn_tx_ps) {CERROR ("Failed to allocate tx pool array\n" ); rc = -ENOMEM ;
Signature · 1 line
1.8.3.4
Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: o2iblnd: Correct the argument of sizeof().
Quoted 1 line · Sandhya Bankar
Correct the argument of
sizeof().
What do you mean by correct? Was the value wrong before, ie 27 when it should have been 45? Or is it a coding style issue, ie *x instead of a type name?
julia
Quoted 38 lines
Signed-off-by Sandhya Bankar <[email protected]>--- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +2
-3@@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)*/ net->ibn_fmr_ps =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (kib_fmr_poolset_t)); +sizeof (*net->ibn_fmr_ps));if (!net->ibn_fmr_ps) {CERROR ("Failed to allocate FMR pool array\n" ); rc = -ENOMEM ;@@ -1992,7 +1992,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) create_tx_pool: net->ibn_tx_ps =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (kib_tx_poolset_t)); +sizeof (*net->ibn_tx_ps));if (!net->ibn_tx_ps) {CERROR ("Failed to allocate tx pool array\n" ); rc = -ENOMEM ; --1.8.3.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/ed2d6f01c194ec9700dcec61409dc30e892136ad.1458454678.git.bankarsandhya512%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
A message that is not in the archive (sent off-list or not yet received): CAA3ASzk+Q7sywUpFqU6KekhHyGRZCAz63osZTGbJ5P+xYs2ifA@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): alpine.DEB.2.10.1603201633370.2597@hadrien
Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: o2iblnd: Correct the argument of sizeof().
To prepare this patch i have used following cocci file. Description mentioned below:
@disable sizeof_type_expr@
type T;
T **x;
@@
x =
<+...sizeof(
- T
+ *x
)...+>
whose description is as below:
badty/badty.cocci - Correct the size argument to kzalloc
obj has type struct snmp_object **, not struct snmp_object *. But
indeed
it is not even clear why kmalloc is needed. The memory is freed by the
end
of the function, so the local variable of pointer type should be
sufficient.
that's why i have used "Correct" word in heading. Please let me know if patch v2 is required with different heading?
Thanks,
Sandhya
Quoted 100 lines · Julia Lawall
Quoted 9 lines · sandhya bankar
Yes.It is coding style issue.
I have read following description:
badty/badty.cocci- Correct the size argument to kzalloc
obj has type structsnmp_object**, not structsnmp_object*. But
indeed
it is not even clear why kmalloc is needed. The memory is freed bythe
Quoted 5 lines
end
of the function, so the local variable of pointer type should be
sufficientwhat it would be for patch v2?
Sorry, but I don't understand the above at all.
julia
Quoted 7 lines
Thanks,
SandhyaOn Sun, Mar 20, 2016 at 8:01 PM, Julia Lawall <[email protected]>
Quoted 51 lines · wrote:
On Sun, 20 Mar 2016, Sandhya Bankar wrote: > Correct the argument of sizeof(). What do you mean by correct? Was the value wrong before, ie 27 when it should have been 45? Or is it a coding style issue, ie *x instead of a type name? julia > > Signed-off-by: Sandhya Bankar <[email protected]> > --- > drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 0d32e65..89f9390 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) > */ > > net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(), > - sizeof(kib_fmr_poolset_t)); > + sizeof(*net->ibn_fmr_ps)); > if (!net->ibn_fmr_ps) { > CERROR("Failed to allocate FMR pool array\n"); > rc = -ENOMEM; > @@ -1992,7 +1992,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) > > create_tx_pool: > net->ibn_tx_ps = cfs_percpt_alloc(lnet_cpt_table(), > - sizeof(kib_tx_poolset_t)); > + sizeof(*net->ibn_tx_ps)); > if (!net->ibn_tx_ps) { > CERROR("Failed to allocate tx pool array\n"); > rc = -ENOMEM; > -- > 1.8.3.4 >Quoted 8 lines
Quoted 2 lines
--
You received this message because you are subscribed to the GoogleGroups "outreachy-kernel" group.
Quoted 1 line
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
Quoted 1 line
To post to this group, send email to
Quoted 1 line
To view this discussion on the web visithttps://
groups.google.com/d/msgid/outreachy-kernel/ed2d6f01c194ec9700dcec61
Quoted 7 lines
409dc30e892136ad.1458454678.git.bankarsandhya512%40gmail.com.
Quoted 2 lines
For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: o2iblnd: Correct the argument of sizeof().
Quoted 25 lines · sandhya bankar
To prepare this patch i have used following cocci file. Description mentioned below:
@disable sizeof_type_expr@
type T;
T **x;
@@x =
<+...sizeof(
- T
+ *x
)...+>whose description is as below:
badty/badty.cocci- Correct the size argument to kzallocobj has type struct
snmp_object**, not structsnmp_object*. But indeed
it is not even clear why kmalloc is needed. The memory is freed by the end
of the function, so the local variable of pointer type should be sufficient.
Quoted 2 lines
that's why i have used "Correct" word in heading. Please let me know if patch v2 is required with different heading?
You need to understand what the semantic patch is doing, and explain what the transformed code does and why it is wrong. I guess that this semantic patch comes from coccinellery. The descriptions there are autogenerated from a patch that uses the given semantic patch. In this case, the coccinellery description is not useful.
julia
Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: o2iblnd: Correct the argument of sizeof().
Thanks..!! I got it.I will send patch v2.
Quoted 40 lines · Julia Lawall
Quoted 14 lines · sandhya bankar
To prepare this patch i have used following cocci file. Description mentioned below:
@disable sizeof_type_expr@
type T;
T **x;
@@x =
<+...sizeof(
- T
+ *x
)...+>Quoted 7 lines
whose description is as below:
badty/badty.cocci- Correct the size argument to kzallocobj has type struct
snmp_object**, not structsnmp_object*. But
indeed
it is not even clear why kmalloc is needed. The memory is freed bythe
Quoted 6 lines
end
of the function, so the local variable of pointer type should be
sufficient.that's why i have used "Correct" word in heading. Please let me know if patch v2 is required with different heading?
You need to understand what the semantic patch is doing, and explain what the transformed code does and why it is wrong. I guess that this semantic patch comes from coccinellery. The descriptions there are autogenerated from a patch that uses the given semantic patch. In this case, the coccinellery description is not useful.
julia