All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3)
@ 2024-03-29  0:21 Fedor Lapshin
  2024-03-29  0:24 ` Fedor Lapshin
  2024-03-30 22:55 ` Alejandro Colomar
  0 siblings, 2 replies; 3+ messages in thread
From: Fedor Lapshin @ 2024-03-29  0:21 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

Signed-off-by: Fedor Lapshin <fe.lap.prog@gmail.com>
---
 man3/getgrouplist.3 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
index 41389b6c3..e2e640d56 100644
--- a/man3/getgrouplist.3
+++ b/man3/getgrouplist.3
@@ -162,10 +162,12 @@ main(int argc, char *argv[])
 \&
     /* Fetch passwd structure (contains first group ID for user). */
 \&
+    errno = 0;
     pw = getpwnam(argv[1]);
     if (pw == NULL) {
-        perror("getpwnam");
-        exit(EXIT_SUCCESS);
+        if (errno) perror("getpwnam");
+        else fprintf(stderr, "no such user\en");
+        exit(EXIT_FAILURE);
     }
 \&
     /* Retrieve group list. */
--
2.34.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3)
  2024-03-29  0:21 [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3) Fedor Lapshin
@ 2024-03-29  0:24 ` Fedor Lapshin
  2024-03-30 22:55 ` Alejandro Colomar
  1 sibling, 0 replies; 3+ messages in thread
From: Fedor Lapshin @ 2024-03-29  0:24 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

For some reason my mail client decided to not reply to the previous thread.
Yet again, sorry for the mess. This patch was related to our previous
discussion on getgrouplist

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3)
  2024-03-29  0:21 [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3) Fedor Lapshin
  2024-03-29  0:24 ` Fedor Lapshin
@ 2024-03-30 22:55 ` Alejandro Colomar
  1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2024-03-30 22:55 UTC (permalink / raw)
  To: Fedor Lapshin; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

On Fri, Mar 29, 2024 at 03:21:11AM +0300, Fedor Lapshin wrote:
> Signed-off-by: Fedor Lapshin <fe.lap.prog@gmail.com>

Hi Fedor,

Patch applied, with some tweaks.  Thanks!

Have a lovely night!
Alex

> ---
>  man3/getgrouplist.3 | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
> index 41389b6c3..e2e640d56 100644
> --- a/man3/getgrouplist.3
> +++ b/man3/getgrouplist.3
> @@ -162,10 +162,12 @@ main(int argc, char *argv[])
>  \&
>      /* Fetch passwd structure (contains first group ID for user). */
>  \&
> +    errno = 0;
>      pw = getpwnam(argv[1]);
>      if (pw == NULL) {
> -        perror("getpwnam");
> -        exit(EXIT_SUCCESS);
> +        if (errno) perror("getpwnam");
> +        else fprintf(stderr, "no such user\en");
> +        exit(EXIT_FAILURE);
>      }
>  \&
>      /* Retrieve group list. */
> --
> 2.34.1
> 

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-30 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29  0:21 [PATCH] getgrouplist.3: EXAMPLES: improve error handling for getpwnam(3) Fedor Lapshin
2024-03-29  0:24 ` Fedor Lapshin
2024-03-30 22:55 ` Alejandro Colomar

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.