[sysprof: 54/63] libsysprof-capture: Drop GError usage from SysprofCaptureReader
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof: 54/63] libsysprof-capture: Drop GError usage from SysprofCaptureReader
- Date: Sat, 4 Jul 2020 18:33:53 +0000 (UTC)
commit e19d70bca018319ce3d9b3a04e306d810f7f3d07
Author: Philip Withnall <withnall endlessm com>
Date: Thu Jul 2 12:56:12 2020 +0100
libsysprof-capture: Drop GError usage from SysprofCaptureReader
Use `errno` instead, which is icky, but given that all of the failure
modes are from POSIX I/O functions, it’s at least in keeping with them.
This is a major API break.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #40
src/libsysprof-capture/sysprof-capture-reader.c | 76 +++++++++++--------------
src/libsysprof-capture/sysprof-capture-reader.h | 12 ++--
src/libsysprof/sysprof-proxy-source.c | 8 ++-
src/libsysprof/sysprof-tracefd-source.c | 2 +-
src/tests/allocs-by-size.c | 5 +-
src/tests/allocs-within-mark.c | 5 +-
src/tests/cross-thread-frees.c | 6 +-
src/tests/find-temp-allocs.c | 6 +-
src/tests/memory-stack-stash.c | 5 +-
src/tests/show-page-usage.c | 6 +-
src/tests/test-addr-decode.c | 6 +-
src/tests/test-addr-map.c | 5 +-
src/tests/test-capture-cursor.c | 8 +--
src/tests/test-capture.c | 68 +++++++++-------------
src/tests/test-resolvers.c | 8 ++-
src/tools/list-threads.c | 4 +-
src/tools/sysprof-cat.c | 5 +-
src/tools/sysprof-cli.c | 5 +-
src/tools/sysprof-dump.c | 5 +-
19 files changed, 114 insertions(+), 131 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c
index 2b103b5..67c6b28 100644
--- a/src/libsysprof-capture/sysprof-capture-reader.c
+++ b/src/libsysprof-capture/sysprof-capture-reader.c
@@ -90,29 +90,24 @@ struct _SysprofCaptureReader
unsigned int st_buf_set : 1;
};
+/* Sets @errno on failure. Sets @errno to EBADMSG if the file magic doesn’t
+ * match, and otherwise can return any error as for read(). */
static bool
-sysprof_capture_reader_read_file_header (SysprofCaptureReader *self,
- SysprofCaptureFileHeader *header,
- GError **error)
+sysprof_capture_reader_read_file_header (SysprofCaptureReader *self,
+ SysprofCaptureFileHeader *header)
{
assert (self != NULL);
assert (header != NULL);
if (sizeof *header != _sysprof_pread (self->fd, header, sizeof *header, 0L))
{
- g_set_error (error,
- G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
+ /* errno is propagated */
return false;
}
if (header->magic != SYSPROF_CAPTURE_MAGIC)
{
- g_set_error (error,
- G_FILE_ERROR,
- G_FILE_ERROR_FAILED,
- "Capture file magic does not match");
+ errno = EBADMSG;
return false;
}
@@ -201,17 +196,17 @@ sysprof_capture_reader_discover_end_time (SysprofCaptureReader *self)
/**
* sysprof_capture_reader_new_from_fd:
* @fd: an fd to take ownership from
- * @error: a location for a #GError or %NULL
*
* Creates a new reader using the file-descriptor.
*
* This is useful if you don't necessarily have access to the filename itself.
*
+ * If this function fails, `errno` is set.
+ *
* Returns: (transfer full): an #SysprofCaptureReader or %NULL upon failure.
*/
SysprofCaptureReader *
-sysprof_capture_reader_new_from_fd (int fd,
- GError **error)
+sysprof_capture_reader_new_from_fd (int fd)
{
SysprofCaptureReader *self;
@@ -220,7 +215,7 @@ sysprof_capture_reader_new_from_fd (int fd,
self = sysprof_malloc0 (sizeof (SysprofCaptureReader));
if (self == NULL)
{
- g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, "No memory");
+ errno = ENOMEM;
return NULL;
}
@@ -230,7 +225,7 @@ sysprof_capture_reader_new_from_fd (int fd,
if (self->buf == NULL)
{
free (self);
- g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, "No memory");
+ errno = ENOMEM;
return NULL;
}
@@ -239,9 +234,11 @@ sysprof_capture_reader_new_from_fd (int fd,
self->fd = fd;
self->fd_off = sizeof (SysprofCaptureFileHeader);
- if (!sysprof_capture_reader_read_file_header (self, &self->header, error))
+ if (!sysprof_capture_reader_read_file_header (self, &self->header))
{
+ int errsv = errno;
sysprof_capture_reader_finalize (self);
+ errno = errsv;
return NULL;
}
@@ -261,8 +258,7 @@ sysprof_capture_reader_new_from_fd (int fd,
}
SysprofCaptureReader *
-sysprof_capture_reader_new (const char *filename,
- GError **error)
+sysprof_capture_reader_new (const char *filename)
{
SysprofCaptureReader *self;
int fd;
@@ -271,16 +267,15 @@ sysprof_capture_reader_new (const char *filename,
if (-1 == (fd = open (filename, O_RDONLY, 0)))
{
- g_set_error (error,
- G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
+ /* errno is propagated */
return NULL;
}
- if (NULL == (self = sysprof_capture_reader_new_from_fd (fd, error)))
+ if (NULL == (self = sysprof_capture_reader_new_from_fd (fd)))
{
+ int errsv = errno;
close (fd);
+ errno = errsv;
return NULL;
}
@@ -996,9 +991,8 @@ sysprof_capture_reader_unref (SysprofCaptureReader *self)
}
bool
-sysprof_capture_reader_splice (SysprofCaptureReader *self,
- SysprofCaptureWriter *dest,
- GError **error)
+sysprof_capture_reader_splice (SysprofCaptureReader *self,
+ SysprofCaptureWriter *dest)
{
assert (self != NULL);
assert (self->fd != -1);
@@ -1007,10 +1001,7 @@ sysprof_capture_reader_splice (SysprofCaptureReader *self,
/* Flush before writing anything to ensure consistency */
if (!sysprof_capture_writer_flush (dest))
{
- g_set_error (error,
- G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
+ /* errno is propagated */
return false;
}
@@ -1019,30 +1010,32 @@ sysprof_capture_reader_splice (SysprofCaptureReader *self,
* track the current position to avoid reseting it.
*/
- /* Perform the splice */
- return _sysprof_capture_writer_splice_from_fd (dest, self->fd, error);
+ /* Perform the splice; errno is propagated on failure */
+ return _sysprof_capture_writer_splice_from_fd (dest, self->fd);
}
/**
* sysprof_capture_reader_save_as:
* @self: An #SysprofCaptureReader
* @filename: the file to save the capture as
- * @error: a location for a #GError or %NULL.
*
* This is a convenience function for copying a capture file for which
* you may have already discarded the writer for.
*
- * Returns: %TRUE on success; otherwise %FALSE and @error is set.
+ * `errno` is set on failure. It may be any of the errors returned by
+ * `open()`, `fstat()`, `ftruncate()`, `lseek()` or `sendfile()`.
+ *
+ * Returns: %TRUE on success; otherwise %FALSE.
*/
bool
-sysprof_capture_reader_save_as (SysprofCaptureReader *self,
- const char *filename,
- GError **error)
+sysprof_capture_reader_save_as (SysprofCaptureReader *self,
+ const char *filename)
{
struct stat stbuf;
off_t in_off;
size_t to_write;
int fd = -1;
+ int errsv;
assert (self != NULL);
assert (filename != NULL);
@@ -1087,13 +1080,12 @@ sysprof_capture_reader_save_as (SysprofCaptureReader *self,
return true;
handle_errno:
+ errsv = errno;
+
if (fd != -1)
close (fd);
- g_set_error (error,
- G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
+ errno = errsv;
return false;
}
diff --git a/src/libsysprof-capture/sysprof-capture-reader.h b/src/libsysprof-capture/sysprof-capture-reader.h
index 18561ad..c802e0a 100644
--- a/src/libsysprof-capture/sysprof-capture-reader.h
+++ b/src/libsysprof-capture/sysprof-capture-reader.h
@@ -67,11 +67,9 @@ SYSPROF_BEGIN_DECLS
typedef struct _SysprofCaptureReader SysprofCaptureReader;
SYSPROF_AVAILABLE_IN_ALL
-SysprofCaptureReader *sysprof_capture_reader_new (const char
*filename,
- GError
**error);
+SysprofCaptureReader *sysprof_capture_reader_new (const char
*filename);
SYSPROF_AVAILABLE_IN_ALL
-SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int
fd,
- GError
**error);
+SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int
fd);
SYSPROF_AVAILABLE_IN_ALL
SysprofCaptureReader *sysprof_capture_reader_copy (SysprofCaptureReader
*self);
SYSPROF_AVAILABLE_IN_ALL
@@ -128,12 +126,10 @@ SYSPROF_AVAILABLE_IN_ALL
bool sysprof_capture_reader_reset (SysprofCaptureReader
*self);
SYSPROF_AVAILABLE_IN_ALL
bool sysprof_capture_reader_splice (SysprofCaptureReader
*self,
- SysprofCaptureWriter
*dest,
- GError
**error);
+ SysprofCaptureWriter
*dest);
SYSPROF_AVAILABLE_IN_ALL
bool sysprof_capture_reader_save_as (SysprofCaptureReader
*self,
- const char
*filename,
- GError
**error);
+ const char
*filename);
SYSPROF_AVAILABLE_IN_ALL
bool sysprof_capture_reader_get_stat (SysprofCaptureReader
*self,
SysprofCaptureStat
*st_buf);
diff --git a/src/libsysprof/sysprof-proxy-source.c b/src/libsysprof/sysprof-proxy-source.c
index 967ae23..d290c8b 100644
--- a/src/libsysprof/sysprof-proxy-source.c
+++ b/src/libsysprof/sysprof-proxy-source.c
@@ -464,14 +464,16 @@ sysprof_proxy_source_complete_monitor (SysprofProxySource *self,
Monitor *monitor)
{
g_autoptr(SysprofCaptureReader) reader = NULL;
- g_autoptr(GError) error = NULL;
g_assert (SYSPROF_IS_PROXY_SOURCE (self));
g_assert (monitor != NULL);
g_assert (monitor->self == self);
- if (!(reader = sysprof_capture_reader_new_from_fd (steal_fd (&monitor->fd), &error)))
- g_warning ("Failed to load reader from peer FD: %s", error->message);
+ if (!(reader = sysprof_capture_reader_new_from_fd (steal_fd (&monitor->fd))))
+ {
+ int errsv = errno;
+ g_warning ("Failed to load reader from peer FD: %s", g_strerror (errsv));
+ }
else
sysprof_proxy_source_cat (self, reader);
}
diff --git a/src/libsysprof/sysprof-tracefd-source.c b/src/libsysprof/sysprof-tracefd-source.c
index a59cd1d..061f913 100644
--- a/src/libsysprof/sysprof-tracefd-source.c
+++ b/src/libsysprof/sysprof-tracefd-source.c
@@ -259,7 +259,7 @@ sysprof_tracefd_source_stop (SysprofSource *source)
{
g_autoptr(SysprofCaptureReader) reader = NULL;
- if ((reader = sysprof_capture_reader_new_from_fd (priv->tracefd, 0)))
+ if ((reader = sysprof_capture_reader_new_from_fd (priv->tracefd)))
sysprof_capture_writer_cat (priv->writer, reader, NULL);
priv->tracefd = -1;
diff --git a/src/tests/allocs-by-size.c b/src/tests/allocs-by-size.c
index 6260d4b..4f80414 100644
--- a/src/tests/allocs-by-size.c
+++ b/src/tests/allocs-by-size.c
@@ -134,9 +134,10 @@ main (gint argc,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/allocs-within-mark.c b/src/tests/allocs-within-mark.c
index 10d1228..9e2bfaa 100644
--- a/src/tests/allocs-within-mark.c
+++ b/src/tests/allocs-within-mark.c
@@ -205,9 +205,10 @@ main (gint argc,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/cross-thread-frees.c b/src/tests/cross-thread-frees.c
index f4ec892..6279e21 100644
--- a/src/tests/cross-thread-frees.c
+++ b/src/tests/cross-thread-frees.c
@@ -116,7 +116,6 @@ main (gint argc,
{
SysprofCaptureReader *reader;
const gchar *filename = argv[1];
- g_autoptr(GError) error = NULL;
if (argc < 2)
{
@@ -124,9 +123,10 @@ main (gint argc,
return EXIT_FAILURE;
}
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/find-temp-allocs.c b/src/tests/find-temp-allocs.c
index 3df3c2c..f4d3533 100644
--- a/src/tests/find-temp-allocs.c
+++ b/src/tests/find-temp-allocs.c
@@ -141,7 +141,6 @@ main (gint argc,
{
SysprofCaptureReader *reader;
const gchar *filename = argv[1];
- g_autoptr(GError) error = NULL;
if (argc < 2)
{
@@ -149,9 +148,10 @@ main (gint argc,
return EXIT_FAILURE;
}
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/memory-stack-stash.c b/src/tests/memory-stack-stash.c
index 7b6675c..7562c67 100644
--- a/src/tests/memory-stack-stash.c
+++ b/src/tests/memory-stack-stash.c
@@ -77,9 +77,10 @@ main (gint argc,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/show-page-usage.c b/src/tests/show-page-usage.c
index 0a6a1c2..9eb22ec 100644
--- a/src/tests/show-page-usage.c
+++ b/src/tests/show-page-usage.c
@@ -168,7 +168,6 @@ main (gint argc,
SysprofCaptureReader *reader;
const gchar *filename = argv[1];
g_autoptr(SysprofProfile) memprof = NULL;
- g_autoptr(GError) error = NULL;
if (argc < 2)
{
@@ -178,9 +177,10 @@ main (gint argc,
main_loop = g_main_loop_new (NULL, FALSE);
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
+ if (!(reader = sysprof_capture_reader_new (filename)))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tests/test-addr-decode.c b/src/tests/test-addr-decode.c
index 8757bed..dae7769 100644
--- a/src/tests/test-addr-decode.c
+++ b/src/tests/test-addr-decode.c
@@ -11,7 +11,6 @@ main (gint argc,
{
g_autoptr(SysprofCaptureReader) reader = NULL;
g_autoptr(SysprofSymbolResolver) resolver = NULL;
- g_autoptr(GError) error = NULL;
SysprofCaptureFrameType type;
if (argc != 2)
@@ -20,9 +19,10 @@ main (gint argc,
return 1;
}
- if (!(reader = sysprof_capture_reader_new (argv[1], &error)))
+ if (!(reader = sysprof_capture_reader_new (argv[1])))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return 1;
}
diff --git a/src/tests/test-addr-map.c b/src/tests/test-addr-map.c
index 022e814..918ba7a 100644
--- a/src/tests/test-addr-map.c
+++ b/src/tests/test-addr-map.c
@@ -92,9 +92,10 @@ main (gint argc,
return 1;
}
- if (!(reader = sysprof_capture_reader_new (argv[1], &error)))
+ if (!(reader = sysprof_capture_reader_new (argv[1])))
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return 1;
}
diff --git a/src/tests/test-capture-cursor.c b/src/tests/test-capture-cursor.c
index dd88416..9dc2e6c 100644
--- a/src/tests/test-capture-cursor.c
+++ b/src/tests/test-capture-cursor.c
@@ -37,20 +37,18 @@ test_cursor_basic (void)
SysprofCaptureReader *reader;
SysprofCaptureWriter *writer;
SysprofCaptureCursor *cursor;
- GError *error = NULL;
gint64 t = SYSPROF_CAPTURE_CURRENT_TIME;
guint i;
gint r;
gint count = 0;
writer = sysprof_capture_writer_new ("capture-cursor-file", 0);
- g_assert (writer != NULL);
+ g_assert_nonnull (writer);
sysprof_capture_writer_flush (writer);
- reader = sysprof_capture_reader_new ("capture-cursor-file", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("capture-cursor-file");
+ g_assert_nonnull (reader);
for (i = 0; i < 100; i++)
{
diff --git a/src/tests/test-capture.c b/src/tests/test-capture.c
index cb88f01..8f2d4f3 100644
--- a/src/tests/test-capture.c
+++ b/src/tests/test-capture.c
@@ -61,9 +61,8 @@ test_reader_basic (void)
sysprof_capture_writer_flush (writer);
- reader = sysprof_capture_reader_new ("capture-file", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("capture-file");
+ g_assert_nonnull (reader);
for (i = 0; i < 100; i++)
{
@@ -430,9 +429,8 @@ test_reader_basic (void)
g_clear_pointer (&writer, sysprof_capture_writer_unref);
g_clear_pointer (&reader, sysprof_capture_reader_unref);
- reader = sysprof_capture_reader_new ("capture-file.bak", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("capture-file.bak");
+ g_assert_nonnull (reader);
for (i = 0; i < 2; i++)
{
@@ -481,9 +479,8 @@ test_writer_splice (void)
g_clear_pointer (&writer1, sysprof_capture_writer_unref);
g_clear_pointer (&writer2, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("writer2.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("writer2.syscap");
+ g_assert_nonnull (reader);
for (i = 0; i < 1000; i++)
{
@@ -511,7 +508,6 @@ test_reader_splice (void)
SysprofCaptureWriter *writer2;
SysprofCaptureReader *reader;
SysprofCaptureFrameType type;
- GError *error = NULL;
guint i;
guint count;
gint r;
@@ -527,9 +523,8 @@ test_reader_splice (void)
g_clear_pointer (&writer1, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("writer1.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("writer1.syscap");
+ g_assert_nonnull (reader);
/* advance to the end of the reader to non-start boundary for fd */
@@ -546,14 +541,14 @@ test_reader_splice (void)
r = sysprof_capture_reader_peek_type (reader, &type);
g_assert_cmpint (r, ==, FALSE);
- r = sysprof_capture_reader_splice (reader, writer2, &error);
- g_assert_no_error (error);
- g_assert_cmpint (r, ==, TRUE);
+ r = sysprof_capture_reader_splice (reader, writer2);
+ g_assert_true (r);
g_clear_pointer (&reader, sysprof_capture_reader_unref);
g_clear_pointer (&writer2, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("writer2.syscap", 0);
+ reader = sysprof_capture_reader_new ("writer2.syscap");
+ g_assert_nonnull (reader);
for (i = 0; i < 1000; i++)
{
@@ -570,19 +565,16 @@ test_reader_splice (void)
g_clear_pointer (&reader, sysprof_capture_reader_unref);
- reader = sysprof_capture_reader_new ("writer2.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("writer2.syscap");
+ g_assert_nonnull (reader);
- r = sysprof_capture_reader_save_as (reader, "writer3.syscap", &error);
- g_assert_no_error (error);
- g_assert_cmpint (r, ==, TRUE);
+ r = sysprof_capture_reader_save_as (reader, "writer3.syscap");
+ g_assert_true (r);
g_clear_pointer (&reader, sysprof_capture_reader_unref);
- reader = sysprof_capture_reader_new ("writer3.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("writer3.syscap");
+ g_assert_nonnull (reader);
count = 0;
while (sysprof_capture_reader_skip (reader))
@@ -603,7 +595,6 @@ test_reader_writer_log (void)
SysprofCaptureReader *reader;
const SysprofCaptureLog *log;
SysprofCaptureFrameType type;
- GError *error = NULL;
gint r;
writer = sysprof_capture_writer_new ("log1.syscap", 0);
@@ -614,9 +605,8 @@ test_reader_writer_log (void)
g_clear_pointer (&writer, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("log1.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("log1.syscap");
+ g_assert_nonnull (reader);
log = sysprof_capture_reader_read_log (reader);
g_assert_nonnull (log);
@@ -657,7 +647,6 @@ test_reader_writer_mark (void)
SysprofCaptureReader *reader;
const SysprofCaptureMark *mark;
SysprofCaptureFrameType type;
- GError *error = NULL;
gint r;
writer = sysprof_capture_writer_new ("mark1.syscap", 0);
@@ -667,9 +656,8 @@ test_reader_writer_mark (void)
g_clear_pointer (&writer, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("mark1.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("mark1.syscap");
+ g_assert_nonnull (reader);
mark = sysprof_capture_reader_read_mark (reader);
g_assert_nonnull (mark);
@@ -704,7 +692,6 @@ test_reader_writer_metadata (void)
SysprofCaptureReader *reader;
const SysprofCaptureMetadata *metadata;
SysprofCaptureFrameType type;
- GError *error = NULL;
gint r;
writer = sysprof_capture_writer_new ("metadata1.syscap", 0);
@@ -717,9 +704,8 @@ test_reader_writer_metadata (void)
g_clear_pointer (&writer, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("metadata1.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("metadata1.syscap");
+ g_assert_nonnull (reader);
metadata = sysprof_capture_reader_read_metadata (reader);
g_assert_nonnull (metadata);
@@ -752,7 +738,6 @@ test_reader_writer_file (void)
SysprofCaptureWriter *writer;
SysprofCaptureReader *reader;
SysprofCaptureFrameType type;
- GError *error = NULL;
gsize data_len;
guint count = 0;
gint fd;
@@ -775,9 +760,8 @@ test_reader_writer_file (void)
g_clear_pointer (&writer, sysprof_capture_writer_unref);
- reader = sysprof_capture_reader_new ("file1.syscap", &error);
- g_assert_no_error (error);
- g_assert (reader != NULL);
+ reader = sysprof_capture_reader_new ("file1.syscap");
+ g_assert_nonnull (reader);
while (count < 2)
{
diff --git a/src/tests/test-resolvers.c b/src/tests/test-resolvers.c
index 8ba0e34..7cb8515 100644
--- a/src/tests/test-resolvers.c
+++ b/src/tests/test-resolvers.c
@@ -43,8 +43,12 @@ main (gint argc,
g_ptr_array_add (resolvers, sysprof_jitmap_symbol_resolver_new ());
g_ptr_array_add (resolvers, sysprof_kernel_symbol_resolver_new ());
- if (!(reader = sysprof_capture_reader_new (filename, &error)))
- g_error ("%s", error->message);
+ if (!(reader = sysprof_capture_reader_new (filename)))
+ {
+ int errsv = errno;
+ g_error ("%s", g_strerror (errsv));
+ return 1;
+ }
for (guint r = 0; r < resolvers->len; r++)
{
diff --git a/src/tools/list-threads.c b/src/tools/list-threads.c
index 30837c5..2a60540 100644
--- a/src/tools/list-threads.c
+++ b/src/tools/list-threads.c
@@ -59,9 +59,9 @@ main (gint argc,
}
if (g_strcmp0 ("-", argv[1]) == 0)
- reader = sysprof_capture_reader_new_from_fd (dup (STDIN_FILENO), 0);
+ reader = sysprof_capture_reader_new_from_fd (dup (STDIN_FILENO));
else
- reader = sysprof_capture_reader_new (argv[1], 0);
+ reader = sysprof_capture_reader_new (argv[1]);
if (reader == NULL)
{
diff --git a/src/tools/sysprof-cat.c b/src/tools/sysprof-cat.c
index eeca139..b49e200 100644
--- a/src/tools/sysprof-cat.c
+++ b/src/tools/sysprof-cat.c
@@ -73,10 +73,11 @@ main (gint argc,
g_autoptr(SysprofCaptureReader) reader = NULL;
g_autoptr(GError) error = NULL;
- if (!(reader = sysprof_capture_reader_new (argv[i], &error)))
+ if (!(reader = sysprof_capture_reader_new (argv[i])))
{
+ int errsv = errno;
g_printerr ("Failed to create reader for \"%s\": %s\n",
- argv[i], error->message);
+ argv[i], g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tools/sysprof-cli.c b/src/tools/sysprof-cli.c
index 32f3c42..b5d02a9 100644
--- a/src/tools/sysprof-cli.c
+++ b/src/tools/sysprof-cli.c
@@ -136,10 +136,11 @@ merge_files (gint argc,
g_autoptr(SysprofCaptureReader) reader = NULL;
g_autoptr(GError) error = NULL;
- if (!(reader = sysprof_capture_reader_new (argv[i], &error)))
+ if (!(reader = sysprof_capture_reader_new (argv[i])))
{
+ int errsv = errno;
g_printerr ("Failed to create reader for \"%s\": %s\n",
- argv[i], error->message);
+ argv[i], g_strerror (errsv));
return EXIT_FAILURE;
}
diff --git a/src/tools/sysprof-dump.c b/src/tools/sysprof-dump.c
index d90963d..cb85880 100644
--- a/src/tools/sysprof-dump.c
+++ b/src/tools/sysprof-dump.c
@@ -56,9 +56,10 @@ main (gint argc,
return EXIT_FAILURE;
}
- if ((reader = sysprof_capture_reader_new (argv[1], &error)) == NULL)
+ if ((reader = sysprof_capture_reader_new (argv[1])) == NULL)
{
- g_printerr ("%s\n", error->message);
+ int errsv = errno;
+ g_printerr ("%s\n", g_strerror (errsv));
return EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]