diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/code-from-errno.c | 3 | ||||
-rw-r--r-- | src/gpg-error.h | 16 |
3 files changed, 27 insertions, 0 deletions
@@ -1,5 +1,13 @@ 2003-06-04 Marcus Brinkmann <[email protected]> + * 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 <[email protected]> + * src/gpg-error.h (gpg_err_source_t): Add GPG_ERR_SOURCE_USER_1 to GPG_ERR_SOURCE_USER_4. (gpg_err_code_t): Add GPG_ERR_USER_1 to GPG_ERR_USER_16. 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 */ |