public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] iconv: restore verbosity with unrecognized encoding names (bug 30694)
@ 2023-08-01 15:07 Andreas Schwab
  2023-08-02 11:05 ` Arjun Shankar
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2023-08-01 15:07 UTC (permalink / raw)
  To: libc-alpha

Commit 91927b7c76 ("Rewrite iconv option parsing [BZ #19519]") changed the
iconv program to call __gconv_open directly instead of the iconv_open
wrapper, but the former does not set errno.  Update the caller to
interpret the return codes like iconv_open does.
---
 iconv/iconv_prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index bee898c63c..cf32cf9b44 100644
--- a/iconv/iconv_prog.c
+++ b/iconv/iconv_prog.c
@@ -187,7 +187,7 @@ main (int argc, char *argv[])
 
       if (res != __GCONV_OK)
 	{
-	  if (errno == EINVAL)
+	  if (res == __GCONV_NOCONV || res == __GCONV_NODB)
 	    {
 	      /* Try to be nice with the user and tell her which of the
 		 two encoding names is wrong.  This is possible because
-- 
2.41.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH] iconv: restore verbosity with unrecognized encoding names (bug 30694)
  2023-08-01 15:07 [PATCH] iconv: restore verbosity with unrecognized encoding names (bug 30694) Andreas Schwab
@ 2023-08-02 11:05 ` Arjun Shankar
  0 siblings, 0 replies; 2+ messages in thread
From: Arjun Shankar @ 2023-08-02 11:05 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

Hi Andreas,

> Commit 91927b7c76 ("Rewrite iconv option parsing [BZ #19519]") changed the
> iconv program to call __gconv_open directly instead of the iconv_open
> wrapper, but the former does not set errno.  Update the caller to
> interpret the return codes like iconv_open does.
> ---
>  iconv/iconv_prog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
> index bee898c63c..cf32cf9b44 100644
> --- a/iconv/iconv_prog.c
> +++ b/iconv/iconv_prog.c
> @@ -187,7 +187,7 @@ main (int argc, char *argv[])
>
>        if (res != __GCONV_OK)
>         {
> -         if (errno == EINVAL)
> +         if (res == __GCONV_NOCONV || res == __GCONV_NODB)
>             {
>               /* Try to be nice with the user and tell her which of the
>                  two encoding names is wrong.  This is possible because

OK. errno could have changed in ways we don't know since the
assignment we actually care about, but res contains the correct reason
returned by __gconv_open. This also aligns with iconv_open where we
set errno (as required by the standard) after checking the value of
res.

This looks good to me. Thanks!

Reviewed-by: Arjun Shankar <arjun@redhat.com>


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

end of thread, other threads:[~2023-08-02 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 15:07 [PATCH] iconv: restore verbosity with unrecognized encoding names (bug 30694) Andreas Schwab
2023-08-02 11:05 ` Arjun Shankar

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).