Skip to content

Commit

Permalink
util: drop custom set_prefix_error_from_errno
Browse files Browse the repository at this point in the history
We can use libglnx functions for this now.

Closes: #643
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Feb 23, 2017
1 parent f573354 commit c0b4fbc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 59 deletions.
3 changes: 1 addition & 2 deletions src/app/rpmostree-compose-builtin-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,7 @@ rpmostree_compose_builtin_tree (int argc,
{
if (mount ("tmpfs", tmpd, "tmpfs", 0, (const void*)"mode=755") != 0)
{
_rpmostree_set_prefix_error_from_errno (error, errno,
"mount(tmpfs): ");
glnx_set_prefix_error_from_errno (error, "%s", "mount(tmpfs)");
goto out;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/libpriv/rpmostree-passwd-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ gfopen (const char *path,
ret = fopen (path, mode);
if (!ret)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "fopen(%s): ", path);
glnx_set_prefix_error_from_errno (error, "fopen(%s)", path);
return NULL;
}
return ret;
Expand All @@ -692,7 +692,7 @@ gfflush (FILE *f,
{
if (fflush (f) != 0)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "fflush: ");
glnx_set_prefix_error_from_errno (error, "%s", "fflush");
return FALSE;
}
return TRUE;
Expand Down Expand Up @@ -754,7 +754,7 @@ rpmostree_passwd_migrate_except_root (GFile *rootfs,
{
if (errno != 0 && errno != ENOENT)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "fgetpwent: ");
glnx_set_prefix_error_from_errno (error, "%s", "fgetpwent");
goto out;
}
else
Expand Down Expand Up @@ -802,7 +802,7 @@ rpmostree_passwd_migrate_except_root (GFile *rootfs,

if (r == -1)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "putpwent: ");
glnx_set_prefix_error_from_errno (error, "%s", "putpwent");
goto out;
}
}
Expand All @@ -814,8 +814,8 @@ rpmostree_passwd_migrate_except_root (GFile *rootfs,

if (rename (etctmp_path, src_path) != 0)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "rename(%s, %s): ",
etctmp_path, src_path);
glnx_set_prefix_error_from_errno (error, "rename(%s, %s)",
etctmp_path, src_path);
goto out;
}

Expand Down Expand Up @@ -905,7 +905,7 @@ concat_entries (FILE *src_stream,
{
if (errno != 0 && errno != ENOENT)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "fgetpwent: ");
glnx_set_prefix_error_from_errno (error, "%s", "fgetpwent");
goto out;
}
else
Expand All @@ -929,7 +929,7 @@ concat_entries (FILE *src_stream,

if (r == -1)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "putpwent: ");
glnx_set_prefix_error_from_errno (error, "%s", "putpwent");
goto out;
}
}
Expand Down
38 changes: 1 addition & 37 deletions src/libpriv/rpmostree-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,6 @@
#include "rpmostree-util.h"
#include "libglnx.h"

void
_rpmostree_set_error_from_errno (GError **error,
gint errsv)
{
g_set_error_literal (error,
G_IO_ERROR,
g_io_error_from_errno (errsv),
g_strerror (errsv));
errno = errsv;
}

void
_rpmostree_set_prefix_error_from_errno (GError **error,
gint errsv,
const char *format,
...)
{
g_autofree char *formatted = NULL;
va_list args;

va_start (args, format);
formatted = g_strdup_vprintf (format, args);
va_end (args);

_rpmostree_set_error_from_errno (error, errsv);
g_prefix_error (error, "%s", formatted);
errno = errsv;
}

void
_rpmostree_perror_fatal (const char *message)
{
perror (message);
exit (1);
}

int
rpmostree_ptrarray_sort_compare_strings (gconstpointer ap,
gconstpointer bp)
Expand Down Expand Up @@ -376,7 +340,7 @@ _rpmostree_sync_wait_on_pid (pid_t pid,

if (r == -1)
{
_rpmostree_set_prefix_error_from_errno (error, errno, "waitpid: ");
glnx_set_prefix_error_from_errno (error, "%s", "waitpid");
goto out;
}

Expand Down
12 changes: 0 additions & 12 deletions src/libpriv/rpmostree-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@
#include <sys/wait.h>
#include <ostree.h>

void
_rpmostree_set_error_from_errno (GError **error,
gint errsv);

void
_rpmostree_set_prefix_error_from_errno (GError **error,
gint errsv,
const char *format,
...) G_GNUC_PRINTF (3,4);

void _rpmostree_perror_fatal (const char *message) __attribute__ ((noreturn));

int
rpmostree_ptrarray_sort_compare_strings (gconstpointer ap,
gconstpointer bp);
Expand Down

0 comments on commit c0b4fbc

Please sign in to comment.