]> code.delx.au - pulseaudio/commitdiff
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 4d930a090bb7d3fa878f4a4ac522ed62aeb1446c..a1aee0e87f038e3856639fcc6a6daf9de4ad7002 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;
     }