[glib] Always include G_SOCKET_FAMILY_UNIX value in GSocketFamily
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Always include G_SOCKET_FAMILY_UNIX value in GSocketFamily
- Date: Wed, 4 Apr 2012 09:40:45 +0000 (UTC)
commit 118c42e7471155d444b9df38d9538f344cb7f89c
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Apr 4 11:39:03 2012 +0200
Always include G_SOCKET_FAMILY_UNIX value in GSocketFamily
This is needed because glib-mkenums doesn't handle #ifdef values in
enums, and so it needs to have all values always defined in the enum.
When not available, define the missing values to a negative value.
configure.ac | 12 +++++++++++-
gio/gioenums.h | 2 --
gio/gsocket.c | 7 +++++++
3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a40961..cbd868d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3344,7 +3344,17 @@ g_pollhup=$glib_cv_value_POLLHUP
g_pollerr=$glib_cv_value_POLLERR
g_pollnval=$glib_cv_value_POLLNVAL
-g_af_unix=$glib_cv_value_AF_UNIX
+# If a family is not found on the system, define that family to
+# a negative value, picking a different one for each undefined
+# family (-1 for AF_UNIX, -2 for the next one, -3 ...)
+# This is needed because glib-mkenums doesn't handle optional
+# values in enums, and thus we have to have all existing values
+# defined in the enum.
+if "x$glib_cv_value_AF_UNIX" != "x"; then
+ g_af_unix=$glib_cv_value_AF_UNIX
+else
+ g_af_unix=-1
+fi
g_af_inet=$glib_cv_value_AF_INET
g_af_inet6=$glib_cv_value_AF_INET6
diff --git a/gio/gioenums.h b/gio/gioenums.h
index 61f8aa3..dd97230 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -687,9 +687,7 @@ typedef enum /*< flags >*/ {
*/
typedef enum {
G_SOCKET_FAMILY_INVALID,
-#ifdef GLIB_SYSDEF_AF_UNIX
G_SOCKET_FAMILY_UNIX = GLIB_SYSDEF_AF_UNIX,
-#endif
G_SOCKET_FAMILY_IPV4 = GLIB_SYSDEF_AF_INET,
G_SOCKET_FAMILY_IPV6 = GLIB_SYSDEF_AF_INET6
} GSocketFamily;
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 0fa133f..b24000f 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -500,6 +500,13 @@ g_socket_create_socket (GSocketFamily family,
g_assert_not_reached ();
}
+ if (family < 0)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Unable to create socket: %s"), _("Unknown family was specified"));
+ return -1;
+ }
+
if (protocol == -1)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]