aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/code-from-errno.c3
-rw-r--r--src/gpg-error.h16
2 files changed, 19 insertions, 0 deletions
diff --git a/src/code-from-errno.c b/src/code-from-errno.c
index 5312389..5c97a7b 100644
--- a/src/code-from-errno.c
+++ b/src/code-from-errno.c
@@ -34,6 +34,9 @@ gpg_err_code_from_errno (int err)
{
int idx = errno_to_idx (err);
+ if (!err)
+ return GPG_ERR_NO_ERROR;
+
if (idx < 0)
return GPG_ERR_UNKNOWN_ERRNO;
diff --git a/src/gpg-error.h b/src/gpg-error.h
index 23c0a50..e69399a 100644
--- a/src/gpg-error.h
+++ b/src/gpg-error.h
@@ -471,4 +471,20 @@ gpg_err_code_t gpg_err_code_from_errno (int err);
if CODE is not a system error code. */
int gpg_err_code_to_errno (gpg_err_code_t code);
+
+/* Self-documenting convenience functions. */
+
+static __inline__ gpg_error_t
+gpg_make_error_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_make_error (source, gpg_err_code_from_errno (err));
+}
+
+
+static __inline__ gpg_err_code_t
+gpg_error_from_errno (int err)
+{
+ return gpg_error (gpg_err_code_from_errno (err));
+}
+
#endif /* GPG_ERROR_H */