[gjs: 20/22] gjs-test-tools: Use `g_prefix_error` instead of using that ourself
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 20/22] gjs-test-tools: Use `g_prefix_error` instead of using that ourself
- Date: Fri, 23 Apr 2021 04:56:07 +0000 (UTC)
commit 08bf63bfea524e9a4a3ccc4656e1d161336a38eb
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Apr 7 19:38:38 2021 +0200
gjs-test-tools: Use `g_prefix_error` instead of using that ourself
.../js/libgjstesttools/gjs-test-tools.cpp | 23 ++--------------------
1 file changed, 2 insertions(+), 21 deletions(-)
---
diff --git a/installed-tests/js/libgjstesttools/gjs-test-tools.cpp
b/installed-tests/js/libgjstesttools/gjs-test-tools.cpp
index c018cc2e..54c457bc 100644
--- a/installed-tests/js/libgjstesttools/gjs-test-tools.cpp
+++ b/installed-tests/js/libgjstesttools/gjs-test-tools.cpp
@@ -244,31 +244,12 @@ GObject* gjs_test_tools_get_disposed(GObject* object) {
#ifdef G_OS_UNIX
// Adapted from glnx_throw_errno_prefix()
-G_GNUC_PRINTF(2, 3)
-static gboolean throw_errno_prefix(GError** error, const char* fmt, ...) {
+static gboolean throw_errno_prefix(GError** error, const char* prefix) {
int errsv = errno;
- char* old_msg;
- GString* buf;
-
- va_list args;
-
- if (!error)
- return FALSE;
-
- va_start(args, fmt);
g_set_error_literal(error, G_IO_ERROR, g_io_error_from_errno(errsv),
g_strerror(errsv));
-
- old_msg = g_steal_pointer(&(*error)->message);
- buf = g_string_new("");
- g_string_append_vprintf(buf, fmt, args);
- g_string_append(buf, ": ");
- g_string_append(buf, old_msg);
- g_free(old_msg);
- (*error)->message = g_string_free(g_steal_pointer(&buf), FALSE);
-
- va_end(args);
+ g_prefix_error(error, "%s: ", prefix);
errno = errsv;
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]