X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgunixfdlist.c;h=5808e40cdf9a1dd9c6530e93481baa0b55556d51;hb=9da85c7262325478e8730ae9f3e76bd0528a9a8c;hp=0348512fc840b8c981953b8a50ff78629a2115c0;hpb=fdaaa22b58b20c285bc0c328cd6a97bb6c0f0258;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gunixfdlist.c b/gio/gunixfdlist.c index 0348512..5808e40 100644 --- a/gio/gunixfdlist.c +++ b/gio/gunixfdlist.c @@ -26,41 +26,34 @@ * the %G_SOCKET_ADDRESS_UNIX family by using g_socket_send_message() * and received using g_socket_receive_message(). * - * Note that <gio/gunixfdlist.h> belongs to - * the UNIX-specific GIO interfaces, thus you have to use the - * gio-unix-2.0.pc pkg-config file when using it. + * Note that `` belongs to the UNIX-specific GIO + * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config + * file when using it. */ -#define _GNU_SOURCE /* for F_DUPFD_CLOEXEC */ - #include "config.h" -#include -#include #include #include #include #include #include "gunixfdlist.h" +#include "gnetworking.h" #include "gioerror.h" - - -G_DEFINE_TYPE (GUnixFDList, g_unix_fd_list, G_TYPE_OBJECT) - struct _GUnixFDListPrivate { gint *fds; gint nfd; }; +G_DEFINE_TYPE_WITH_PRIVATE (GUnixFDList, g_unix_fd_list, G_TYPE_OBJECT) + static void g_unix_fd_list_init (GUnixFDList *list) { - list->priv = G_TYPE_INSTANCE_GET_PRIVATE (list, - G_TYPE_UNIX_FD_LIST, - GUnixFDListPrivate); + list->priv = g_unix_fd_list_get_instance_private (list); } static void @@ -82,7 +75,6 @@ g_unix_fd_list_class_init (GUnixFDListClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - g_type_class_add_private (class, sizeof (GUnixFDListPrivate)); object_class->finalize = g_unix_fd_list_finalize; } @@ -115,7 +107,6 @@ dup_close_on_exec_fd (gint fd, g_set_error (error, G_IO_ERROR, g_io_error_from_errno (saved_errno), "dup: %s", g_strerror (saved_errno)); - close (new_fd); return -1; } @@ -192,7 +183,8 @@ g_unix_fd_list_new_from_array (const gint *fds, list->priv->fds = g_new (gint, n_fds + 1); list->priv->nfd = n_fds; - memcpy (list->priv->fds, fds, sizeof (gint) * n_fds); + if (n_fds > 0) + memcpy (list->priv->fds, fds, sizeof (gint) * n_fds); list->priv->fds[n_fds] = -1; return list;