Skip to contentSkip to conversation

sign-file: Fix confusing error messages

PATCH In review Tianjia Zhang 2 participants 4 messages Jun 24, 2021 – Jun 26, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sign-file: Fix confusing error messages

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.

---
 scripts/sign-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sign-file.c +1 -1
index fbd34b8e8f57..37d8760cb0d1 100644
@@ -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)
 
Signature · 1 line
2.19.1.3.ge56e4f7
#1 lore raw

ping.

Quoted 29 lines · Tianjia Zhang

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.

---
  scripts/sign-file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sign-file.c +1 -1
index fbd34b8e8f57..37d8760cb0d1 100644
@@ -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)
 
#2 lore raw
In reply to Tianjia Zhang

Hi Jarkko,

Quoted 20 lines · Tianjia Zhang

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.

---
  scripts/sign-file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sign-file.c +0 -0
index fbd34b8e8f57..37d8760cb0d1 100644

scripts/sign-file.c static void drain_openssl_errors(void) · line 113

Quoted 8 lines
scripts/sign-file.c +1 -1
@@ -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

maintainer
#3 lore raw
Quoted 33 lines · Tianjia Zhang

Hi Jarkko,

Quoted 20 lines · Tianjia Zhang

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.

---
  scripts/sign-file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sign-file.c +0 -0
index fbd34b8e8f57..37d8760cb0d1 100644

scripts/sign-file.c static void drain_openssl_errors(void) · line 112

Quoted 7 lines
scripts/sign-file.c +1 -1
@@ -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.

Quoted 2 lines

Best regards,
Tianjia

Ditto.

BR, Jarkko