diff options
author | Thomas Haller <thaller@redhat.com> | 2016-02-28 16:06:05 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-03-03 18:54:20 +0100 |
commit | 7871d850f50975b46f7909bc6bd3cce434c7c60e (patch) | |
tree | 67ebb6724094878457eb2e5a812bd0d10432f610 | |
parent | c30627f10667e370a053602e7b3a4640e6fa411d (diff) | |
download | NetworkManager-7871d850f50975b46f7909bc6bd3cce434c7c60e.tar.gz |
shared: add NM_G_ERROR_MSG()
-rw-r--r-- | shared/nm-macros-internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index aa38bacf55..dafce87795 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -116,6 +116,26 @@ GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free) /********************************************************/ +/** + * NM_G_ERROR_MSG: + * @error: (allow none): the #GError instance + * + * All functions must follow the convention that when they + * return a failure, they must also set the GError to a valid + * message. For external API however, we want to be extra + * careful before accessing the error instance. Use NM_G_ERROR_MSG() + * which is safe to use on NULL. + * + * Returns: the error message. + **/ +static inline const char * +NM_G_ERROR_MSG (GError *error) +{ + return error ? (error->message ? : "(null)") : "(no-error)"; \ +} + +/********************************************************/ + /* macro to return strlen() of a compile time string. */ #define NM_STRLEN(str) ( sizeof ("" str) - 1 ) |