x86: Don't make 2 calls to dlerror () in a row
diff mbox series

Message ID CAMe9rOrh3EiT4xGxDq48rPkVGjT9W97fQkK01N0t3C5JFQ+uzQ@mail.gmail.com
State New
Headers show
Series
  • x86: Don't make 2 calls to dlerror () in a row
Related show

Commit Message

H.J. Lu Jan. 17, 2020, 7:02 p.m. UTC
We shouldn't make 2 calls to dlerror () in a row since the first call
will clear the error.  We should just use the return value from the
first call.

Tested on Linux/x86-64.

Comments

Florian Weimer Jan. 17, 2020, 9:53 p.m. UTC | #1
* H. J. Lu:

> We shouldn't make 2 calls to dlerror () in a row since the first call
> will clear the error.  We should just use the return value from the
> first call.
>
> Tested on Linux/x86-64.
>
> -- 
> H.J.
>
> From 7fe7a18b7bed14bc2da616281d72b2bdbe26b41c Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Fri, 17 Jan 2020 10:13:43 -0800
> Subject: [PATCH] x86: Don't make 2 calls to dlerror () in a row
>
> We shouldn't make 2 calls to dlerror () in a row since the first call
> will clear the error.  We should just use the return value from the
> first call.
>
> Tested on Linux/x86-64.
> ---
>  sysdeps/x86/tst-cet-legacy-5.c | 2 +-
>  sysdeps/x86/tst-cet-legacy-6.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/x86/tst-cet-legacy-5.c b/sysdeps/x86/tst-cet-legacy-5.c
> index b97e03d634..6c9bba06f5 100644
> --- a/sysdeps/x86/tst-cet-legacy-5.c
> +++ b/sysdeps/x86/tst-cet-legacy-5.c
> @@ -38,7 +38,7 @@ do_test_1 (const char *modname, bool fail)
>  	  if (strstr (err, "shadow stack isn't enabled") == NULL)
>  	    {
>  	      printf ("incorrect dlopen '%s' error: %s\n", modname,
> -		      dlerror ());
> +		      err);
>  	      exit (1);
>  	    }
>  
> diff --git a/sysdeps/x86/tst-cet-legacy-6.c b/sysdeps/x86/tst-cet-legacy-6.c
> index 3c4a47f2db..877e77747d 100644
> --- a/sysdeps/x86/tst-cet-legacy-6.c
> +++ b/sysdeps/x86/tst-cet-legacy-6.c
> @@ -38,7 +38,7 @@ do_test_1 (const char *modname, bool fail)
>  	  if (strstr (err, "shadow stack isn't enabled") == NULL)
>  	    {
>  	      printf ("incorrect dlopen '%s' error: %s\n", modname,
> -		      dlerror ());
> +		      err);
>  	      exit (1);
>  	    }

You could FAIL_EXIT1 for this.  But the change looks good to me as is.

Thanks,
Florian
H.J. Lu Feb. 1, 2020, 1:42 p.m. UTC | #2
On Fri, Jan 17, 2020 at 1:53 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > We shouldn't make 2 calls to dlerror () in a row since the first call
> > will clear the error.  We should just use the return value from the
> > first call.
> >
> > Tested on Linux/x86-64.
> >
> > --
> > H.J.
> >
> > From 7fe7a18b7bed14bc2da616281d72b2bdbe26b41c Mon Sep 17 00:00:00 2001
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Fri, 17 Jan 2020 10:13:43 -0800
> > Subject: [PATCH] x86: Don't make 2 calls to dlerror () in a row
> >
> > We shouldn't make 2 calls to dlerror () in a row since the first call
> > will clear the error.  We should just use the return value from the
> > first call.
> >
> > Tested on Linux/x86-64.
> > ---
> >  sysdeps/x86/tst-cet-legacy-5.c | 2 +-
> >  sysdeps/x86/tst-cet-legacy-6.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/sysdeps/x86/tst-cet-legacy-5.c b/sysdeps/x86/tst-cet-legacy-5.c
> > index b97e03d634..6c9bba06f5 100644
> > --- a/sysdeps/x86/tst-cet-legacy-5.c
> > +++ b/sysdeps/x86/tst-cet-legacy-5.c
> > @@ -38,7 +38,7 @@ do_test_1 (const char *modname, bool fail)
> >         if (strstr (err, "shadow stack isn't enabled") == NULL)
> >           {
> >             printf ("incorrect dlopen '%s' error: %s\n", modname,
> > -                   dlerror ());
> > +                   err);
> >             exit (1);
> >           }
> >
> > diff --git a/sysdeps/x86/tst-cet-legacy-6.c b/sysdeps/x86/tst-cet-legacy-6.c
> > index 3c4a47f2db..877e77747d 100644
> > --- a/sysdeps/x86/tst-cet-legacy-6.c
> > +++ b/sysdeps/x86/tst-cet-legacy-6.c
> > @@ -38,7 +38,7 @@ do_test_1 (const char *modname, bool fail)
> >         if (strstr (err, "shadow stack isn't enabled") == NULL)
> >           {
> >             printf ("incorrect dlopen '%s' error: %s\n", modname,
> > -                   dlerror ());
> > +                   err);
> >             exit (1);
> >           }
>
> You could FAIL_EXIT1 for this.  But the change looks good to me as is.
>

I am checking my patch in as is.

Thanks.

Patch
diff mbox series

From 7fe7a18b7bed14bc2da616281d72b2bdbe26b41c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 17 Jan 2020 10:13:43 -0800
Subject: [PATCH] x86: Don't make 2 calls to dlerror () in a row

We shouldn't make 2 calls to dlerror () in a row since the first call
will clear the error.  We should just use the return value from the
first call.

Tested on Linux/x86-64.
---
 sysdeps/x86/tst-cet-legacy-5.c | 2 +-
 sysdeps/x86/tst-cet-legacy-6.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/x86/tst-cet-legacy-5.c b/sysdeps/x86/tst-cet-legacy-5.c
index b97e03d634..6c9bba06f5 100644
--- a/sysdeps/x86/tst-cet-legacy-5.c
+++ b/sysdeps/x86/tst-cet-legacy-5.c
@@ -38,7 +38,7 @@  do_test_1 (const char *modname, bool fail)
 	  if (strstr (err, "shadow stack isn't enabled") == NULL)
 	    {
 	      printf ("incorrect dlopen '%s' error: %s\n", modname,
-		      dlerror ());
+		      err);
 	      exit (1);
 	    }
 
diff --git a/sysdeps/x86/tst-cet-legacy-6.c b/sysdeps/x86/tst-cet-legacy-6.c
index 3c4a47f2db..877e77747d 100644
--- a/sysdeps/x86/tst-cet-legacy-6.c
+++ b/sysdeps/x86/tst-cet-legacy-6.c
@@ -38,7 +38,7 @@  do_test_1 (const char *modname, bool fail)
 	  if (strstr (err, "shadow stack isn't enabled") == NULL)
 	    {
 	      printf ("incorrect dlopen '%s' error: %s\n", modname,
-		      dlerror ());
+		      err);
 	      exit (1);
 	    }
 
-- 
2.24.1