summaryrefslogtreecommitdiff
path: root/support/support_test_compare_failure.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-01-12 08:18:30 +0100
committerFlorian Weimer <fweimer@redhat.com>2018-01-12 13:35:01 +0100
commit1a51e46e4a87e1cd9528ac5e5656011636e4086b (patch)
tree0120ca1d101beec6d0cf0532cdd4ab31aa95e211 /support/support_test_compare_failure.c
parent63b52889c35b367cf20896442203bbe5d123058c (diff)
support: Preserve errno in write_message, TEST_VERIFY and other checks
These facilities could clobber errno, which makes it difficult to write certain checks because a specific order has to be used.
Diffstat (limited to 'support/support_test_compare_failure.c')
-rw-r--r--support/support_test_compare_failure.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/support/support_test_compare_failure.c b/support/support_test_compare_failure.c
index e5596fd121..8eb51c439d 100644
--- a/support/support_test_compare_failure.c
+++ b/support/support_test_compare_failure.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <errno.h>
#include <stdio.h>
#include <support/check.h>
@@ -44,6 +45,7 @@ support_test_compare_failure (const char *file, int line,
int right_positive,
int right_size)
{
+ int saved_errno = errno;
support_record_failure ();
if (left_size != right_size)
printf ("%s:%d: numeric comparison failure (widths %d and %d)\n",
@@ -52,4 +54,5 @@ support_test_compare_failure (const char *file, int line,
printf ("%s:%d: numeric comparison failure\n", file, line);
report (" left", left_expr, left_value, left_positive, left_size);
report ("right", right_expr, right_value, right_positive, right_size);
+ errno = saved_errno;
}