Commit graph

12 commits

Author SHA1 Message Date
Thomas Haller
f39138ea48 shared: add nm_auto_close and nm_auto_fclose
We already have gs_fd_close, which however doesn't preserve
errno and only checks for fd != -1. Add our own define.

Downside is, we have to include stdio.h and errno.h,
which effectively ends up to be included *everywhere*.

(cherry picked from commit 312cea870d)
2016-12-15 17:51:04 +01:00
Thomas Haller
d242fdc319 shared: add nm_assert_se() macro
We usually don't build NM with g_assert() disabled (G_DISABLE_ASSERT).
But even if we would, there is no assertion macro that always evaluates
the condition for possible side effects.

I think that is a useful thing to have.

(cherry picked from commit ba950cedee)
2016-11-03 12:24:00 +01:00
Thomas Haller
beeb676735 shared: add nm_clear_g_free()
(cherry picked from commit b4e66c4818)
2016-11-03 12:24:00 +01:00
Thomas Haller
7a8ed3fefd shared: make nm_str_not_empty() inline function instead of macro
It was a macro to pass on the non-const-ness of the argument, but
that just doesn't make sense.

That is a signature

  char *nm_str_not_empty (char *)

does not make sense, because you cannot transfer ownership
conditionally without additional checks to avoid a leak. Which makes
this form is pointless. For example:

    char *
    foo (void)
    {
        char *s;

        s = _create_value ();
        return nm_str_not_empty (s); /* leaks "" */
    }

(cherry picked from commit 34970e4141)
2016-10-24 10:33:07 +02:00
Thomas Haller
766f040681 macros: simplify NM_IN_SET() and NM_IN_STRSET() macros
and support up to 16 arguments.

(cherry picked from commit b1fd5a06c4)
2016-09-22 16:39:36 +02:00
Thomas Haller
5bac57496c shared: add _NM_GET_PRIVATE() macro
(cherry picked from commit 2cae9ba348)
2016-09-08 00:26:14 +02:00
Thomas Haller
811aaead4c shared: add NM_MIN()/NM_MAX() macros to replace glib's MIN()/MAX()
(cherry picked from commit b2016fd2a5)
2016-09-08 00:26:14 +02:00
Thomas Haller
4aad70a61d shared: add helper macros nm_str_not_empty() and nm_strdup_not_empty()
(cherry picked from commit 3227b9017b)
2016-09-06 16:16:19 +02:00
Thomas Haller
4041bf966f shared: add nm_strquote_a() helper 2016-07-05 23:08:22 +02:00
Beniamino Galvani
a5d1db08f8 dns: log DNS servers at TRACE level
Be more verbose at TRACE level and log the DNS servers associated to
configurations. This will help to debug issues like [0].

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1348887
2016-06-28 16:24:28 +02:00
Thomas Haller
3bcec4067f shared: include "nm-glib.h" from "nm-macros-internal.h"
"nm-glib.h" is our most basic header. "nm-macros-internal.h" extends
on that. Thus, let "nm-macros-internal.h" include "nm-glib.h".
2016-06-16 10:45:54 +02:00
Thomas Haller
4b288136e1 shared: move shared files to subdirectory "shared/nm-utils/"
The "shared" directory contains files that are possibly used by all components
of NetworkManager repository.

Some of these files are even copied as-is to other projects (VPN plugins, nm-applet)
and used there without modification. Move those files to a separate directory.
By moving them to a common directory, it is clearer that they belong
together. Also, you can easier compare the copied versions to their
original via

  $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
2016-06-16 10:45:53 +02:00
Renamed from shared/nm-macros-internal.h (Browse further)