[glib] gioerror: map some more values to G_IO_ERROR_NOT_SUPPORTED
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gioerror: map some more values to G_IO_ERROR_NOT_SUPPORTED
- Date: Sun, 30 Mar 2014 15:56:21 +0000 (UTC)
commit 9fc35dbfb6b804c0ead5dd3dba1bbf14773a2f8f
Author: Dan Winship <danw gnome org>
Date: Fri Mar 21 16:54:04 2014 -0400
gioerror: map some more values to G_IO_ERROR_NOT_SUPPORTED
Map EPROTONOSUPPORT, ESOCKTNOSUPPORT, EPFNOSUPPORT and EAFNOSUPPORT to
G_IO_ERROR_NOT_SUPPORTED in g_io_error_from_errno(). (GSocket's
socket_io_error_from_errno() already did this with the corresponding
Winsock errors.)
Also map EOPNOTSUPP, which on Linux is the same as ENOTSUP, but may
not be on other platforms.
Also, rewrite the EAGAIN/EWOULDBLOCK section to use the simpler idiom
used by EEXIST/ENOTEMPTY and (now) ENOTSUP/EOPNOTSUPP.
gio/gioenums.h | 2 +-
gio/gioerror.c | 59 +++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 40 insertions(+), 21 deletions(-)
---
diff --git a/gio/gioenums.h b/gio/gioenums.h
index 27ba3ce..9eaef31 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -432,7 +432,7 @@ typedef enum {
* @G_IO_ERROR_NO_SPACE: No space left on drive.
* @G_IO_ERROR_INVALID_ARGUMENT: Invalid argument.
* @G_IO_ERROR_PERMISSION_DENIED: Permission denied.
- * @G_IO_ERROR_NOT_SUPPORTED: Operation not supported for the current backend.
+ * @G_IO_ERROR_NOT_SUPPORTED: Operation (or one of its parameters) not supported
* @G_IO_ERROR_NOT_MOUNTED: File isn't mounted.
* @G_IO_ERROR_ALREADY_MOUNTED: File is already mounted.
* @G_IO_ERROR_CLOSED: File was closed.
diff --git a/gio/gioerror.c b/gio/gioerror.c
index 4434d9a..cce1dfe 100644
--- a/gio/gioerror.c
+++ b/gio/gioerror.c
@@ -134,7 +134,8 @@ g_io_error_from_errno (gint err_no)
break;
#endif
-#if defined(ENOTEMPTY) && (!defined (EEXIST) || (ENOTEMPTY != EEXIST))
+ /* ENOTEMPTY == EEXIST on AIX for backward compatibility reasons */
+#if defined (ENOTEMPTY) && (!defined (EEXIST) || (ENOTEMPTY != EEXIST))
case ENOTEMPTY:
return G_IO_ERROR_NOT_EMPTY;
break;
@@ -146,6 +147,37 @@ g_io_error_from_errno (gint err_no)
break;
#endif
+ /* EOPNOTSUPP == ENOTSUP on Linux, but POSIX considers them distinct */
+#if defined (EOPNOTSUPP) && (!defined (ENOTSUP) || (EOPNOTSUPP != ENOTSUP))
+ case EOPNOTSUPP:
+ return G_IO_ERROR_NOT_SUPPORTED;
+ break;
+#endif
+
+#ifdef EPROTONOSUPPORT
+ case EPROTONOSUPPORT:
+ return G_IO_ERROR_NOT_SUPPORTED;
+ break;
+#endif
+
+#ifdef ESOCKTNOSUPPORT
+ case ESOCKTNOSUPPORT:
+ return G_IO_ERROR_NOT_SUPPORTED;
+ break;
+#endif
+
+#ifdef EPFNOSUPPORT
+ case EPFNOSUPPORT:
+ return G_IO_ERROR_NOT_SUPPORTED;
+ break;
+#endif
+
+#ifdef EAFNOSUPPORT
+ case EAFNOSUPPORT:
+ return G_IO_ERROR_NOT_SUPPORTED;
+ break;
+#endif
+
#ifdef ETIMEDOUT
case ETIMEDOUT:
return G_IO_ERROR_TIMED_OUT;
@@ -158,30 +190,17 @@ g_io_error_from_errno (gint err_no)
break;
#endif
-/* some magic to deal with EWOULDBLOCK and EAGAIN.
- * apparently on HP-UX these are actually defined to different values,
- * but on Linux, for example, they are the same.
- */
-#if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK == EAGAIN
- /* we have both and they are the same: only emit one case. */
- case EAGAIN:
- return G_IO_ERROR_WOULD_BLOCK;
- break;
-#else
- /* else: consider each of them separately. this handles both the
- * case of having only one and the case where they are different values.
- */
-# ifdef EAGAIN
- case EAGAIN:
+#ifdef EWOULDBLOCK
+ case EWOULDBLOCK:
return G_IO_ERROR_WOULD_BLOCK;
break;
-# endif
+#endif
-# ifdef EWOULDBLOCK
- case EWOULDBLOCK:
+ /* EWOULDBLOCK == EAGAIN on most systems, but POSIX considers them distinct */
+#if defined (EAGAIN) && (!defined (EWOULDBLOCK) || (EWOULDBLOCK != EAGAIN))
+ case EAGAIN:
return G_IO_ERROR_WOULD_BLOCK;
break;
-# endif
#endif
#ifdef EMFILE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]