[PATCH] rpm2cpio: print name of unknown compression method

Ron Yorston via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <69c27941.Og9mG89bdD6S+WFv%[email protected]>
Commit f13f68288 (rpm2cpio: extract cpio even if compression is
not known) added an error message if the compression method was
unknown.  When support for lzma was disabled this resulted in a
null pointer being passed to bb_error_msg().

The call to rpm_getstr0() to fetch the name of the compression
method shouldn't depend on lzma being supported.

This doesn't affect the size of a default build.  In a build with
lzma disabled:

function                                             old     new   delta
rpm2cpio_main                                        110     121     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 11/0)               Total: 11 bytes

Signed-off-by: Ron Yorston <[email protected]>
---
 archival/rpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/archival/rpm.c b/archival/rpm.c
index 95a8c79b6..899587751 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -533,9 +533,9 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
 	//	/* We need to know whether child (gzip/bzip/etc) exits abnormally */
 	//	signal(SIGCHLD, check_errors_in_children);
 
-	str = NULL;
+	str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR);
 	if (ENABLE_FEATURE_SEAMLESS_LZMA
-	 && (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL
+	 && str != NULL
 	 && strcmp(str, "lzma") == 0
 	) {
 		// lzma compression can't be detected
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.