public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Samuel Thibault <sthibaul@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] htl: Use __hurd_fail () instead of assigning errno
Date: Sat, 20 May 2023 16:16:53 +0000 (GMT)	[thread overview]
Message-ID: <20230520161653.4E1993856DDE@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=70d0dda0c160cb1f9000a4da50baf27c63db51c8

commit 70d0dda0c160cb1f9000a4da50baf27c63db51c8
Author: Sergey Bugaev <bugaevc@gmail.com>
Date:   Sat May 20 14:55:30 2023 +0300

    htl: Use __hurd_fail () instead of assigning errno
    
    Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
    Message-Id: <20230520115531.3911877-2-bugaevc@gmail.com>

Diff:
---
 sysdeps/htl/sem-destroy.c |  6 ++----
 sysdeps/htl/sem-init.c    |  6 ++----
 sysdeps/htl/sem-post.c    | 11 +++--------
 sysdeps/htl/sem-trywait.c |  4 ++--
 4 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/sysdeps/htl/sem-destroy.c b/sysdeps/htl/sem-destroy.c
index 3e40151bb1..84a35ed5be 100644
--- a/sysdeps/htl/sem-destroy.c
+++ b/sysdeps/htl/sem-destroy.c
@@ -19,6 +19,7 @@
 #include <semaphore.h>
 #include <errno.h>
 
+#include <hurd.h>
 #include <pt-internal.h>
 
 int
@@ -34,10 +35,7 @@ __sem_destroy (sem_t *sem)
 #endif
       )
     /* There are threads waiting on *SEM.  */
-    {
-      errno = EBUSY;
-      return -1;
-    }
+    return __hurd_fail (EBUSY);
 
   return 0;
 }
diff --git a/sysdeps/htl/sem-init.c b/sysdeps/htl/sem-init.c
index f04bbfdc77..f2954acd60 100644
--- a/sysdeps/htl/sem-init.c
+++ b/sysdeps/htl/sem-init.c
@@ -19,6 +19,7 @@
 #include <semaphore.h>
 #include <errno.h>
 
+#include <hurd.h>
 #include <pt-internal.h>
 
 int
@@ -26,10 +27,7 @@ __sem_init (sem_t *sem, int pshared, unsigned value)
 {
 #ifdef SEM_VALUE_MAX
   if (value > SEM_VALUE_MAX)
-    {
-      errno = EINVAL;
-      return -1;
-    }
+    return __hurd_fail (EINVAL);
 #endif
 
   struct new_sem *isem = (struct new_sem *) sem;
diff --git a/sysdeps/htl/sem-post.c b/sysdeps/htl/sem-post.c
index e283161a35..c57458c140 100644
--- a/sysdeps/htl/sem-post.c
+++ b/sysdeps/htl/sem-post.c
@@ -20,6 +20,7 @@
 #include <assert.h>
 
 #include <hurdlock.h>
+#include <hurd.h>
 
 #include <pt-internal.h>
 
@@ -35,10 +36,7 @@ __sem_post (sem_t *sem)
   do
     {
       if ((d & SEM_VALUE_MASK) == SEM_VALUE_MAX)
-	{
-	  errno = EOVERFLOW;
-	  return -1;
-	}
+	return __hurd_fail (EOVERFLOW);
     }
   while (!atomic_compare_exchange_weak_release (&isem->data, &d, d + 1));
 
@@ -51,10 +49,7 @@ __sem_post (sem_t *sem)
   do
     {
       if ((v >> SEM_VALUE_SHIFT) == SEM_VALUE_MAX)
-	{
-	  errno = EOVERFLOW;
-	  return -1;
-	}
+	return __hurd_fail (EOVERFLOW);
     }
   while (!atomic_compare_exchange_weak_release
 	  (&isem->value, &v, v + (1 << SEM_VALUE_SHIFT)));
diff --git a/sysdeps/htl/sem-trywait.c b/sysdeps/htl/sem-trywait.c
index 0959092e10..43aa185c27 100644
--- a/sysdeps/htl/sem-trywait.c
+++ b/sysdeps/htl/sem-trywait.c
@@ -19,6 +19,7 @@
 #include <semaphore.h>
 #include <errno.h>
 
+#include <hurd.h>
 #include <pt-internal.h>
 
 int
@@ -29,8 +30,7 @@ __sem_trywait (sem_t *sem)
   if (__sem_waitfast (isem, 1) == 0)
     return 0;
 
-  errno = EAGAIN;
-  return -1;
+  return __hurd_fail (EAGAIN);
 }
 
 weak_alias (__sem_trywait, sem_trywait);

                 reply	other threads:[~2023-05-20 16:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230520161653.4E1993856DDE@sourceware.org \
    --to=sthibaul@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).