<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Sep 12, 2015 at 2:03 PM, Rémi Denis-Courmont <span dir="ltr"><<a href="mailto:remi@remlab.net" target="_blank">remi@remlab.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>Le 2015-09-12 20:23, Sean McGovern a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/posix/error.c | 26 ++++++++++++++++++++++++++<br>
1 file changed, 26 insertions(+)<br>
<br>
diff --git a/src/posix/error.c b/src/posix/error.c<br>
index db51004..790e5bb 100644<br>
--- a/src/posix/error.c<br>
+++ b/src/posix/error.c<br>
@@ -29,6 +29,23 @@<br>
<br>
#include <vlc_common.h><br>
<br>
+#ifndef HAVE_STRERROR_L<br>
+static const char *vlc_strerror_r(int errnum)<br>
+{<br>
+#define BUF_LEN 256<br>
+ char *buf = malloc(BUF_LEN);<br>
+ if(unlikely(buf == NULL))<br>
+ return buf;<br>
+<br>
+ if(strerror_r(errnum, buf, BUF_LEN))<br>
+ {<br>
+ free(buf);<br>
+ buf = NULL;<br>
</blockquote>
<br></span>
This function is not allowed to return NULL. Call sites would crash.<span><br>
<br></span></blockquote><div><br></div><div>Fair enough. I can have it return "Unknown error" or something similar.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+<br>
+ return buf;<br>
</blockquote>
<br></span>
Memory leak.<div><div><br></div></div></blockquote><div><br></div><div>Doesn't the calling function need to take ownership of whatever this returns anyhow?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+#else<br>
static const char *vlc_strerror_l(int errnum, const char *lname)<br>
{<br>
int saved_errno = errno;<br>
@@ -53,6 +70,7 @@ static const char *vlc_strerror_l(int errnum, const<br>
char *lname)<br>
freelocale(loc);<br>
return buf;<br>
}<br>
+#endif<br>
<br>
/**<br>
* Formats an error message in the current locale.<br>
@@ -63,7 +81,11 @@ static const char *vlc_strerror_l(int errnum,<br>
const char *lname)<br>
const char *vlc_strerror(int errnum)<br>
{<br>
/* We cannot simply use strerror() here, since it is not thread-safe. */<br>
+#ifndef HAVE_STRERROR_L<br>
+ return vlc_strerror_r(errnum);<br>
+#else<br>
return vlc_strerror_l(errnum, "");<br>
+#endif<br>
}<br>
<br>
/**<br>
@@ -74,5 +96,9 @@ const char *vlc_strerror(int errnum)<br>
*/<br>
const char *vlc_strerror_c(int errnum)<br>
{<br>
+#ifndef HAVE_STRERROR_L<br>
+ return vlc_strerror_r(errnum);<br>
</blockquote>
<br></div></div>
This will cause translated error messages in the log. This might mean nothing to you. But *I* get to review a a lot of debug logs in locales I don't understand.</blockquote><div><br></div><div>This doesn't mean nothing to me -- I'm just stuck with no clear idea on how to move forward. I definitely don't have the resources to provide translations for all the operating systems that have no implementation for this.</div><div><br></div><div>-- Sean McG. </div></div></div></div>