From 2d80a675240c67b6fca3d2626eab4c745ce25141 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
Date: Mon, 12 Jul 2021 20:51:43 +0300
Subject: [PATCH] include: use negated standard error codes

---
 include/vlc_common.h | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 6fb9f706e3e5..71db8d603dd1 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -44,6 +44,7 @@
  *****************************************************************************/
 #include <stdlib.h>
 #include <stdarg.h>
+#include <errno.h>
 
 #include <string.h>
 #include <stdio.h>
@@ -463,25 +464,29 @@ typedef union
 
 } vlc_value_t;
 
-/*****************************************************************************
- * Error values (shouldn't be exposed)
- *****************************************************************************/
+/**
+ * \defgroup errors Error codes
+ * \ingroup cext
+ * @{
+ */
 /** No error */
-#define VLC_SUCCESS        (-0)
+#define VLC_SUCCESS        0
 /** Unspecified error */
 #define VLC_EGENERIC       (-2 * (1 << (sizeof (int) * 8 - 2))) /* INT_MIN */
 /** Not enough memory */
-#define VLC_ENOMEM         (-2)
+#define VLC_ENOMEM         (-ENOMEM)
 /** Timeout */
-#define VLC_ETIMEOUT       (-3)
+#define VLC_ETIMEOUT       (-ETIMEDOUT)
 /** Not found */
-#define VLC_ENOENT         (-4)
+#define VLC_ENOENT         (-ENOENT)
 /** Bad variable value */
-#define VLC_EINVAL         (-7)
+#define VLC_EINVAL         (-EINVAL)
 /** Operation forbidden */
-#define VLC_EACCES         (-9)
+#define VLC_EACCES         (-EACCES)
 /** Operation not supported */
-#define VLC_ENOTSUP        (-10)
+#define VLC_ENOTSUP        (-ENOTSUP)
+
+/** @} */
 
 /*****************************************************************************
  * Variable callbacks: called when the value is modified
-- 
GitLab