From 9f3bba8bd4c5c5bfeaf22d2d314efba2f3f0b065 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 20 Aug 2012 23:50:39 +0200 Subject: [PATCH] core: Slightly more helpful pa_cstrerror for unknown errors On Windows, strerror can actually return "Unknown Error" (e.g. for large errnums). The code assumes the return value to be helpful. Make it slightly more helpful by catching the message and appending the errnum. --- src/pulsecore/core-error.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/core-error.c b/src/pulsecore/core-error.c index 4d930a090..a1aee0e87 100644 --- a/src/pulsecore/core-error.c +++ b/src/pulsecore/core-error.c @@ -63,8 +63,9 @@ const char* pa_cstrerror(int errnum) { original = strerror(errnum); #endif - if (!original) { - pa_snprintf(errbuf, sizeof(errbuf), "Unknown error %i", errnum); + /* The second condition is a Windows-ism */ + if (!original || !strcasecmp(original, "Unknown error")) { + pa_snprintf(errbuf, sizeof(errbuf), "Unknown error %d", errnum); original = errbuf; }