[systemd-commits] 6 commits - Makefile.am src/network src/shared src/systemd src/udev tmpfiles.d/home.conf tmpfiles.d/systemd-nologin.conf tmpfiles.d/var.conf

Lennart Poettering lennart at kemper.freedesktop.org
Tue Apr 21 08:46:01 PDT 2015


 Makefile.am                     |    3 
 src/network/networkd-address.c  |    6 
 src/network/networkd-fdb.c      |   79 +++---
 src/network/networkd-link.c     |  458 ++++++++++++++--------------------------
 src/network/networkd-netdev.c   |  190 ++++------------
 src/network/networkd-netdev.h   |   20 +
 src/network/networkd-network.c  |   15 -
 src/network/networkd.h          |    2 
 src/shared/conf-parser.c        |   44 ---
 src/shared/conf-parser.h        |   17 -
 src/shared/log.c                |   56 ++++
 src/shared/log.h                |   21 +
 src/systemd/sd-messages.h       |    2 
 src/udev/udevadm-info.c         |   14 -
 tmpfiles.d/home.conf            |   11 
 tmpfiles.d/systemd-nologin.conf |    2 
 tmpfiles.d/var.conf             |    2 
 17 files changed, 379 insertions(+), 563 deletions(-)

New commits:
commit 8519d8f58ec3c5f8488be0ee557a30c21b1d0616
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 17:43:31 2015 +0200

    networkd-fdb: indentation/whitespace fixes

diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index 72ac40d..796d111 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -148,9 +148,9 @@ void fdb_entry_free(FdbEntry *fdb_entry) {
                 LIST_REMOVE(static_fdb_entries, fdb_entry->network->static_fdb_entries,
                             fdb_entry);
 
-                if(fdb_entry->section)
-                    hashmap_remove(fdb_entry->network->fdb_entries_by_section,
-                                   UINT_TO_PTR(fdb_entry->section));
+                if (fdb_entry->section)
+                        hashmap_remove(fdb_entry->network->fdb_entries_by_section,
+                                       UINT_TO_PTR(fdb_entry->section));
         }
 
         free(fdb_entry->mac_addr);
@@ -159,16 +159,18 @@ void fdb_entry_free(FdbEntry *fdb_entry) {
 }
 
 /* parse the HW address from config files. */
-int config_parse_fdb_hwaddr(const char *unit,
-                            const char *filename,
-                            unsigned line,
-                            const char *section,
-                            unsigned section_line,
-                            const char *lvalue,
-                            int ltype,
-                            const char *rvalue,
-                            void *data,
-                            void *userdata) {
+int config_parse_fdb_hwaddr(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
         Network *network = userdata;
         _cleanup_fdbentry_free_ FdbEntry *fdb_entry = NULL;
         int r;
@@ -192,9 +194,8 @@ int config_parse_fdb_hwaddr(const char *unit,
                    &fdb_entry->mac_addr->ether_addr_octet[4],
                    &fdb_entry->mac_addr->ether_addr_octet[5]);
 
-        if (ETHER_ADDR_LEN !=  r) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Not a valid MAC address, ignoring assignment: %s", rvalue);
+        if (ETHER_ADDR_LEN != r) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not a valid MAC address, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
@@ -204,16 +205,18 @@ int config_parse_fdb_hwaddr(const char *unit,
 }
 
 /* parse the VLAN Id from config files. */
-int config_parse_fdb_vlan_id(const char *unit,
-                             const char *filename,
-                             unsigned line,
-                             const char *section,
-                             unsigned section_line,
-                             const char *lvalue,
-                             int ltype,
-                             const char *rvalue,
-                             void *data,
-                             void *userdata) {
+int config_parse_fdb_vlan_id(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
         Network *network = userdata;
         _cleanup_fdbentry_free_ FdbEntry *fdb_entry = NULL;
         int r;

commit 6a7a4e4d0a057febab787a2d5d3e0b52d2db2268
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 17:40:18 2015 +0200

    networkd: improve how networkd logs things
    
    This makes adds a couple of fixes:
    
    - Introduces log_netdev_error_errno() and friends, which takes an error
      number, and matches what log_link_error_errno() and friends do.
    
    - Replaces a lof ot strerror() usage with log_netdev_error_errno(),
      log_link_error_errno() and log_erro_errno()
    
    - Uppercases the first character of many log messages, after all this is
      supposed to be english language
    
    - Drops manual negating of error codes before passing them to log
      functions, the log functions all do that internally anyway.
    
    Some other minor fixes.
    
    Behaviour should not change really.

diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 85acc49..a3aa1f7 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -274,10 +274,8 @@ static int address_acquire(Link *link, Address *original, Address **ret) {
         /* The address is configured to be 0.0.0.0 or [::] by the user?
          * Then let's acquire something more useful from the pool. */
         r = manager_address_pool_acquire(link->manager, original->family, original->prefixlen, &in_addr);
-        if (r < 0) {
-                log_link_error(link, "Failed to acquire address from pool: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Failed to acquire address from pool: %m");
         if (r == 0) {
                 log_link_error(link, "Couldn't find free address for interface, all taken.");
                 return -EBUSY;
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index b6b8327..72ac40d 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -88,7 +88,7 @@ static int set_fdb_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EEXIST)
-                log_link_error(link, "Could not add FDB entry: %s", strerror(-r));
+                log_link_error_errno(link, r, "Could not add FDB entry: %m");
 
         return 1;
 }
@@ -133,10 +133,8 @@ int fdb_entry_configure(Link *const link, FdbEntry *const fdb_entry) {
 
         /* send message to the kernel to update its internal static MAC table. */
         r = sd_rtnl_call_async(rtnl, req, set_fdb_handler, link, 0, NULL);
-        if (r < 0) {
-                log_link_error(link, "Could not send rtnetlink message: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
 
         return 0;
 }
@@ -182,10 +180,8 @@ int config_parse_fdb_hwaddr(const char *unit,
         assert(data);
 
         r = fdb_entry_new_static(network, section_line, &fdb_entry);
-        if (r < 0) {
-                log_error("Failed to allocate a new FDB entry: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_oom();
 
         /* read in the MAC address for the FDB table. */
         r = sscanf(rvalue, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
@@ -229,18 +225,14 @@ int config_parse_fdb_vlan_id(const char *unit,
         assert(data);
 
         r = fdb_entry_new_static(network, section_line, &fdb_entry);
-        if (r < 0) {
-                log_error("Failed to allocate a new FDB entry: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_oom();
 
         r = config_parse_unsigned(unit, filename, line, section,
                                   section_line, lvalue, ltype,
                                   rvalue, &fdb_entry->vlan_id, userdata);
-        if (r < 0) {
-                log_error("Failed to parse the unsigned integer: %s", strerror(-r));
+        if (r < 0)
                 return r;
-        }
 
         fdb_entry = NULL;
 
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index be9e5ed..ab115a0 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -128,10 +128,8 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
         assert(link);
 
         r = sd_rtnl_message_link_get_flags(m, &flags);
-        if (r < 0) {
-                log_link_warning(link, "Could not get link flags");
-                return r;
-        }
+        if (r < 0)
+                return log_link_warning_errno(link, r, "Could not get link flags: %m");
 
         r = sd_rtnl_message_read_u8(m, IFLA_OPERSTATE, &operstate);
         if (r < 0)
@@ -143,7 +141,7 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
                 return 0;
 
         if (link->flags != flags) {
-                log_link_debug(link, "flags change:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+                log_link_debug(link, "Flags change:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                                FLAG_STRING("LOOPBACK", IFF_LOOPBACK, link->flags, flags),
                                FLAG_STRING("MASTER", IFF_MASTER, link->flags, flags),
                                FLAG_STRING("SLAVE", IFF_SLAVE, link->flags, flags),
@@ -177,12 +175,12 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
                  * printing 20 */
                 if (unknown_flags_added)
                         log_link_debug(link,
-                                       "unknown link flags gained: %#.5x (ignoring)",
+                                       "Unknown link flags gained: %#.5x (ignoring)",
                                        unknown_flags_added);
 
                 if (unknown_flags_removed)
                         log_link_debug(link,
-                                       "unknown link flags lost: %#.5x (ignoring)",
+                                       "Unknown link flags lost: %#.5x (ignoring)",
                                        unknown_flags_removed);
         }
 
@@ -368,7 +366,7 @@ static void link_set_state(Link *link, LinkState state) {
 static void link_enter_unmanaged(Link *link) {
         assert(link);
 
-        log_link_debug(link, "unmanaged");
+        log_link_debug(link, "Unmanaged");
 
         link_set_state(link, LINK_STATE_UNMANAGED);
 
@@ -387,50 +385,32 @@ static int link_stop_clients(Link *link) {
 
         if (link->dhcp_client) {
                 k = sd_dhcp_client_stop(link->dhcp_client);
-                if (k < 0) {
-                        log_link_warning(link, "Could not stop DHCPv4 client: %s",
-                                         strerror(-r));
-                        r = k;
-                }
+                if (k < 0)
+                        r = log_link_warning_errno(link, r, "Could not stop DHCPv4 client: %m");
         }
 
         if (link->ipv4ll) {
                 k = sd_ipv4ll_stop(link->ipv4ll);
-                if (k < 0) {
-                        log_link_warning(link, "Could not stop IPv4 link-local: %s",
-                                         strerror(-r));
-                        r = k;
-                }
+                if (k < 0)
+                        r = log_link_warning_errno(link, r, "Could not stop IPv4 link-local: %m");
         }
 
         if(link->icmp6_router_discovery) {
-
                 if (link->dhcp6_client) {
                         k = sd_dhcp6_client_stop(link->dhcp6_client);
-                        if (k < 0) {
-                                log_link_warning(link, "Could not stop DHCPv6 client: %s",
-                                                 strerror(-r));
-                                r = k;
-                        }
+                        if (k < 0)
+                                r = log_link_warning_errno(link, r, "Could not stop DHCPv6 client: %m");
                 }
 
                 k = sd_icmp6_nd_stop(link->icmp6_router_discovery);
-                if (k < 0) {
-                        log_link_warning(link,
-                                         "Could not stop ICMPv6 router discovery: %s",
-                                         strerror(-r));
-                        r = k;
-                }
+                if (k < 0)
+                        r = log_link_warning_errno(link, r, "Could not stop ICMPv6 router discovery: %m");
         }
 
         if (link->lldp) {
-
                 k = sd_lldp_stop(link->lldp);
-                if (k < 0) {
-                        log_link_warning(link, "Could not stop LLDP : %s",
-                                         strerror(-r));
-                        r = k;
-                }
+                if (k < 0)
+                        r = log_link_warning_errno(link, r, "Could not stop LLDP: %m");
         }
 
         return r;
@@ -442,7 +422,7 @@ void link_enter_failed(Link *link) {
         if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
                 return;
 
-        log_link_warning(link, "failed");
+        log_link_warning(link, "Failed");
 
         link_set_state(link, LINK_STATE_FAILED);
 
@@ -485,7 +465,7 @@ static int link_enter_configured(Link *link) {
         assert(link->network);
         assert(link->state == LINK_STATE_SETTING_ROUTES);
 
-        log_link_info(link, "link configured");
+        log_link_info(link, "Configured");
 
         link_set_state(link, LINK_STATE_CONFIGURED);
 
@@ -531,10 +511,10 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EEXIST)
-                log_link_warning_errno(link, -r, "%-*s: could not set route: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not set route: %m", IFNAMSIZ, link->ifname);
 
         if (link->link_messages == 0) {
-                log_link_debug(link, "routes set");
+                log_link_debug(link, "Routes set");
                 link->static_configured = true;
                 link_client_handler(link);
         }
@@ -555,9 +535,7 @@ static int link_enter_set_routes(Link *link) {
         LIST_FOREACH(routes, rt, link->network->static_routes) {
                 r = route_configure(rt, link, &route_handler);
                 if (r < 0) {
-                        log_link_warning(link,
-                                         "could not set routes: %s",
-                                         strerror(-r));
+                        log_link_warning_errno(link, r, "Could not set routes: %m");
                         link_enter_failed(link);
                         return r;
                 }
@@ -569,7 +547,7 @@ static int link_enter_set_routes(Link *link) {
                 link->static_configured = true;
                 link_client_handler(link);
         } else
-                log_link_debug(link, "setting routes");
+                log_link_debug(link, "Setting routes");
 
         return 0;
 }
@@ -587,7 +565,7 @@ int link_route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -ESRCH)
-                log_link_warning_errno(link, -r, "%-*s: could not drop route: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not drop route: %m", IFNAMSIZ, link->ifname);
 
         return 1;
 }
@@ -611,12 +589,12 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EEXIST)
-                log_link_warning_errno(link, -r, "%-*s: could not set address: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not set address: %m", IFNAMSIZ, link->ifname);
         else if (r >= 0)
                 link_rtnl_process_address(rtnl, m, link->manager);
 
         if (link->link_messages == 0) {
-                log_link_debug(link, "addresses set");
+                log_link_debug(link, "Addresses set");
                 link_enter_set_routes(link);
         }
 
@@ -652,8 +630,7 @@ static int link_enter_set_addresses(Link *link) {
 
                 address = link_find_dhcp_server_address(link);
                 if (!address) {
-                        log_link_warning(link,
-                                         "Failed to find suitable address for DHCPv4 server instance.");
+                        log_link_warning(link, "Failed to find suitable address for DHCPv4 server instance.");
                         link_enter_failed(link);
                         return 0;
                 }
@@ -685,21 +662,20 @@ static int link_enter_set_addresses(Link *link) {
 
                 r = sd_dhcp_server_start(link->dhcp_server);
                 if (r < 0) {
-                        log_link_warning(link, "could not start DHCPv4 server "
-                                         "instance: %s", strerror(-r));
+                        log_link_warning_errno(link, r, "Could not start DHCPv4 server instance: %m");
 
                         link_enter_failed(link);
 
                         return 0;
                 }
 
-                log_link_debug(link, "offering DHCPv4 leases");
+                log_link_debug(link, "Offering DHCPv4 leases");
         }
 
-        if (link->link_messages == 0) {
+        if (link->link_messages == 0)
                 link_enter_set_routes(link);
-        } else
-                log_link_debug(link, "setting addresses");
+        else
+                log_link_debug(link, "Setting addresses");
 
         return 0;
 }
@@ -717,7 +693,7 @@ int link_address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EADDRNOTAVAIL)
-                log_link_warning_errno(link, -r, "%-*s: could not drop address: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not drop address: %m", IFNAMSIZ, link->ifname);
 
         return 1;
 }
@@ -729,7 +705,7 @@ static int link_set_bridge_fdb(Link *const link) {
         LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
                 r = fdb_entry_configure(link, fdb_entry);
                 if(r < 0) {
-                        log_link_error(link, "Failed to add MAC entry to static MAC table: %s", strerror(-r));
+                        log_link_error_errno(link, r, "Failed to add MAC entry to static MAC table: %m");
                         break;
                 }
         }
@@ -741,14 +717,14 @@ static int link_set_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
         _cleanup_link_unref_ Link *link = userdata;
         int r;
 
-        log_link_debug(link, "set link");
+        log_link_debug(link, "Set link");
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EEXIST) {
                 log_link_struct(link, LOG_ERR,
                                 "MESSAGE=%-*s: could not join netdev: %s",
-                                IFNAMSIZ,
-                                link->ifname, strerror(-r),
+                                IFNAMSIZ, link->ifname,
+                                strerror(-r),
                                 "ERRNO=%d", -r,
                                 NULL);
                 link_enter_failed(link);
@@ -770,8 +746,7 @@ static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata,
 
         r = sd_bus_message_get_errno(m);
         if (r > 0)
-                log_link_warning(link, "Could not set hostname: %s",
-                                 strerror(r));
+                log_link_warning_errno(link, r, "Could not set hostname: %m");
 
         return 1;
 }
@@ -788,8 +763,7 @@ int link_set_hostname(Link *link, const char *hostname) {
 
         if (!link->manager->bus) {
                 /* TODO: replace by assert when we can rely on kdbus */
-                log_link_info(link,
-                              "Not connected to system bus, ignoring transient hostname.");
+                log_link_info(link, "Not connected to system bus, ignoring transient hostname.");
                 return 0;
         }
 
@@ -809,11 +783,8 @@ int link_set_hostname(Link *link, const char *hostname) {
 
         r = sd_bus_call_async(link->manager->bus, NULL, m, set_hostname_handler,
                               link, 0);
-        if (r < 0) {
-                log_link_error(link, "Could not set transient hostname: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not set transient hostname: %m");
 
         link_ref(link);
 
@@ -833,7 +804,7 @@ static int set_mtu_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0)
-                log_link_warning_errno(link, -r, "%-*s: could not set MTU: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not set MTU: %m", IFNAMSIZ, link->ifname);
 
         return 1;
 }
@@ -846,29 +817,19 @@ int link_set_mtu(Link *link, uint32_t mtu) {
         assert(link->manager);
         assert(link->manager->rtnl);
 
-        log_link_debug(link, "setting MTU: %" PRIu32, mtu);
+        log_link_debug(link, "Setting MTU: %" PRIu32, mtu);
 
-        r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
-                                     RTM_SETLINK, link->ifindex);
-        if (r < 0) {
-                log_link_error(link, "Could not allocate RTM_SETLINK message");
-                return r;
-        }
+        r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
 
         r = sd_rtnl_message_append_u32(req, IFLA_MTU, mtu);
-        if (r < 0) {
-                log_link_error(link, "Could not append MTU: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not append MTU: %m");
 
-        r = sd_rtnl_call_async(link->manager->rtnl, req, set_mtu_handler, link,
-                               0, NULL);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not send rtnetlink message: %s",
-                               strerror(-r));
-                return r;
-        }
+        r = sd_rtnl_call_async(link->manager->rtnl, req, set_mtu_handler, link, 0, NULL);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
 
         link_ref(link);
 
@@ -885,53 +846,31 @@ static int link_set_bridge(Link *link) {
         if(link->network->cost == 0)
                 return 0;
 
-        r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
-                                     RTM_SETLINK, link->ifindex);
-        if (r < 0) {
-                log_link_error(link, "Could not allocate RTM_SETLINK message");
-                return r;
-        }
+        r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
 
         r = sd_rtnl_message_link_set_family(req, PF_BRIDGE);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not set message family %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not set message family: %m");
 
         r = sd_rtnl_message_open_container(req, IFLA_PROTINFO);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not append IFLA_PROTINFO attribute: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not append IFLA_PROTINFO attribute: %m");
 
         if(link->network->cost != 0) {
                 r = sd_rtnl_message_append_u32(req, IFLA_BRPORT_COST, link->network->cost);
-                if (r < 0) {
-                        log_link_error(link,
-                                       "Could not append IFLA_BRPORT_COST attribute: %s",
-                                       strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_COST attribute: %m");
         }
 
         r = sd_rtnl_message_close_container(req);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not append IFLA_LINKINFO attribute: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not append IFLA_LINKINFO attribute: %m");
 
         r = sd_rtnl_call_async(link->manager->rtnl, req, link_set_handler, link, 0, NULL);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not send rtnetlink message: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
 
         link_ref(link);
 
@@ -951,7 +890,7 @@ static void lldp_handler(sd_lldp *lldp, int event, void *userdata) {
 
         r = sd_lldp_save(link->lldp, link->lldp_file);
         if (r < 0)
-                log_link_warning(link, "could not save LLDP");
+                log_link_warning_errno(link, r, "Could not save LLDP: %m");
 
 }
 
@@ -966,40 +905,31 @@ static int link_acquire_conf(Link *link) {
         if (link_ipv4ll_enabled(link)) {
                 assert(link->ipv4ll);
 
-                log_link_debug(link, "acquiring IPv4 link-local address");
+                log_link_debug(link, "Acquiring IPv4 link-local address");
 
                 r = sd_ipv4ll_start(link->ipv4ll);
-                if (r < 0) {
-                        log_link_warning(link, "could not acquire IPv4 "
-                                         "link-local address");
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
         }
 
         if (link_dhcp4_enabled(link)) {
                 assert(link->dhcp_client);
 
-                log_link_debug(link, "acquiring DHCPv4 lease");
+                log_link_debug(link, "Acquiring DHCPv4 lease");
 
                 r = sd_dhcp_client_start(link->dhcp_client);
-                if (r < 0) {
-                        log_link_warning(link, "could not acquire DHCPv4 "
-                                         "lease");
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "Could not acquire DHCPv4 lease: %m");
         }
 
         if (link_dhcp6_enabled(link)) {
                 assert(link->icmp6_router_discovery);
 
-                log_link_debug(link, "discovering IPv6 routers");
+                log_link_debug(link, "Discovering IPv6 routers");
 
                 r = sd_icmp6_router_solicitation_start(link->icmp6_router_discovery);
-                if (r < 0) {
-                        log_link_warning(link,
-                                         "could not start IPv6 router discovery");
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "Could not start IPv6 router discovery: %m");
         }
 
         if (link_lldp_enabled(link)) {
@@ -1008,10 +938,8 @@ static int link_acquire_conf(Link *link) {
                 log_link_debug(link, "Starting LLDP");
 
                 r = sd_lldp_start(link->lldp);
-                if (r < 0) {
-                        log_link_warning(link, "could not start LLDP ");
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "Could not start LLDP: %m");
         }
 
         return 0;
@@ -1041,11 +969,10 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
                 return 1;
 
         r = sd_rtnl_message_get_errno(m);
-        if (r < 0) {
-                /* we warn but don't fail the link, as it may
-                   be brought up later */
-                log_link_warning_errno(link, -r, "%-*s: could not bring up interface: %m", IFNAMSIZ, link->ifname);
-        }
+        if (r < 0)
+                /* we warn but don't fail the link, as it may be
+                   brought up later */
+                log_link_warning_errno(link, r, "%-*s: could not bring up interface: %m", IFNAMSIZ, link->ifname);
 
         return 1;
 }
@@ -1060,85 +987,58 @@ static int link_up(Link *link) {
         assert(link->manager);
         assert(link->manager->rtnl);
 
-        log_link_debug(link, "bringing link up");
+        log_link_debug(link, "Bringing link up");
 
-        r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
-                                     RTM_SETLINK, link->ifindex);
-        if (r < 0) {
-                log_link_error(link, "Could not allocate RTM_SETLINK message");
-                return r;
-        }
+        r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
 
         r = sd_rtnl_message_link_set_flags(req, IFF_UP, IFF_UP);
-        if (r < 0) {
-                log_link_error(link, "Could not set link flags: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not set link flags: %m");
 
         if (link->network->mac) {
                 r = sd_rtnl_message_append_ether_addr(req, IFLA_ADDRESS, link->network->mac);
-                if (r < 0) {
-                        log_link_error(link, "Could not set MAC address: %s", strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not set MAC address: %m");
         }
 
         if (link->network->mtu) {
                 r = sd_rtnl_message_append_u32(req, IFLA_MTU, link->network->mtu);
-                if (r < 0) {
-                        log_link_error(link, "Could not set MTU: %s", strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not set MTU: %m");
         }
 
         r = sd_rtnl_message_open_container(req, IFLA_AF_SPEC);
-        if (r < 0) {
-                log_link_error(link, "Could not open IFLA_AF_SPEC container: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m");
 
         r = sd_rtnl_message_open_container(req, AF_INET6);
-        if (r < 0) {
-                log_link_error(link, "Could not open AF_INET6 container: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not open AF_INET6 container: %m");
 
         ipv6ll_mode = link_ipv6ll_enabled(link) ? IN6_ADDR_GEN_MODE_EUI64 : IN6_ADDR_GEN_MODE_NONE;
         r = sd_rtnl_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode);
-        if (r < 0) {
-                log_link_error(link, "Could not append IFLA_INET6_ADDR_GEN_MODE: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m");
 
         if (!in_addr_is_null(AF_INET6, &link->network->ipv6_token)) {
                 r = sd_rtnl_message_append_in6_addr(req, IFLA_INET6_TOKEN, &link->network->ipv6_token.in6);
-                if (r < 0) {
-                        log_link_error(link, "Could not append IFLA_INET6_TOKEN: %s", strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m");
         }
 
         r = sd_rtnl_message_close_container(req);
-        if (r < 0) {
-                log_link_error(link, "Could not close AF_INET6 container: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m");
 
         r = sd_rtnl_message_close_container(req);
-        if (r < 0) {
-                log_link_error(link, "Could not close IFLA_AF_SPEC container: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m");
 
-        r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link,
-                               0, NULL);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not send rtnetlink message: %s",
-                               strerror(-r));
-                return r;
-        }
+        r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link, 0, NULL);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
 
         link_ref(link);
 
@@ -1156,7 +1056,7 @@ static int link_down_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0)
-                log_link_warning_errno(link, -r, "%-*s: could not bring down interface: %m", IFNAMSIZ, link->ifname);
+                log_link_warning_errno(link, r, "%-*s: could not bring down interface: %m", IFNAMSIZ, link->ifname);
 
         return 1;
 }
@@ -1169,30 +1069,20 @@ static int link_down(Link *link) {
         assert(link->manager);
         assert(link->manager->rtnl);
 
-        log_link_debug(link, "bringing link down");
+        log_link_debug(link, "Bringing link down");
 
         r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
                                      RTM_SETLINK, link->ifindex);
-        if (r < 0) {
-                log_link_error(link, "Could not allocate RTM_SETLINK message");
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
 
         r = sd_rtnl_message_link_set_flags(req, 0, IFF_UP);
-        if (r < 0) {
-                log_link_error(link, "Could not set link flags: %s",
-                               strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not set link flags: %m");
 
-        r = sd_rtnl_call_async(link->manager->rtnl, req, link_down_handler, link,
-                               0, NULL);
-        if (r < 0) {
-                log_link_error(link,
-                               "Could not send rtnetlink message: %s",
-                               strerror(-r));
-                return r;
-        }
+        r = sd_rtnl_call_async(link->manager->rtnl, req, link_down_handler, link,  0, NULL);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
 
         link_ref(link);
 
@@ -1440,7 +1330,7 @@ void link_drop(Link *link) {
 
         link_free_carrier_maps(link);
 
-        log_link_debug(link, "link removed");
+        log_link_debug(link, "Link removed");
 
         link_unref(link);
 
@@ -1467,11 +1357,8 @@ static int link_joined(Link *link) {
 
         if(link->network->bridge) {
                 r = link_set_bridge(link);
-                if (r < 0) {
-                        log_link_error(link,
-                                       "Could not set bridge message: %s",
-                                       strerror(-r));
-                }
+                if (r < 0)
+                        log_link_error_errno(link, r, "Could not set bridge message: %m");
         }
 
         return link_enter_set_addresses(link);
@@ -1492,11 +1379,11 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
 
         r = sd_rtnl_message_get_errno(m);
         if (r < 0 && r != -EEXIST) {
-                log_link_error_errno(link, -r, "%-*s: could not join netdev: %m", IFNAMSIZ, link->ifname);
+                log_link_error_errno(link, r, "%-*s: could not join netdev: %m", IFNAMSIZ, link->ifname);
                 link_enter_failed(link);
                 return 1;
         } else
-                log_link_debug(link, "joined netdev");
+                log_link_debug(link, "Joined netdev");
 
         if (link->enslaving <= 0)
                 link_joined(link);
@@ -1525,8 +1412,8 @@ static int link_enter_join_netdev(Link *link) {
         if (link->network->bond) {
                 log_link_struct(link, LOG_DEBUG,
                                 "MESSAGE=%-*s: enslaving by '%s'",
-                                IFNAMSIZ,
-                                link->ifname, link->network->bond->ifname,
+                                IFNAMSIZ, link->ifname,
+                                link->network->bond->ifname,
                                 NETDEVIF(link->network->bond),
                                 NULL);
 
@@ -1534,8 +1421,8 @@ static int link_enter_join_netdev(Link *link) {
                 if (r < 0) {
                         log_link_struct(link, LOG_WARNING,
                                         "MESSAGE=%-*s: could not join netdev '%s': %s",
-                                        IFNAMSIZ,
-                                        link->ifname, link->network->bond->ifname,
+                                        IFNAMSIZ, link->ifname,
+                                        link->network->bond->ifname,
                                         strerror(-r),
                                         NETDEVIF(link->network->bond),
                                         NULL);
@@ -1549,8 +1436,8 @@ static int link_enter_join_netdev(Link *link) {
         if (link->network->bridge) {
                 log_link_struct(link, LOG_DEBUG,
                                 "MESSAGE=%-*s: enslaving by '%s'",
-                                IFNAMSIZ,
-                                link->ifname, link->network->bridge->ifname,
+                                IFNAMSIZ, link->ifname,
+                                link->network->bridge->ifname,
                                 NETDEVIF(link->network->bridge),
                                 NULL);
 
@@ -1559,8 +1446,8 @@ static int link_enter_join_netdev(Link *link) {
                 if (r < 0) {
                         log_link_struct(link, LOG_WARNING,
                                         "MESSAGE=%-*s: could not join netdev '%s': %s",
-                                        IFNAMSIZ,
-                                        link->ifname, link->network->bridge->ifname,
+                                        IFNAMSIZ, link->ifname,
+                                        link->network->bridge->ifname,
                                         strerror(-r),
                                         NETDEVIF(link->network->bridge),
                                         NULL);
@@ -1574,16 +1461,16 @@ static int link_enter_join_netdev(Link *link) {
         HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) {
                 log_link_struct(link, LOG_DEBUG,
                                 "MESSAGE=%-*s: enslaving by '%s'",
-                                IFNAMSIZ,
-                                link->ifname, netdev->ifname, NETDEVIF(netdev),
+                                IFNAMSIZ, link->ifname,
+                                netdev->ifname, NETDEVIF(netdev),
                                 NULL);
 
                 r = netdev_join(netdev, link, &netdev_join_handler);
                 if (r < 0) {
                         log_link_struct(link, LOG_WARNING,
                                         "MESSAGE=%-*s: could not join netdev '%s': %s",
-                                        IFNAMSIZ,
-                                        link->ifname, netdev->ifname,
+                                        IFNAMSIZ, link->ifname,
+                                        netdev->ifname,
                                         strerror(-r),
                                         NETDEVIF(netdev), NULL);
                         link_enter_failed(link);
@@ -1730,7 +1617,7 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
         if (link->state != LINK_STATE_PENDING)
                 return 1;
 
-        log_link_debug(link, "link state is up-to-date");
+        log_link_debug(link, "Link state is up-to-date");
 
         r = link_new_bound_by_list(link);
         if (r < 0)
@@ -1750,13 +1637,13 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
 
         if (link->flags & IFF_LOOPBACK) {
                 if (network->link_local != ADDRESS_FAMILY_NO)
-                        log_link_debug(link, "ignoring link-local autoconfiguration for loopback link");
+                        log_link_debug(link, "Ignoring link-local autoconfiguration for loopback link");
 
                 if (network->dhcp != ADDRESS_FAMILY_NO)
-                        log_link_debug(link, "ignoring DHCP clients for loopback link");
+                        log_link_debug(link, "Ignoring DHCP clients for loopback link");
 
                 if (network->dhcp_server)
-                        log_link_debug(link, "ignoring DHCP server for loopback link");
+                        log_link_debug(link, "Ignoring DHCP server for loopback link");
         }
 
         r = network_apply(link->manager, network, link);
@@ -1851,7 +1738,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
 
         r = sd_rtnl_message_get_type(message, &type);
         if (r < 0) {
-                log_warning("rtnl: could not get message type");
+                log_warning_errno(r, "rtnl: could not get message type: %m");
                 return 0;
         } else if (type != RTM_NEWADDR && type != RTM_DELADDR) {
                 log_warning("rtnl: received unexpected message type when processing address");
@@ -1882,25 +1769,25 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
 
         r = sd_rtnl_message_addr_get_family(message, &address->family);
         if (r < 0 || !IN_SET(address->family, AF_INET, AF_INET6)) {
-                log_link_warning(link, "rtnl: received address with invalid family, ignoring");
+                log_link_warning(link, "rtnl: received address with invalid family, ignoring.");
                 return 0;
         }
 
         r = sd_rtnl_message_addr_get_prefixlen(message, &address->prefixlen);
         if (r < 0) {
-                log_link_warning(link, "rtnl: received address with invalid prefixlen, ignoring");
+                log_link_warning_errno(link, r, "rtnl: received address with invalid prefixlen, ignoring: %m");
                 return 0;
         }
 
         r = sd_rtnl_message_addr_get_scope(message, &address->scope);
         if (r < 0) {
-                log_link_warning(link, "rtnl: received address with invalid scope, ignoring");
+                log_link_warning_errno(link, r, "rtnl: received address with invalid scope, ignoring: %m");
                 return 0;
         }
 
         r = sd_rtnl_message_addr_get_flags(message, &flags);
         if (r < 0) {
-                log_link_warning(link, "rtnl: received address with invalid flags, ignoring");
+                log_link_warning_errno(link, r, "rtnl: received address with invalid flags, ignoring: %m");
                 return 0;
         }
         address->flags = flags;
@@ -1909,7 +1796,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         case AF_INET:
                 r = sd_rtnl_message_read_in_addr(message, IFA_LOCAL, &address->in_addr.in);
                 if (r < 0) {
-                        log_link_warning(link, "rtnl: received address without valid address, ignoring");
+                        log_link_warning_errno(link, r, "rtnl: received address without valid address, ignoring: %m");
                         return 0;
                 }
 
@@ -1918,7 +1805,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         case AF_INET6:
                 r = sd_rtnl_message_read_in6_addr(message, IFA_ADDRESS, &address->in_addr.in6);
                 if (r < 0) {
-                        log_link_warning(link, "rtnl: received address without valid address, ignoring");
+                        log_link_warning_errno(link, r, "rtnl: received address without valid address, ignoring: %m");
                         return 0;
                 }
 
@@ -1929,7 +1816,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
         }
 
         if (!inet_ntop(address->family, &address->in_addr, buf, INET6_ADDRSTRLEN)) {
-                log_link_warning(link, "could not print address");
+                log_link_warning(link, "Could not print address");
                 return 0;
         }
 
@@ -2003,17 +1890,14 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
 
         link = *ret;
 
-        log_link_debug(link, "link %d added", link->ifindex);
+        log_link_debug(link, "Link %d added", link->ifindex);
 
         if (detect_container(NULL) <= 0) {
                 /* not in a container, udev will be around */
                 sprintf(ifindex_str, "n%d", link->ifindex);
                 device = udev_device_new_from_device_id(m->udev, ifindex_str);
-                if (!device) {
-                        log_link_warning(link,
-                                         "could not find udev device: %m");
-                        return -errno;
-                }
+                if (!device)
+                        return log_link_warning_errno(link, errno, "Could not find udev device: %m");
 
                 if (udev_device_get_is_initialized(device) <= 0) {
                         /* not yet ready */
@@ -2088,7 +1972,7 @@ int link_carrier_reset(Link *link) {
                 if (r < 0)
                         return r;
 
-                log_link_info(link, "reset carrier");
+                log_link_info(link, "Reset carrier");
         }
 
         return 0;
@@ -2108,7 +1992,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
 
         if (link->state == LINK_STATE_LINGER) {
                 link_ref(link);
-                log_link_info(link, "link readded");
+                log_link_info(link, "Link readded");
                 link_set_state(link, LINK_STATE_ENSLAVING);
 
                 r = link_new_carrier_maps(link);
@@ -2118,7 +2002,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
 
         r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
         if (r >= 0 && !streq(ifname, link->ifname)) {
-                log_link_info(link, "renamed to %s", ifname);
+                log_link_info(link, "Renamed to %s", ifname);
 
                 link_free_carrier_maps(link);
 
@@ -2137,17 +2021,14 @@ int link_update(Link *link, sd_rtnl_message *m) {
                 link->mtu = mtu;
                 if (!link->original_mtu) {
                         link->original_mtu = mtu;
-                        log_link_debug(link, "saved original MTU: %"
-                                       PRIu32, link->original_mtu);
+                        log_link_debug(link, "Saved original MTU: %" PRIu32, link->original_mtu);
                 }
 
                 if (link->dhcp_client) {
                         r = sd_dhcp_client_set_mtu(link->dhcp_client,
                                                    link->mtu);
                         if (r < 0) {
-                                log_link_warning(link,
-                                                 "Could not update MTU in DHCP client: %s",
-                                                 strerror(-r));
+                                log_link_warning_errno(link, r, "Could not update MTU in DHCP client: %m");
                                 return r;
                         }
                 }
@@ -2174,12 +2055,8 @@ int link_update(Link *link, sd_rtnl_message *m) {
 
                         if (link->ipv4ll) {
                                 r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac);
-                                if (r < 0) {
-                                        log_link_warning(link,
-                                                         "Could not update MAC address in IPv4LL client: %s",
-                                                         strerror(-r));
-                                        return r;
-                                }
+                                if (r < 0)
+                                        return log_link_warning_errno(link, r, "Could not update MAC address in IPv4LL client: %m");
                         }
 
                         if (link->dhcp_client) {
@@ -2187,12 +2064,8 @@ int link_update(Link *link, sd_rtnl_message *m) {
                                                            (const uint8_t *) &link->mac,
                                                            sizeof (link->mac),
                                                            ARPHRD_ETHER);
-                                if (r < 0) {
-                                        log_link_warning(link,
-                                                         "Could not update MAC address in DHCP client: %s",
-                                                         strerror(-r));
-                                        return r;
-                                }
+                                if (r < 0)
+                                        return log_link_warning_errno(link, r, "Could not update MAC address in DHCP client: %m");
                         }
 
                         if (link->dhcp6_client) {
@@ -2200,12 +2073,8 @@ int link_update(Link *link, sd_rtnl_message *m) {
                                                             (const uint8_t *) &link->mac,
                                                             sizeof (link->mac),
                                                             ARPHRD_ETHER);
-                                if (r < 0) {
-                                        log_link_warning(link,
-                                                         "Could not update MAC address in DHCPv6 client: %s",
-                                                         strerror(-r));
-                                        return r;
-                                }
+                                if (r < 0)
+                                        return log_link_warning_errno(link, r, "Could not update MAC address in DHCPv6 client: %m");
                         }
                 }
         }
@@ -2220,13 +2089,13 @@ int link_update(Link *link, sd_rtnl_message *m) {
         carrier_lost = had_carrier && !link_has_carrier(link);
 
         if (carrier_gained) {
-                log_link_info(link, "gained carrier");
+                log_link_info(link, "Gained carrier");
 
                 r = link_carrier_gained(link);
                 if (r < 0)
                         return r;
         } else if (carrier_lost) {
-                log_link_info(link, "lost carrier");
+                log_link_info(link, "Lost carrier");
 
                 r = link_carrier_lost(link);
                 if (r < 0)
@@ -2306,7 +2175,7 @@ int link_save(Link *link) {
 
         r = fopen_temporary(link->state_file, &f, &temp_path);
         if (r < 0)
-                return r;
+                goto fail;
 
         fchmod(fileno(f), 0644);
 
@@ -2467,9 +2336,12 @@ int link_save(Link *link) {
 
         return 0;
 fail:
-        log_link_error(link, "Failed to save link data to %s: %s", link->state_file, strerror(-r));
-        unlink(link->state_file);
-        unlink(temp_path);
+        log_link_error_errno(link, r, "Failed to save link data to %s: %m", link->state_file);
+        (void) unlink(link->state_file);
+
+        if (temp_path)
+                (void) unlink(temp_path);
+
         return r;
 }
 
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 8456bf5..78f7c40 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -190,34 +190,21 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
         assert(link);
         assert(callback);
 
-        r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req,
-                                     RTM_SETLINK, link->ifindex);
-        if (r < 0) {
-                log_netdev_error(netdev,
-                                 "Could not allocate RTM_SETLINK message: %s",
-                                 strerror(-r));
-                return r;
-        }
+        r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not allocate RTM_SETLINK message: %m");
 
         r = sd_rtnl_message_append_u32(req, IFLA_MASTER, netdev->ifindex);
-        if (r < 0) {
-                log_netdev_error(netdev,
-                                 "Could not append IFLA_MASTER attribute: %s",
-                                 strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not append IFLA_MASTER attribute: %m");
 
         r = sd_rtnl_call_async(netdev->manager->rtnl, req, callback, link, 0, NULL);
-        if (r < 0) {
-                log_netdev_error(netdev,
-                                 "Could not send rtnetlink message: %s",
-                                 strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error(netdev, "Could not send rtnetlink message: %m");
 
         link_ref(link);
 
-        log_netdev_debug(netdev, "enslaving link '%s'", link->ifname);
+        log_netdev_debug(netdev, "Enslaving link '%s'", link->ifname);
 
         return 0;
 }
@@ -262,13 +249,13 @@ static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda
         if (r == -EEXIST)
                 log_netdev_info(netdev, "netdev exists, using existing without changing its parameters");
         else if (r < 0) {
-                log_netdev_warning(netdev, "netdev could not be created: %s", strerror(-r));
+                log_netdev_warning_errno(netdev, r, "netdev could not be created: %m");
                 netdev_drop(netdev);
 
                 return 1;
         }
 
-        log_netdev_debug(netdev, "created");
+        log_netdev_debug(netdev, "Created");
 
         return 1;
 }
@@ -297,8 +284,7 @@ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callbac
 
                 LIST_PREPEND(callbacks, netdev->callbacks, cb);
 
-                log_netdev_debug(netdev, "will enslave '%s', when reday",
-                                 link->ifname);
+                log_netdev_debug(netdev, "Will enslave '%s', when ready", link->ifname);
         }
 
         return 0;
@@ -315,25 +301,23 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
         assert(message);
 
         r = sd_rtnl_message_get_type(message, &type);
-        if (r < 0) {
-                log_netdev_error(netdev, "Could not get rtnl message type");
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not get rtnl message type: %m");
 
         if (type != RTM_NEWLINK) {
-                log_netdev_error(netdev, "Can not set ifindex from unexpected rtnl message type");
+                log_netdev_error(netdev, "Cannot set ifindex from unexpected rtnl message type.");
                 return -EINVAL;
         }
 
         r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
         if (r < 0) {
-                log_netdev_error(netdev, "Could not get ifindex: %s", strerror(-r));
+                log_netdev_error_errno(netdev, r, "Could not get ifindex: %m");
                 netdev_enter_failed(netdev);
                 return r;
         } else if (ifindex <= 0) {
                 log_netdev_error(netdev, "Got invalid ifindex: %d", ifindex);
                 netdev_enter_failed(netdev);
-                return r;
+                return -EINVAL;
         }
 
         if (netdev->ifindex > 0) {
@@ -348,35 +332,26 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
         }
 
         r = sd_rtnl_message_read_string(message, IFLA_IFNAME, &received_name);
-        if (r < 0) {
-                log_netdev_error(netdev, "Could not get IFNAME");
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not get IFNAME: %m");
 
         if (!streq(netdev->ifname, received_name)) {
-                log_netdev_error(netdev, "Received newlink with wrong IFNAME %s",
-                                 received_name);
+                log_netdev_error(netdev, "Received newlink with wrong IFNAME %s", received_name);
                 netdev_enter_failed(netdev);
                 return r;
         }
 
         r = sd_rtnl_message_enter_container(message, IFLA_LINKINFO);
-        if (r < 0) {
-                log_netdev_error(netdev, "Could not get LINKINFO");
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not get LINKINFO: %m");
 
         r = sd_rtnl_message_read_string(message, IFLA_INFO_KIND, &received_kind);
-        if (r < 0) {
-                log_netdev_error(netdev, "Could not get KIND");
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not get KIND: %m");
 
         r = sd_rtnl_message_exit_container(message);
-        if (r < 0) {
-                log_netdev_error(netdev, "Could not exit container");
-                return r;
-        }
+        if (r < 0)
+                return log_netdev_error_errno(netdev, r, "Could not exit container: %m");
 
         if (netdev->kind == NETDEV_KIND_TAP)
                 /* the kernel does not distinguish between tun and tap */
@@ -468,72 +443,43 @@ static int netdev_create(NetDev *netdev, Link *link,
                 if (r < 0)
                         return r;
 
-                log_netdev_debug(netdev, "created");
+                log_netdev_debug(netdev, "Created");
         } else {
                 _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
 
                 r = sd_rtnl_message_new_link(netdev->manager->rtnl, &m, RTM_NEWLINK, 0);
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not allocate RTM_NEWLINK message: %s",
-                                         strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not allocate RTM_NEWLINK message: %m");
 
                 r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not append IFLA_IFNAME, attribute: %s",
-                                         strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_IFNAME, attribute: %m");
 
                 if (netdev->mac) {
                         r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
-                        if (r < 0) {
-                                log_netdev_error(netdev,
-                                                 "Could not append IFLA_ADDRESS attribute: %s",
-                                                 strerror(-r));
-                            return r;
-                        }
+                        if (r < 0)
+                                return log_netdev_error_errno(netdev, r, "Could not append IFLA_ADDRESS attribute: %m");
                 }
 
                 if (netdev->mtu) {
                         r = sd_rtnl_message_append_u32(m, IFLA_MTU, netdev->mtu);
-                        if (r < 0) {
-                                log_netdev_error(netdev,
-                                                 "Could not append IFLA_MTU attribute: %s",
-                                                 strerror(-r));
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_netdev_error_errno(netdev, r, "Could not append IFLA_MTU attribute: %m");
                 }
 
                 if (link) {
                         r = sd_rtnl_message_append_u32(m, IFLA_LINK, link->ifindex);
-                        if (r < 0) {
-                                log_netdev_error(netdev,
-                                                 "Could not append IFLA_LINK attribute: %s",
-                                                 strerror(-r));
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINK attribute: %m");
                 }
 
                 r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not append IFLA_LINKINFO attribute: %s",
-                                         strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m");
 
-                r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA,
-                                                         netdev_kind_to_string(netdev->kind));
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not append IFLA_INFO_DATA attribute: %s",
-                                         strerror(-r));
-                        return r;
-                }
+                r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, netdev_kind_to_string(netdev->kind));
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m");
 
                 if (NETDEV_VTABLE(netdev)->fill_message_create) {
                         r = NETDEV_VTABLE(netdev)->fill_message_create(netdev, link, m);
@@ -542,50 +488,30 @@ static int netdev_create(NetDev *netdev, Link *link,
                 }
 
                 r = sd_rtnl_message_close_container(m);
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not append IFLA_LINKINFO attribute: %s",
-                                         strerror(-r));
-                        return r;
-                }
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m");
 
                 r = sd_rtnl_message_close_container(m);
-                if (r < 0) {
-                        log_netdev_error(netdev,
-                                         "Could not append IFLA_LINKINFO attribute: %s",
-                                         strerror(-r));
-                        return r;
-                }
-
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m");
 
                 if (link) {
-                        r = sd_rtnl_call_async(netdev->manager->rtnl, m,
-                                               callback, link, 0, NULL);
-                        if (r < 0) {
-                                log_netdev_error(netdev,
-                                                 "Could not send rtnetlink message: %s",
-                                                 strerror(-r));
-                                return r;
-                        }
+                        r = sd_rtnl_call_async(netdev->manager->rtnl, m, callback, link, 0, NULL);
+                        if (r < 0)
+                                return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
 
                         link_ref(link);
                 } else {
-                        r = sd_rtnl_call_async(netdev->manager->rtnl, m,
-                                               netdev_create_handler, netdev, 0,
-                                               NULL);
-                        if (r < 0) {
-                                log_netdev_error(netdev,
-                                                 "Could not send rtnetlink message: %s",
-                                                 strerror(-r));
-                                return r;
-                        }
+                        r = sd_rtnl_call_async(netdev->manager->rtnl, m, netdev_create_handler, netdev, 0, NULL);
+                        if (r < 0)
+                                return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
 
                         netdev_ref(netdev);
                 }
 
                 netdev->state = NETDEV_STATE_CREATING;
 
-                log_netdev_debug(netdev, "creating");
+                log_netdev_debug(netdev, "Creating");
         }
 
         return 0;
@@ -709,11 +635,8 @@ static int netdev_load_one(Manager *manager, const char *filename) {
 
         if (!netdev->mac) {
                 r = netdev_get_mac(netdev->ifname, &netdev->mac);
-                if (r < 0) {
-                        log_error("Failed to generate predictable MAC address for %s",
-                                  netdev->ifname);
-                        return r;
-                }
+                if (r < 0)
+                        return log_error_errno(r, "Failed to generate predictable MAC address for %s: %m", netdev->ifname);
         }
 
         r = hashmap_put(netdev->manager->netdevs, netdev->ifname, netdev);
@@ -742,8 +665,9 @@ static int netdev_load_one(Manager *manager, const char *filename) {
 }
 
 int netdev_load(Manager *manager) {
+        _cleanup_strv_free_ char **files = NULL;
         NetDev *netdev;
-        char **files, **f;
+        char **f;
         int r;
 
         assert(manager);
@@ -761,7 +685,5 @@ int netdev_load(Manager *manager) {
                         return r;
         }
 
-        strv_free(files);
-
         return 0;
 }
diff --git a/src/network/networkd-netdev.h b/src/network/networkd-netdev.h
index 5f5fcfb..ff06067 100644
--- a/src/network/networkd-netdev.h
+++ b/src/network/networkd-netdev.h
@@ -200,12 +200,20 @@ const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsign
 
 /* Macros which append INTERFACE= to the message */
 
-#define log_netdev_full(level, netdev, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
-#define log_netdev_debug(netdev, ...)       log_netdev_full(LOG_DEBUG, netdev, ##__VA_ARGS__)
-#define log_netdev_info(netdev, ...)        log_netdev_full(LOG_INFO, netdev, ##__VA_ARGS__)
-#define log_netdev_notice(netdev, ...)      log_netdev_full(LOG_NOTICE, netdev, ##__VA_ARGS__)
-#define log_netdev_warning(netdev, ...)     log_netdev_full(LOG_WARNING, netdev,## __VA_ARGS__)
-#define log_netdev_error(netdev, ...)       log_netdev_full(LOG_ERR, netdev, ##__VA_ARGS__)
+#define log_netdev_full(netdev, level, error, fmt, ...)                  \
+        log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
+
+#define log_netdev_debug(netdev, ...)       log_netdev_full(netdev, LOG_DEBUG, 0, ##__VA_ARGS__)
+#define log_netdev_info(netdev, ...)        log_netdev_full(netdev, LOG_INFO, 0, ##__VA_ARGS__)
+#define log_netdev_notice(netdev, ...)      log_netdev_full(netdev, LOG_NOTICE, 0, ##__VA_ARGS__)
+#define log_netdev_warning(netdev, ...)     log_netdev_full(netdev, LOG_WARNING, 0, ## __VA_ARGS__)
+#define log_netdev_error(netdev, ...)       log_netdev_full(netdev, LOG_ERR, 0, ##__VA_ARGS__)
+
+#define log_netdev_debug_errno(netdev, error, ...)   log_netdev_full(netdev, LOG_DEBUG, error, ##__VA_ARGS__)
+#define log_netdev_info_errno(netdev, error, ...)    log_netdev_full(netdev, LOG_INFO, error, ##__VA_ARGS__)
+#define log_netdev_notice_errno(netdev, error, ...)  log_netdev_full(netdev, LOG_NOTICE, error, ##__VA_ARGS__)
+#define log_netdev_warning_errno(netdev, error, ...) log_netdev_full(netdev, LOG_WARNING, error, ##__VA_ARGS__)
+#define log_netdev_error_errno(netdev, error, ...)   log_netdev_full(netdev, LOG_ERR, error, ##__VA_ARGS__)
 
 #define log_netdev_struct(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__)
 
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 78bbf74..64c1b9c 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -425,8 +425,8 @@ int config_parse_netdev(const char *unit,
                 r = hashmap_put(network->stacked_netdevs, netdev->ifname, netdev);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                                   "Can not add VLAN '%s' to network: %s",
-                                   rvalue, strerror(-r));
+                                   "Can not add VLAN '%s' to network: %m",
+                                   rvalue);
                         return 0;
                 }
 
@@ -502,8 +502,7 @@ int config_parse_tunnel(const char *unit,
 
         r = netdev_get(network->manager, rvalue, &netdev);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Tunnel is invalid, ignoring assignment: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, r, "Tunnel is invalid, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
@@ -523,9 +522,7 @@ int config_parse_tunnel(const char *unit,
 
         r = hashmap_put(network->stacked_netdevs, netdev->ifname, netdev);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Can not add VLAN '%s' to network: %s",
-                           rvalue, strerror(-r));
+                log_syntax(unit, LOG_ERR, filename, line, r, "Cannot add VLAN '%s' to network, ignoring: %m", rvalue);
                 return 0;
         }
 
@@ -694,13 +691,13 @@ int config_parse_ipv6token(
 
         r = in_addr_from_string(AF_INET6, rvalue, &buffer);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse IPv6 token, ignoring: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IPv6 token, ignoring: %s", rvalue);
                 return 0;
         }
 
         r = in_addr_is_null(AF_INET6, &buffer);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, -r, "IPv6 token can not be the ANY address, ignoring: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, r, "IPv6 token can not be the ANY address, ignoring: %s", rvalue);
                 return 0;
         }
 
diff --git a/src/network/networkd.h b/src/network/networkd.h
index c26d64e..4b13d4a 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -448,7 +448,7 @@ AddressFamilyBoolean address_family_boolean_from_string(const char *s) _const_;
 
 int config_parse_address_family_boolean(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
-/* Opeartional State */
+/* Operational State */
 
 const char* link_operstate_to_string(LinkOperationalState s) _const_;
 LinkOperationalState link_operstate_from_string(const char *s) _pure_;

commit fed2b07ebc9e8694b5b326923356028f464381ce
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 17:28:16 2015 +0200

    tmpfiles: make /home and /var btrfs subvolumes by default when booted up with them missing
    
    This way the root subvolume can be left read-only easily, and variable
    and user data writable with explicit quota set.

diff --git a/Makefile.am b/Makefile.am
index 68d8252..8b16314 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2244,7 +2244,8 @@ dist_tmpfiles_DATA = \
 	tmpfiles.d/systemd-nologin.conf \
 	tmpfiles.d/tmp.conf \
 	tmpfiles.d/x11.conf \
-	tmpfiles.d/var.conf
+	tmpfiles.d/var.conf \
+	tmpfiles.d/home.conf
 
 if HAVE_SYSV_COMPAT
 dist_tmpfiles_DATA += \
diff --git a/tmpfiles.d/home.conf b/tmpfiles.d/home.conf
new file mode 100644
index 0000000..aa652b1
--- /dev/null
+++ b/tmpfiles.d/home.conf
@@ -0,0 +1,11 @@
+#  This file is part of systemd.
+#
+#  systemd 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.1 of the License, or
+#  (at your option) any later version.
+
+# See tmpfiles.d(5) for details
+
+v /home 0755 - - -
+v /srv 0755 - - -
diff --git a/tmpfiles.d/var.conf b/tmpfiles.d/var.conf
index 9b76444..814652a 100644
--- a/tmpfiles.d/var.conf
+++ b/tmpfiles.d/var.conf
@@ -7,7 +7,7 @@
 
 # See tmpfiles.d(5) for details
 
-d /var 0755 - - -
+v /var 0755 - - -
 
 L /var/run - - - - ../run
 

commit 451d691ae110a600497348d9f6288bc84efb8642
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 17:26:56 2015 +0200

    tmpfiles: there's no systemd-forbid-user-logins.service service

diff --git a/tmpfiles.d/systemd-nologin.conf b/tmpfiles.d/systemd-nologin.conf
index d61232b..a30a8da 100644
--- a/tmpfiles.d/systemd-nologin.conf
+++ b/tmpfiles.d/systemd-nologin.conf
@@ -5,7 +5,7 @@
 #  the Free Software Foundation; either version 2.1 of the License, or
 #  (at your option) any later version.
 
-# See tmpfiles.d(5) and systemd-forbid-user-logins.service(5).
+# See tmpfiles.d(5), systemd-user-session.service(5) and pam_nologin(8).
 # This file has special suffix so it is not run by mistake.
 
 F! /run/nologin 0644 - - - "System is booting up. See pam_nologin(8)"

commit 158350e86923cb1d878d3bf7d928fb1c30a3da76
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 17:26:04 2015 +0200

    log: move log_syntax() into src/shared/log.c, and make it more similar to the other log functions

diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index aa6a4a6..2c85515 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -34,50 +34,6 @@
 #include "path-util.h"
 #include "sd-messages.h"
 
-int log_syntax_internal(
-                const char *unit,
-                int level,
-                const char *file,
-                int line,
-                const char *func,
-                const char *config_file,
-                unsigned config_line,
-                int error,
-                const char *format, ...) {
-
-        _cleanup_free_ char *msg = NULL;
-        int r;
-        va_list ap;
-
-        va_start(ap, format);
-        r = vasprintf(&msg, format, ap);
-        va_end(ap);
-        if (r < 0)
-                return log_oom();
-
-        if (unit)
-                r = log_struct_internal(level,
-                                        error,
-                                        file, line, func,
-                                        getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit,
-                                        LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
-                                        "CONFIG_FILE=%s", config_file,
-                                        "CONFIG_LINE=%u", config_line,
-                                        LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg),
-                                        NULL);
-        else
-                r = log_struct_internal(level,
-                                        error,
-                                        file, line, func,
-                                        LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
-                                        "CONFIG_FILE=%s", config_file,
-                                        "CONFIG_LINE=%u", config_line,
-                                        LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg),
-                                        NULL);
-
-        return r;
-}
-
 int config_item_table_lookup(
                 const void *table,
                 const char *section,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 7a2f855..6152ee3 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -119,23 +119,6 @@ int config_parse_mode(const char *unit, const char *filename, unsigned line, con
 int config_parse_log_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_log_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
-int log_syntax_internal(
-                const char *unit,
-                int level,
-                const char *file,
-                int line,
-                const char *func,
-                const char *config_file,
-                unsigned config_line,
-                int error,
-                const char *format, ...) _printf_(9, 10);
-
-#define log_syntax(unit, level, config_file, config_line, error, ...)   \
-        log_syntax_internal(unit, level,                                \
-                            __FILE__, __LINE__, __func__,               \
-                            config_file, config_line,                   \
-                            error, __VA_ARGS__)
-
 #define log_invalid_utf8(unit, level, config_file, config_line, error, rvalue) \
         do {                                                            \
                 _cleanup_free_ char *_p = utf8_escape_invalid(rvalue);  \
diff --git a/src/shared/log.c b/src/shared/log.c
index 85c0605..e8b63a3 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -29,6 +29,7 @@
 #include <stddef.h>
 #include <printf.h>
 
+#include "sd-messages.h"
 #include "log.h"
 #include "util.h"
 #include "missing.h"
@@ -1064,3 +1065,58 @@ void log_received_signal(int level, const struct signalfd_siginfo *si) {
 void log_set_upgrade_syslog_to_journal(bool b) {
         upgrade_syslog_to_journal = b;
 }
+
+int log_syntax_internal(
+                const char *unit,
+                int level,
+                const char *config_file,
+                unsigned config_line,
+                int error,
+                const char *file,
+                int line,
+                const char *func,
+                const char *format, ...) {
+
+        PROTECT_ERRNO;
+        char buffer[LINE_MAX];
+        int r;
+        va_list ap;
+
+        if (error < 0)
+                error = -error;
+
+        if (_likely_(LOG_PRI(level) > log_max_level))
+                return -error;
+
+        if (log_target == LOG_TARGET_NULL)
+                return -error;
+
+        if (error != 0)
+                errno = error;
+
+        va_start(ap, format);
+        vsnprintf(buffer, sizeof(buffer), format, ap);
+        va_end(ap);
+
+        if (unit)
+                r = log_struct_internal(
+                                level, error,
+                                file, line, func,
+                                getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit,
+                                LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION),
+                                "CONFIG_FILE=%s", config_file,
+                                "CONFIG_LINE=%u", config_line,
+                                LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer),
+                                NULL);
+        else
+                r = log_struct_internal(
+                                level, error,
+                                file, line, func,
+                                LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION),
+                                "CONFIG_FILE=%s", config_file,
+                                "CONFIG_LINE=%u", config_line,
+                                LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer),
+                                NULL);
+
+        return r;
+}
diff --git a/src/shared/log.h b/src/shared/log.h
index d6061c0..09d2fc7 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -28,8 +28,8 @@
 #include <sys/signalfd.h>
 #include <errno.h>
 
-#include "macro.h"
 #include "sd-id128.h"
+#include "macro.h"
 
 typedef enum LogTarget{
         LOG_TARGET_CONSOLE,
@@ -209,3 +209,22 @@ LogTarget log_target_from_string(const char *s) _pure_;
 void log_received_signal(int level, const struct signalfd_siginfo *si);
 
 void log_set_upgrade_syslog_to_journal(bool b);
+
+int log_syntax_internal(
+                const char *unit,
+                int level,
+                const char *config_file,
+                unsigned config_line,
+                int error,
+                const char *file,
+                int line,
+                const char *func,
+                const char *format, ...) _printf_(9, 10);
+
+#define log_syntax(unit, level, config_file, config_line, error, ...)   \
+        ({                                                              \
+                int _level = (level), _e = (error);                     \
+                (log_get_max_level() >= LOG_PRI(_level))                \
+                        ? log_syntax_internal(unit, _level, config_file, config_line, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
+                        : -abs(_e);                                     \
+        })
diff --git a/src/systemd/sd-messages.h b/src/systemd/sd-messages.h
index a8379e0..8aedaec 100644
--- a/src/systemd/sd-messages.h
+++ b/src/systemd/sd-messages.h
@@ -81,7 +81,7 @@ _SD_BEGIN_DECLARATIONS;
 #define SD_MESSAGE_SUSPEND_KEY      SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72)
 #define SD_MESSAGE_HIBERNATE_KEY    SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,73)
 
-#define SD_MESSAGE_CONFIG_ERROR     SD_ID128_MAKE(c7,72,d2,4e,9a,88,4c,be,b9,ea,12,62,5c,30,6c,01)
+#define SD_MESSAGE_INVALID_CONFIGURATION SD_ID128_MAKE(c7,72,d2,4e,9a,88,4c,be,b9,ea,12,62,5c,30,6c,01)
 
 #define SD_MESSAGE_BOOTCHART        SD_ID128_MAKE(9f,26,aa,56,2c,f4,40,c2,b1,6c,77,3d,04,79,b5,18)
 

commit 200c7fa6fea5aea301e5b091338c5dc1f88f759c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 21 13:21:44 2015 +0200

    udevadm: enclose invocation of unlinkat() with a (void) cast
    
    Let's make Coverity happy about this one.

diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 352e024..b3d5565 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -205,17 +205,15 @@ static void cleanup_dir(DIR *dir, mode_t mask, int depth) {
                 if ((stats.st_mode & mask) != 0)
                         continue;
                 if (S_ISDIR(stats.st_mode)) {
-                        DIR *dir2;
+                        _cleanup_closedir_ DIR *dir2;
 
                         dir2 = fdopendir(openat(dirfd(dir), dent->d_name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC));
-                        if (dir2 != NULL) {
+                        if (dir2 != NULL)
                                 cleanup_dir(dir2, mask, depth-1);
-                                closedir(dir2);
-                        }
-                        unlinkat(dirfd(dir), dent->d_name, AT_REMOVEDIR);
-                } else {
-                        unlinkat(dirfd(dir), dent->d_name, 0);
-                }
+
+                        (void) unlinkat(dirfd(dir), dent->d_name, AT_REMOVEDIR);
+                } else
+                        (void) unlinkat(dirfd(dir), dent->d_name, 0);
         }
 }
 



More information about the systemd-commits mailing list