File pacemaker#3684-0001-High-libcrmcommon-Don-t-assert-on-failure-to-write-e.patch of Package pacemaker.36842

From 867c8d17ede64a59cde424e522a014caf50943aa Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Thu, 3 Oct 2024 09:56:10 -0400
Subject: [PATCH] High: libcrmcommon: Don't assert on failure to write errors.

Only text output mode is affected by this - other output formats write
to a buffer, so an error there is likely a memory problem and should be
asserted on.  vprintf/fprintf can return a negative value if the file
handle is closed (say, with shell output redirection) and we don't want
to assert on that.

Fixes T891
---
 lib/common/output_text.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Index: pacemaker-2.1.7+20231219.0f7f88312/lib/common/output_text.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/lib/common/output_text.c
+++ pacemaker-2.1.7+20231219.0f7f88312/lib/common/output_text.c
@@ -131,7 +131,6 @@ G_GNUC_PRINTF(2, 3)
 static void
 text_err(pcmk__output_t *out, const char *format, ...) {
     va_list ap;
-    int len = 0;
 
     CRM_ASSERT(out != NULL);
 
@@ -140,8 +139,7 @@ text_err(pcmk__output_t *out, const char
     /* Informational output does not get indented, to separate it from other
      * potentially indented list output.
      */
-    len = vfprintf(stderr, format, ap);
-    CRM_ASSERT(len >= 0);
+    vfprintf(stderr, format, ap);
     va_end(ap);
 
     /* Add a newline. */
@@ -152,7 +150,6 @@ G_GNUC_PRINTF(2, 3)
 static int
 text_info(pcmk__output_t *out, const char *format, ...) {
     va_list ap;
-    int len = 0;
 
     CRM_ASSERT(out != NULL);
 
@@ -165,8 +162,7 @@ text_info(pcmk__output_t *out, const cha
     /* Informational output does not get indented, to separate it from other
      * potentially indented list output.
      */
-    len = vfprintf(out->dest, format, ap);
-    CRM_ASSERT(len >= 0);
+    vfprintf(out->dest, format, ap);
     va_end(ap);
 
     /* Add a newline. */
@@ -347,13 +343,9 @@ pcmk__mk_text_output(char **argv) {
 G_GNUC_PRINTF(2, 0)
 void
 pcmk__formatted_vprintf(pcmk__output_t *out, const char *format, va_list args) {
-    int len = 0;
-
     CRM_ASSERT(out != NULL);
     CRM_CHECK(pcmk__str_eq(out->fmt_name, "text", pcmk__str_none), return);
-
-    len = vfprintf(out->dest, format, args);
-    CRM_ASSERT(len >= 0);
+    vfprintf(out->dest, format, args);
 }
 
 G_GNUC_PRINTF(2, 3)
openSUSE Build Service is sponsored by