Commit 943dcba5 authored by Thomas Haller's avatar Thomas Haller

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.
parent 9e9320cc
......@@ -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 \
......
......@@ -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
......
/* 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"
/*****************************************************************************/
/* 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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment