summaryrefslogtreecommitdiff
path: root/glnx-errors.h
diff options
context:
space:
mode:
authorJonathan Lebon <jlebon@redhat.com>2017-07-21 14:07:12 -0700
committerJonathan Lebon <jlebon@redhat.com>2017-07-21 14:09:24 -0700
commitc820571bc4389515902e268bea5489dc114c3973 (patch)
treeeb088514bc9442092a40a8aece4c975e04b3e375 /glnx-errors.h
parent7d6a31fb9316ec85d462c26b84fb8fe9ca04ef2b (diff)
downloadlibglnx-c820571bc4389515902e268bea5489dc114c3973.tar.gz
errors: check for an error before prefixing
Minor tweak to the new `GLNX_AUTO_PREFIX_ERROR`. Since the common case is that there's no errors, let's bring down the same check that `g_prefix_error` does to avoid a function call most of the time.
Diffstat (limited to 'glnx-errors.h')
-rw-r--r--glnx-errors.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/glnx-errors.h b/glnx-errors.h
index 07c30fe..5a6fe19 100644
--- a/glnx-errors.h
+++ b/glnx-errors.h
@@ -94,7 +94,7 @@ glnx_prefix_error (GError **error, const char *fmt, ...)
* ```
* gboolean start_http_request (..., GError **error)
* {
- * GLNX_AUTO_PREFIX_ERROR("HTTP request", error)
+ * GLNX_AUTO_PREFIX_ERROR ("HTTP request", error)
*
* if (!libhttp_request_start (..., error))
* return FALSE;
@@ -109,7 +109,8 @@ typedef struct {
static inline void
glnx_cleanup_auto_prefix_error (GLnxAutoErrorPrefix *prefix)
{
- g_prefix_error (prefix->error, "%s: ", prefix->prefix);
+ if (prefix->error && *(prefix->error))
+ g_prefix_error (prefix->error, "%s: ", prefix->prefix);
}
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxAutoErrorPrefix, glnx_cleanup_auto_prefix_error)
#define GLNX_AUTO_PREFIX_ERROR(text, error) \