diff options
| author | Michael Biebl <biebl@debian.org> | 2018-09-15 01:04:32 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-09-15 01:04:32 +0200 |
| commit | c240974325c552cad177c457d6ff04e381fd77a3 (patch) | |
| tree | 2fe5561359b767db15292c84447be8075a75388a /shared/nm-utils | |
| parent | 8f7a3cbbdd0c0a48277c341dd3a8ec8743ae9735 (diff) | |
New upstream version 1.14.0 upstream/1.14.0
Diffstat (limited to 'shared/nm-utils')
| -rw-r--r-- | shared/nm-utils/nm-shared-utils.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index b3099738..5125bd3d 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -480,6 +480,19 @@ _nm_g_slice_free_fcn_define (16) /*****************************************************************************/ +static inline int +nm_errno (int errsv) +{ + /* several API returns negative errno values as errors. Normalize + * negative values to positive values. + * + * As a special case, map G_MININT to G_MAXINT. If you care about the + * distinction, then check for G_MININT before. */ + return errsv >= 0 + ? errsv + : ((errsv == G_MININT) ? G_MAXINT : -errsv); +} + /** * NMUtilsError: * @NM_UTILS_ERROR_UNKNOWN: unknown or unclassified error @@ -542,6 +555,14 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal) #define nm_utils_error_set(error, error_code, ...) \ g_set_error ((error), NM_UTILS_ERROR, error_code, __VA_ARGS__) +#define nm_utils_error_set_errno(error, errsv, fmt, ...) \ + g_set_error ((error), \ + NM_UTILS_ERROR, \ + NM_UTILS_ERROR_UNKNOWN, \ + fmt, \ + ##__VA_ARGS__, \ + g_strerror (nm_errno (errsv))) + /*****************************************************************************/ gboolean nm_g_object_set_property (GObject *object, |