From 9ec31e57278ffc4e680ef03e75ce5b6b02e5edcf Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sat, 20 May 2023 14:55:29 +0300 Subject: hurd: Use __hurd_fail () instead of assigning errno The __hurd_fail () inline function is the dedicated, idiomatic way of reporting errors in the Hurd part of glibc. Not only is it more concise than '{ errno = err; return -1; }', it is since commit 6639cc10029e24e06b34e169712b21c31b8cf213 "hurd: Mark error functions as __COLD" marked with the cold attribute, telling the compiler that this codepath is unlikely to be executed. In one case, use __hurd_dfail () over the plain __hurd_fail (). Signed-off-by: Sergey Bugaev Message-Id: <20230520115531.3911877-1-bugaevc@gmail.com> --- sysdeps/mach/hurd/getlogin_r.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sysdeps/mach/hurd/getlogin_r.c') diff --git a/sysdeps/mach/hurd/getlogin_r.c b/sysdeps/mach/hurd/getlogin_r.c index 2e43225182..c1a2f14e5e 100644 --- a/sysdeps/mach/hurd/getlogin_r.c +++ b/sysdeps/mach/hurd/getlogin_r.c @@ -31,14 +31,11 @@ __getlogin_r (char *name, size_t name_len) error_t err; if (err = __USEPORT (PROC, __proc_getlogin (port, login))) - return errno = err; + return __hurd_fail (err), err; size_t len = __strnlen (login, sizeof login - 1) + 1; if (len > name_len) - { - errno = ERANGE; - return errno; - } + return __hurd_fail (ERANGE), ERANGE; memcpy (name, login, len); return 0; -- cgit 1.4.1