changeset 676:f3649df3d9a7

Adjust errno handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 25 Feb 2020 07:42:50 +0200
parents fb4093ad1f7b
children 927772fb0745
files th_util.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/th_util.c	Tue Feb 25 06:15:08 2020 +0200
+++ b/th_util.c	Tue Feb 25 07:42:50 2020 +0200
@@ -183,13 +183,16 @@
  */
 int th_get_error()
 {
-    return TH_SYSTEM_ERRORS + errno;
+    return th_errno_to_error(errno);
 }
 
 
 int th_errno_to_error(int error)
 {
-    return TH_SYSTEM_ERRORS + error;
+    if (error == 0)
+        return THERR_OK;
+    else
+        return TH_SYSTEM_ERRORS + error;
 }