diff mbox

[for-4.7,2/4] tools/xsplice: corrently use errno

Message ID 1461939680-32574-3-git-send-email-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné April 29, 2016, 2:21 p.m. UTC
Some error paths incorrectly used rc instead of errno.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 tools/misc/xen-xsplice.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Wei Liu April 29, 2016, 2:57 p.m. UTC | #1
On Fri, Apr 29, 2016 at 04:21:18PM +0200, Roger Pau Monne wrote:
> Some error paths incorrectly used rc instead of errno.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/misc/xen-xsplice.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/misc/xen-xsplice.c b/tools/misc/xen-xsplice.c
> index 0f1ab5a..695be7f 100644
> --- a/tools/misc/xen-xsplice.c
> +++ b/tools/misc/xen-xsplice.c
> @@ -273,7 +273,7 @@ int action_func(int argc, char *argv[], unsigned int idx)
>      if ( rc )
>      {
>          fprintf(stderr, "%s failed to get status (rc=%d, %s)!\n",

I think it is better to also change rc= to errno= here.

> -                name, -rc, strerror(-rc));
> +                name, errno, strerror(errno));
>          return -1;
>      }
>      if ( status.rc == -EAGAIN )
> @@ -295,7 +295,8 @@ int action_func(int argc, char *argv[], unsigned int idx)
>          rc = action_options[idx].function(xch, name, 0);
>          if ( rc )
>          {
> -            fprintf(stderr, "%s failed with %d(%s)\n", name, -rc, strerror(-rc));
> +            fprintf(stderr, "%s failed with %d(%s)\n", name, errno,
> +                    strerror(errno));
>              return -1;
>          }
>      }
> -- 
> 2.6.4 (Apple Git-63)
>
Roger Pau Monné April 29, 2016, 3:07 p.m. UTC | #2
On Fri, Apr 29, 2016 at 03:57:23PM +0100, Wei Liu wrote:
> On Fri, Apr 29, 2016 at 04:21:18PM +0200, Roger Pau Monne wrote:
> > Some error paths incorrectly used rc instead of errno.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > ---
> >  tools/misc/xen-xsplice.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/misc/xen-xsplice.c b/tools/misc/xen-xsplice.c
> > index 0f1ab5a..695be7f 100644
> > --- a/tools/misc/xen-xsplice.c
> > +++ b/tools/misc/xen-xsplice.c
> > @@ -273,7 +273,7 @@ int action_func(int argc, char *argv[], unsigned int idx)
> >      if ( rc )
> >      {
> >          fprintf(stderr, "%s failed to get status (rc=%d, %s)!\n",
> 
> I think it is better to also change rc= to errno= here.

Thanks. Yes, in fact I think I prefer the format used elsewhere in this 
file, which is:

%d(%s)

Roger.
Wei Liu April 29, 2016, 3:08 p.m. UTC | #3
On Fri, Apr 29, 2016 at 05:07:40PM +0200, Roger Pau Monne wrote:
> On Fri, Apr 29, 2016 at 03:57:23PM +0100, Wei Liu wrote:
> > On Fri, Apr 29, 2016 at 04:21:18PM +0200, Roger Pau Monne wrote:
> > > Some error paths incorrectly used rc instead of errno.
> > > 
> > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > > ---
> > > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > > Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Wei Liu <wei.liu2@citrix.com>
> > > ---
> > >  tools/misc/xen-xsplice.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tools/misc/xen-xsplice.c b/tools/misc/xen-xsplice.c
> > > index 0f1ab5a..695be7f 100644
> > > --- a/tools/misc/xen-xsplice.c
> > > +++ b/tools/misc/xen-xsplice.c
> > > @@ -273,7 +273,7 @@ int action_func(int argc, char *argv[], unsigned int idx)
> > >      if ( rc )
> > >      {
> > >          fprintf(stderr, "%s failed to get status (rc=%d, %s)!\n",
> > 
> > I think it is better to also change rc= to errno= here.
> 
> Thanks. Yes, in fact I think I prefer the format used elsewhere in this 
> file, which is:
> 
> %d(%s)
> 

That's fine, too.

Wei.

> Roger.
diff mbox

Patch

diff --git a/tools/misc/xen-xsplice.c b/tools/misc/xen-xsplice.c
index 0f1ab5a..695be7f 100644
--- a/tools/misc/xen-xsplice.c
+++ b/tools/misc/xen-xsplice.c
@@ -273,7 +273,7 @@  int action_func(int argc, char *argv[], unsigned int idx)
     if ( rc )
     {
         fprintf(stderr, "%s failed to get status (rc=%d, %s)!\n",
-                name, -rc, strerror(-rc));
+                name, errno, strerror(errno));
         return -1;
     }
     if ( status.rc == -EAGAIN )
@@ -295,7 +295,8 @@  int action_func(int argc, char *argv[], unsigned int idx)
         rc = action_options[idx].function(xch, name, 0);
         if ( rc )
         {
-            fprintf(stderr, "%s failed with %d(%s)\n", name, -rc, strerror(-rc));
+            fprintf(stderr, "%s failed with %d(%s)\n", name, errno,
+                    strerror(errno));
             return -1;
         }
     }