commit 8ac666968562e167026bdb3e2dd31efcb09ed260
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Mon Jan 8 14:00:51 2018 -0600

    Log: libcluster,libcrmcommon: improve BZ2 error messages

diff --git a/lib/cluster/cpg.c b/lib/cluster/cpg.c
index 5cc981db7..2640e0e84 100644
--- a/lib/cluster/cpg.c
+++ b/lib/cluster/cpg.c
@@ -291,7 +291,8 @@ pcmk_message_common_cs(cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void
         rc = BZ2_bzBuffToBuffDecompress(uncompressed, &new_size, msg->data, msg->compressed_size, 1, 0);
 
         if (rc != BZ_OK) {
-            crm_err("Decompression failed: %d", rc);
+            crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+                    bz2_strerror(rc), rc);
             free(uncompressed);
             goto badmsg;
         }
diff --git a/lib/common/ipc.c b/lib/common/ipc.c
index c238bca23..2f7f90e33 100644
--- a/lib/common/ipc.c
+++ b/lib/common/ipc.c
@@ -481,7 +481,8 @@ crm_ipcs_recv(crm_client_t * c, void *data, size_t size, uint32_t * id, uint32_t
         text = uncompressed;
 
         if (rc != BZ_OK) {
-            crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+            crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+                    bz2_strerror(rc), rc);
             free(uncompressed);
             return NULL;
         }
@@ -1019,7 +1020,8 @@ crm_ipc_decompress(crm_ipc_t * client)
                                         client->buffer + hdr_offset, header->size_compressed, 1, 0);
 
         if (rc != BZ_OK) {
-            crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+            crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+                    bz2_strerror(rc), rc);
             free(uncompressed);
             return -EILSEQ;
         }
diff --git a/lib/common/remote.c b/lib/common/remote.c
index 01f0409ef..b228d10c0 100644
--- a/lib/common/remote.c
+++ b/lib/common/remote.c
@@ -410,7 +410,8 @@ crm_remote_parse_buffer(crm_remote_t * remote)
             return NULL;
 
         } else if (rc != BZ_OK) {
-            crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+            crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+                    bz2_strerror(rc), rc);
             free(uncompressed);
             return NULL;
         }
diff --git a/lib/common/strings.c b/lib/common/strings.c
index 26dc793b8..d4f29c7b0 100644
--- a/lib/common/strings.c
+++ b/lib/common/strings.c
@@ -436,7 +436,8 @@ crm_compress_string(const char *data, int length, int max, char **result, unsign
     free(uncompressed);
 
     if (rc != BZ_OK) {
-        crm_err("Compression of %d bytes failed: %s (%d)", length, bz2_strerror(rc), rc);
+        crm_err("Compression of %d bytes failed: %s " CRM_XS " bzerror=%d",
+                length, bz2_strerror(rc), rc);
         free(compressed);
         return FALSE;
     }
diff --git a/lib/common/xml.c b/lib/common/xml.c
index 9e99619af..61575f1c7 100644
--- a/lib/common/xml.c
+++ b/lib/common/xml.c
@@ -2848,8 +2848,9 @@ decompress_file(const char *filename)
     }
 
     bz_file = BZ2_bzReadOpen(&rc, input, 0, 0, NULL, 0);
-
     if (rc != BZ_OK) {
+        crm_err("Could not prepare to read compressed %s: %s "
+                CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
         BZ2_bzReadClose(&rc, bz_file);
         return NULL;
     }
@@ -2869,7 +2870,8 @@ decompress_file(const char *filename)
     buffer[length] = '\0';
 
     if (rc != BZ_STREAM_END) {
-        crm_err("Couldn't read compressed xml from file");
+        crm_err("Could not read compressed %s: %s "
+                CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
         free(buffer);
         buffer = NULL;
     }
@@ -2878,7 +2880,8 @@ decompress_file(const char *filename)
     fclose(input);
 
 #else
-    crm_err("Cannot read compressed files:" " bzlib was not available at compile time");
+    crm_err("Could not read compressed %s: not built with bzlib support",
+            filename);
 #endif
     return buffer;
 }
@@ -2946,7 +2949,8 @@ filename2xml(const char *filename)
     } else {
         char *input = decompress_file(filename);
 
-        output = xmlCtxtReadDoc(ctxt, (const xmlChar *)input, NULL, NULL, xml_options);
+        output = xmlCtxtReadDoc(ctxt, (const xmlChar *)input, NULL, NULL,
+                                xml_options);
         free(input);
     }
 
@@ -3073,21 +3077,23 @@ write_xml_stream(xmlNode * xml_node, const char *filename, FILE * stream, gboole
 
         bz_file = BZ2_bzWriteOpen(&rc, stream, 5, 0, 30);
         if (rc != BZ_OK) {
-            crm_warn("Not compressing %s: could not prepare file stream "
-                     CRM_XS " bzerror=%d", filename, rc);
+            crm_warn("Not compressing %s: could not prepare file stream: %s "
+                     CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
         } else {
             BZ2_bzWrite(&rc, bz_file, buffer, strlen(buffer));
             if (rc != BZ_OK) {
-                crm_warn("Not compressing %s: could not compress data "
-                         CRM_XS " bzerror=%d errno=%d", filename, rc, errno);
+                crm_warn("Not compressing %s: could not compress data: %s "
+                         CRM_XS " bzerror=%d errno=%d",
+                         filename, bz2_strerror(rc), rc, errno);
             }
         }
 
         if (rc == BZ_OK) {
             BZ2_bzWriteClose(&rc, bz_file, 0, &in, &out);
             if (rc != BZ_OK) {
-                crm_warn("Not compressing %s: could not write compressed data "
-                         CRM_XS " bzerror=%d errno=%d", filename, rc, errno);
+                crm_warn("Not compressing %s: could not write compressed data: %s "
+                         CRM_XS " bzerror=%d errno=%d",
+                         filename, bz2_strerror(rc), rc, errno);
                 out = -1; // retry without compression
             } else {
                 res = (int) out;
