* [PATCH] Staging: wlan-ng: Handle error condition.
@ 2016-02-28 3:36 Sandhya Bankar
2016-02-28 12:01 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Sandhya Bankar @ 2016-02-28 3:36 UTC (permalink / raw)
To: outreachy-kernel
Handle error condition.
Below semantic patch found,their is double assignment to 'result' variable.so instead of deleting double assignment,handling error condition for "result = mkimage(..)".
@@
expression e1,e2,e3;
@@
(
(<+...e1++...+>)=e2;
|
(<+...e1--...+>)=e2;
|
(<+...++e1...+>)=e2;
|
(<+...--e1...+>)=e2;
|
e1=e2;
e1 = <+...e1...+>;
|
*e1=e2;
*e1=e3;
Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
---
drivers/staging/wlan-ng/prism2fw.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 8fc80df..35fd5fb 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -333,6 +333,10 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
/* Make the image chunks */
result = mkimage(fchunk, &nfchunks);
+ if (result) {
+ netdev_err(wlandev->netdev, "Failed to make image chunk.\n");
+ return 1;
+ }
/* Do any plugging */
result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
--
1.8.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] Staging: wlan-ng: Handle error condition.
2016-02-28 3:36 [PATCH] Staging: wlan-ng: Handle error condition Sandhya Bankar
@ 2016-02-28 12:01 ` Julia Lawall
2016-02-28 13:01 ` sandhya bankar
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2016-02-28 12:01 UTC (permalink / raw)
To: Sandhya Bankar; +Cc: outreachy-kernel
On Sun, 28 Feb 2016, Sandhya Bankar wrote:
> Handle error condition.
> Below semantic patch found,their is double assignment to 'result' variable.so instead of deleting double assignment,handling error condition for "result = mkimage(..)".
> @@
> expression e1,e2,e3;
> @@
>
> (
> (<+...e1++...+>)=e2;
> |
> (<+...e1--...+>)=e2;
> |
> (<+...++e1...+>)=e2;
> |
> (<+...--e1...+>)=e2;
> |
> e1=e2;
> e1 = <+...e1...+>;
> |
> *e1=e2;
> *e1=e3;
>
> Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
> ---
> drivers/staging/wlan-ng/prism2fw.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
> index 8fc80df..35fd5fb 100644
> --- a/drivers/staging/wlan-ng/prism2fw.c
> +++ b/drivers/staging/wlan-ng/prism2fw.c
> @@ -333,6 +333,10 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
>
> /* Make the image chunks */
> result = mkimage(fchunk, &nfchunks);
> + if (result) {
> + netdev_err(wlandev->netdev, "Failed to make image chunk.\n");
> + return 1;
> + }
Perhaps it would be possible to move this code away from using 1 for
failure, towards using actual error codes.
julia
>
> /* Do any plugging */
> result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160228033629.GA7898%40sandhya.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] Staging: wlan-ng: Handle error condition.
2016-02-28 12:01 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-28 13:01 ` sandhya bankar
2016-02-28 13:04 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: sandhya bankar @ 2016-02-28 13:01 UTC (permalink / raw)
To: Julia Lawall, outreachy-kernel
[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]
The mkimage(..) is returning error i.e return 1 from below error code path,
First error condition is if kzalloc(..) has failed,then return 1.
Second error condition is if chunk mismatch then it return 1.
I also checked the prism2_fwapply(..) in every error condition,it is
returning 1,so i have used return 1 in above patch.
Do you have any suggestion ?
On Sun, Feb 28, 2016 at 5:31 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Sun, 28 Feb 2016, Sandhya Bankar wrote:
>
> > Handle error condition.
> > Below semantic patch found,their is double assignment to 'result'
> variable.so instead of deleting double assignment,handling error condition
> for "result = mkimage(..)".
> > @@
> > expression e1,e2,e3;
> > @@
> >
> > (
> > (<+...e1++...+>)=e2;
> > |
> > (<+...e1--...+>)=e2;
> > |
> > (<+...++e1...+>)=e2;
> > |
> > (<+...--e1...+>)=e2;
> > |
> > e1=e2;
> > e1 = <+...e1...+>;
> > |
> > *e1=e2;
> > *e1=e3;
> >
> > Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
> > ---
> > drivers/staging/wlan-ng/prism2fw.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/staging/wlan-ng/prism2fw.c
> b/drivers/staging/wlan-ng/prism2fw.c
> > index 8fc80df..35fd5fb 100644
> > --- a/drivers/staging/wlan-ng/prism2fw.c
> > +++ b/drivers/staging/wlan-ng/prism2fw.c
> > @@ -333,6 +333,10 @@ static int prism2_fwapply(const struct ihex_binrec
> *rfptr,
> >
> > /* Make the image chunks */
> > result = mkimage(fchunk, &nfchunks);
> > + if (result) {
> > + netdev_err(wlandev->netdev, "Failed to make image
> chunk.\n");
> > + return 1;
> > + }
>
> Perhaps it would be possible to move this code away from using 1 for
> failure, towards using actual error codes.
>
> julia
>
> >
> > /* Do any plugging */
> > result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
> > --
> > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/outreachy-kernel/20160228033629.GA7898%40sandhya
> .
> > For more options, visit https://groups.google.com/d/optout.
> >
>
[-- Attachment #2: Type: text/html, Size: 3772 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] Staging: wlan-ng: Handle error condition.
2016-02-28 13:01 ` sandhya bankar
@ 2016-02-28 13:04 ` Julia Lawall
2016-02-28 13:19 ` sandhya bankar
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2016-02-28 13:04 UTC (permalink / raw)
To: sandhya bankar; +Cc: outreachy-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 3199 bytes --]
On Sun, 28 Feb 2016, sandhya bankar wrote:
> The mkimage(..) is returning error i.e return 1 from below error code path,
> First error condition is if kzalloc(..) has failed,then return 1.
> Second error condition is if chunk mismatch then it return 1.
>
> I also checked the prism2_fwapply(..) in every error condition,it is
> returning 1,so i have used return 1 in above patch.
Yes, I see that they are returning 1 everywhere, so there is no problem
with the patch. But the whole code should be improved to return proper
error codes, like -ENOMEM on allocation failure, rather than 1. There are
even some comments in the code saying that typically an error code is
returned on failure, but that is not the case. 1 indeed looks more like
success (true).
julia
>
>
> Do you have any suggestion ?
>
> On Sun, Feb 28, 2016 at 5:31 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Sun, 28 Feb 2016, Sandhya Bankar wrote:
>
> > Handle error condition.
> > Below semantic patch found,their is double assignment to
> 'result' variable.so instead of deleting double
> assignment,handling error condition for "result = mkimage(..)".
> > @@
> > expression e1,e2,e3;
> > @@
> >
> > (
> > (<+...e1++...+>)=e2;
> > |
> > (<+...e1--...+>)=e2;
> > |
> > (<+...++e1...+>)=e2;
> > |
> > (<+...--e1...+>)=e2;
> > |
> > e1=e2;
> > e1 = <+...e1...+>;
> > |
> > *e1=e2;
> > *e1=e3;
> >
> > Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
> > ---
> > drivers/staging/wlan-ng/prism2fw.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/staging/wlan-ng/prism2fw.c
> b/drivers/staging/wlan-ng/prism2fw.c
> > index 8fc80df..35fd5fb 100644
> > --- a/drivers/staging/wlan-ng/prism2fw.c
> > +++ b/drivers/staging/wlan-ng/prism2fw.c
> > @@ -333,6 +333,10 @@ static int prism2_fwapply(const struct
> ihex_binrec *rfptr,
> >
> > /* Make the image chunks */
> > result = mkimage(fchunk, &nfchunks);
> > + if (result) {
> > + netdev_err(wlandev->netdev, "Failed to make
> image chunk.\n");
> > + return 1;
> > + }
>
> Perhaps it would be possible to move this code away from using 1 for
> failure, towards using actual error codes.
>
> julia
>
> >
> > /* Do any plugging */
> > result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
> > --
> > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to
> outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20160228033629.GA7898%4
> 0sandhya.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] Staging: wlan-ng: Handle error condition.
2016-02-28 13:04 ` Julia Lawall
@ 2016-02-28 13:19 ` sandhya bankar
0 siblings, 0 replies; 5+ messages in thread
From: sandhya bankar @ 2016-02-28 13:19 UTC (permalink / raw)
To: Julia Lawall, outreachy-kernel
[-- Attachment #1: Type: text/plain, Size: 3511 bytes --]
Thanks for suggestion !!. I shall try to fix proper return error codes
through another patch .
On Sun, Feb 28, 2016 at 6:34 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Sun, 28 Feb 2016, sandhya bankar wrote:
>
> > The mkimage(..) is returning error i.e return 1 from below error code
> path,
> > First error condition is if kzalloc(..) has failed,then return 1.
> > Second error condition is if chunk mismatch then it return 1.
> >
> > I also checked the prism2_fwapply(..) in every error condition,it is
> > returning 1,so i have used return 1 in above patch.
>
> Yes, I see that they are returning 1 everywhere, so there is no problem
> with the patch. But the whole code should be improved to return proper
> error codes, like -ENOMEM on allocation failure, rather than 1. There are
> even some comments in the code saying that typically an error code is
> returned on failure, but that is not the case. 1 indeed looks more like
> success (true).
>
> julia
>
> >
> >
> > Do you have any suggestion ?
> >
> > On Sun, Feb 28, 2016 at 5:31 PM, Julia Lawall <julia.lawall@lip6.fr>
> wrote:
> >
> >
> > On Sun, 28 Feb 2016, Sandhya Bankar wrote:
> >
> > > Handle error condition.
> > > Below semantic patch found,their is double assignment to
> > 'result' variable.so instead of deleting double
> > assignment,handling error condition for "result = mkimage(..)".
> > > @@
> > > expression e1,e2,e3;
> > > @@
> > >
> > > (
> > > (<+...e1++...+>)=e2;
> > > |
> > > (<+...e1--...+>)=e2;
> > > |
> > > (<+...++e1...+>)=e2;
> > > |
> > > (<+...--e1...+>)=e2;
> > > |
> > > e1=e2;
> > > e1 = <+...e1...+>;
> > > |
> > > *e1=e2;
> > > *e1=e3;
> > >
> > > Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
> > > ---
> > > drivers/staging/wlan-ng/prism2fw.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/staging/wlan-ng/prism2fw.c
> > b/drivers/staging/wlan-ng/prism2fw.c
> > > index 8fc80df..35fd5fb 100644
> > > --- a/drivers/staging/wlan-ng/prism2fw.c
> > > +++ b/drivers/staging/wlan-ng/prism2fw.c
> > > @@ -333,6 +333,10 @@ static int prism2_fwapply(const struct
> > ihex_binrec *rfptr,
> > >
> > > /* Make the image chunks */
> > > result = mkimage(fchunk, &nfchunks);
> > > + if (result) {
> > > + netdev_err(wlandev->netdev, "Failed to make
> > image chunk.\n");
> > > + return 1;
> > > + }
> >
> > Perhaps it would be possible to move this code away from using 1 for
> > failure, towards using actual error codes.
> >
> > julia
> >
> > >
> > > /* Do any plugging */
> > > result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
> > > --
> > > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > > To post to this group, send email to
> > outreachy-kernel@googlegroups.com.
> > > To view this discussion on the web visithttps://
> groups.google.com/d/msgid/outreachy-kernel/20160228033629.GA7898%4
> > 0sandhya.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> >
> >
> >
>
[-- Attachment #2: Type: text/html, Size: 5356 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-02-28 13:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 3:36 [PATCH] Staging: wlan-ng: Handle error condition Sandhya Bankar
2016-02-28 12:01 ` [Outreachy kernel] " Julia Lawall
2016-02-28 13:01 ` sandhya bankar
2016-02-28 13:04 ` Julia Lawall
2016-02-28 13:19 ` sandhya bankar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.