<html><head></head><body>Hi,<br><br>In which cases can those errors be confused? The whole point is to allow more precise errors (than VLC_EGENERIC), not less.<br><br><div class="gmail_quote">Le 20 mai 2019 09:43:37 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2019-05-19 19:46, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">While this is not complete nor free of ambiguities, this enables a lot<br>more expressive error values than the current tiny set. And even then,<br>mostly only VLC_EGENERIC and VLC_ENOMEM are ever used.<br><br>This also allows passing errors from the CRT or OS.<br><br>This assumes that 666 is not an error code that VLC will use though.<hr> include/vlc_common.h | 23 ++++++++++++++---------<br> modules/lua/libs/misc.c | 23 ++---------------------<br> 2 files changed, 16 insertions(+), 30 deletions(-)<br><br>diff --git a/include/vlc_common.h b/include/vlc_common.h<br>index 0bbb98fd62..c6e6b7ae6a 100644<br>--- a/include/vlc_common.h<br>+++ b/include/vlc_common.h<br>@@ -42,6 +42,11 @@<br> /*****************************************************************************<br> * Required system headers<br> *****************************************************************************/<br>+#ifndef __cplusplus<br>+# include <errno.h><br>+#else<br>+# include <cerrno><br>+#endif<br> #include <stdlib.h><br> #include <stdarg.h><br> <br>@@ -468,23 +473,23 @@ typedef union<br> * Error values (shouldn't be exposed)<br> *****************************************************************************/<br> /** No error */<br>-#define VLC_SUCCESS (-0)<br>+#define VLC_SUCCESS 0<br> /** Unspecified error */<br>-#define VLC_EGENERIC (-1)<br>+#define VLC_EGENERIC (-666)<br> /** Not enough memory */<br>-#define VLC_ENOMEM (-2)<br>+#define VLC_ENOMEM (-ENOMEM)<br> /** Timeout */<br>-#define VLC_ETIMEOUT (-3)<br>+#define VLC_ETIMEOUT (-ETIMEDOUT)<br> /** Module not found */<br>-#define VLC_ENOMOD (-4)<br>+#define VLC_ENOMOD (-ENOTSUP)<br> /** Object not found */<br>-#define VLC_ENOOBJ (-5)<br>+#define VLC_ENOOBJ (-EFAULT)<br></blockquote><br>We're losing some information about what kind of error this is.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> /** Variable not found */<br>-#define VLC_ENOVAR (-6)<br>+#define VLC_ENOVAR (-EFAULT)<br></blockquote><br>We're losing some information about what kind of error this is.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> /** Bad variable value */<br>-#define VLC_EBADVAR (-7)<br>+#define VLC_EBADVAR (-EINVAL)<br> /** Item not found */<br>-#define VLC_ENOITEM (-8)<br>+#define VLC_ENOITEM (-ENOENT)<br> <br> /*****************************************************************************<br> * Variable callbacks: called when the value is modified<br>diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c<br>index 25f44c3047..c7d47c020b 100644<br>--- a/modules/lua/libs/misc.c<br>+++ b/modules/lua/libs/misc.c<br>@@ -85,27 +85,8 @@ vlc_object_t * vlclua_get_this( lua_State *L )<br> int vlclua_push_ret( lua_State *L, int i_error )<br> {<br> lua_pushnumber( L, i_error );<br>-<br>- int err;<br>-<br>- switch( i_error )<br>- {<br>- case VLC_SUCCESS: err = 0; break;<br>- case VLC_ENOMEM: err = ENOMEM; break;<br>- case VLC_ETIMEOUT: err = ETIMEDOUT; break;<br>- case VLC_EBADVAR: err = EINVAL; break;<br>- case VLC_ENOMOD: err = ENOENT; break;<br>- case VLC_ENOOBJ: err = ENOENT; break;<br>- case VLC_ENOVAR: err = ENOENT; break;<br>- case VLC_EGENERIC:<br>- lua_pushstring( L, "generic error" );<br>- return 2;<br>- default:<br>- lua_pushstring( L, "unknown error" );<br>- return 2;<br>- }<br>-<br>- lua_pushstring( L, vlc_strerror_c(err) );<br>+ lua_pushstring( L, (i_error == VLC_EGENERIC ? "generic error"<br>+ : vlc_strerror_c(-i_error)) );<br> return 2;<br> }<br> <br>-- <br>2.20.1<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>