diff mbox series

[v2] sign-file: Fix confusing error messages

Message ID 20210624104824.82616-1-tianjia.zhang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series [v2] sign-file: Fix confusing error messages | expand

Commit Message

tianjia.zhang June 24, 2021, 10:48 a.m. UTC
When an error occurs, use errx() instead of err() to display the
error message, because openssl has its own error record. When an
error occurs, errno will not be changed, while err() displays the
errno error message. It will cause confusion. For example, when
CMS_add1_signer() fails, the following message will appear:

  sign-file: CMS_add1_signer: Success

errx() ignores errno and does not cause such issue.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 scripts/sign-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

tianjia.zhang Sept. 18, 2021, 2:25 a.m. UTC | #1
ping.

On 6/24/21 6:48 PM, Tianjia Zhang wrote:
> When an error occurs, use errx() instead of err() to display the
> error message, because openssl has its own error record. When an
> error occurs, errno will not be changed, while err() displays the
> errno error message. It will cause confusion. For example, when
> CMS_add1_signer() fails, the following message will appear:
> 
>    sign-file: CMS_add1_signer: Success
> 
> errx() ignores errno and does not cause such issue.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>   scripts/sign-file.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/sign-file.c b/scripts/sign-file.c
> index fbd34b8e8f57..37d8760cb0d1 100644
> --- a/scripts/sign-file.c
> +++ b/scripts/sign-file.c
> @@ -107,7 +107,7 @@ static void drain_openssl_errors(void)
>   		bool __cond = (cond);			\
>   		display_openssl_errors(__LINE__);	\
>   		if (__cond) {				\
> -			err(1, fmt, ## __VA_ARGS__);	\
> +			errx(1, fmt, ## __VA_ARGS__);	\
>   		}					\
>   	} while(0)
>   
>
tianjia.zhang June 17, 2022, 9:24 a.m. UTC | #2
Hi Jarkko,

On 6/24/21 6:48 PM, Tianjia Zhang wrote:
> When an error occurs, use errx() instead of err() to display the
> error message, because openssl has its own error record. When an
> error occurs, errno will not be changed, while err() displays the
> errno error message. It will cause confusion. For example, when
> CMS_add1_signer() fails, the following message will appear:
> 
>    sign-file: CMS_add1_signer: Success
> 
> errx() ignores errno and does not cause such issue.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>   scripts/sign-file.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/sign-file.c b/scripts/sign-file.c
> index fbd34b8e8f57..37d8760cb0d1 100644
> --- a/scripts/sign-file.c
> +++ b/scripts/sign-file.c
> @@ -107,7 +107,7 @@ static void drain_openssl_errors(void)
>   		bool __cond = (cond);			\
>   		display_openssl_errors(__LINE__);	\
>   		if (__cond) {				\
> -			err(1, fmt, ## __VA_ARGS__);	\
> +			errx(1, fmt, ## __VA_ARGS__);	\
>   		}					\
>   	} while(0)
>   

Likewise, No response from David, can you pick this? thanks.

Best regards,
Tianjia
Jarkko Sakkinen June 26, 2022, 6:14 a.m. UTC | #3
On Fri, Jun 17, 2022 at 05:24:55PM +0800, Tianjia Zhang wrote:
> Hi Jarkko,
> 
> On 6/24/21 6:48 PM, Tianjia Zhang wrote:
> > When an error occurs, use errx() instead of err() to display the
> > error message, because openssl has its own error record. When an
> > error occurs, errno will not be changed, while err() displays the
> > errno error message. It will cause confusion. For example, when
> > CMS_add1_signer() fails, the following message will appear:
> > 
> >    sign-file: CMS_add1_signer: Success
> > 
> > errx() ignores errno and does not cause such issue.
> > 
> > Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> > ---
> >   scripts/sign-file.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/sign-file.c b/scripts/sign-file.c
> > index fbd34b8e8f57..37d8760cb0d1 100644
> > --- a/scripts/sign-file.c
> > +++ b/scripts/sign-file.c
> > @@ -107,7 +107,7 @@ static void drain_openssl_errors(void)
> >   		bool __cond = (cond);			\
> >   		display_openssl_errors(__LINE__);	\
> >   		if (__cond) {				\
> > -			err(1, fmt, ## __VA_ARGS__);	\
> > +			errx(1, fmt, ## __VA_ARGS__);	\
> >   		}					\
> >   	} while(0)
> 
> Likewise, No response from David, can you pick this? thanks.
> 
> Best regards,
> Tianjia

Ditto.

BR, Jarkko
diff mbox series

Patch

diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index fbd34b8e8f57..37d8760cb0d1 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -107,7 +107,7 @@  static void drain_openssl_errors(void)
 		bool __cond = (cond);			\
 		display_openssl_errors(__LINE__);	\
 		if (__cond) {				\
-			err(1, fmt, ## __VA_ARGS__);	\
+			errx(1, fmt, ## __VA_ARGS__);	\
 		}					\
 	} while(0)