core: Slightly more helpful pa_cstrerror for unknown errors
authorThomas Martitz <kugel@rockbox.org>
Mon, 20 Aug 2012 21:50:39 +0000 (23:50 +0200)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 23 Oct 2012 06:46:50 +0000 (12:16 +0530)
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

index 4d930a0..a1aee0e 100644 (file)
@@ -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;
     }