summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-22 12:41:04 +0100
committerThomas Haller <thaller@redhat.com>2018-12-27 21:30:22 +0100
commit943dcba531545ba5cb6e3a0656427381fee136a2 (patch)
treebcdd18b52504710961f8274757d90956019c4987
parent9e9320cc0f09f1066afe49568c13feda90bcf1be (diff)
downloadNetworkManager-943dcba531545ba5cb6e3a0656427381fee136a2.tar.gz
shared,core: add "nm-errno.h"
This will be our extension on top of <errno.h>. We want to use (integer) error numbers, that can both contain native errors from <errno.h> and our own defines, both merge in one domain. That is, we will reserve a small range of integers for our own defines (that hopefully won't clash with errors from <errno.h>). We can use this at places where GError is too cumbersome to use. The advantage is, that our error numbers extend <errno.h> and can be mixed. This is what "src/platform/nm-netlink.h" already does with nl_errno(). Next, the netlink errors from there will be merged into "nm-errno.h". Also, platform has NMPlatformError, which are a distinct set of error numbers. But these work differently in the sense that negative values represent codes from <errno.h> and positive numbers are our own platform specific defines. NMPlatformError will also be merged into "nm-errno.h". "nm-errno.h" will unify the error handling of platform and netlink, making it more similar to what we are used to from systemd, and give room to extend it for our own purpose.
-rw-r--r--Makefile.am2
-rw-r--r--shared/meson.build1
-rw-r--r--shared/nm-utils/nm-errno.c25
-rw-r--r--shared/nm-utils/nm-errno.h26
4 files changed, 54 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 6b0812b6aa..b1378c0348 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -302,6 +302,8 @@ shared_nm_utils_libnm_utils_base_la_SOURCES = \
shared/nm-utils/nm-dedup-multi.h \
shared/nm-utils/nm-enum-utils.c \
shared/nm-utils/nm-enum-utils.h \
+ shared/nm-utils/nm-errno.c \
+ shared/nm-utils/nm-errno.h \
shared/nm-utils/nm-glib.h \
shared/nm-utils/nm-hash-utils.c \
shared/nm-utils/nm-hash-utils.h \
diff --git a/shared/meson.build b/shared/meson.build
index 2ebef2460b..753c6fb25f 100644
--- a/shared/meson.build
+++ b/shared/meson.build
@@ -87,6 +87,7 @@ shared_files_libnm_core = files('''
nm-utils/c-list-util.c
nm-utils/nm-dedup-multi.c
nm-utils/nm-enum-utils.c
+ nm-utils/nm-errno.c
nm-utils/nm-hash-utils.c
nm-utils/nm-io-utils.c
nm-utils/nm-random-utils.c
diff --git a/shared/nm-utils/nm-errno.c b/shared/nm-utils/nm-errno.c
new file mode 100644
index 0000000000..f44dbf06fe
--- /dev/null
+++ b/shared/nm-utils/nm-errno.c
@@ -0,0 +1,25 @@
+/* NetworkManager -- Network link manager
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2018 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+
+#include "nm-errno.h"
+
+/*****************************************************************************/
diff --git a/shared/nm-utils/nm-errno.h b/shared/nm-utils/nm-errno.h
new file mode 100644
index 0000000000..2f35e10c77
--- /dev/null
+++ b/shared/nm-utils/nm-errno.h
@@ -0,0 +1,26 @@
+/* NetworkManager -- Network link manager
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2018 Red Hat, Inc.
+ */
+
+#ifndef __NM_ERRNO_H__
+#define __NM_ERRNO_H__
+
+#include <errno.h>
+
+#endif /* __NM_ERRNO_H__ */