From 206225305924d8fde785ef194e1f29546f83b12a Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 3 Jun 2003 23:38:53 +0000 Subject: 2003-06-04 Marcus Brinkmann * src/gpg-error.h (gpg_make_error_from_errno): New inline function. (gpg_error_from_errno): Likewise. * src/code-from-errno.c (gpg_err_code_from_errno): Handle the case of no error at all. --- ChangeLog | 8 ++++++++ src/code-from-errno.c | 3 +++ src/gpg-error.h | 16 ++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4a63c68..0015614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-06-04 Marcus Brinkmann + + * src/gpg-error.h (gpg_make_error_from_errno): New inline function. + (gpg_error_from_errno): Likewise. + + * src/code-from-errno.c (gpg_err_code_from_errno): Handle the case + of no error at all. + 2003-06-04 Marcus Brinkmann * src/gpg-error.h (gpg_err_source_t): Add GPG_ERR_SOURCE_USER_1 to 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 */ -- cgit v1.2.3