chiark / gitweb /
Do not return -1 (EINVAL) on allocation error
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 Mar 2014 13:05:56 +0000 (09:05 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 Mar 2014 13:31:34 +0000 (09:31 -0400)
src/core/socket.c
src/network/networkd-link.c

index 8ecc9f9..b39bec2 100644 (file)
@@ -198,16 +198,14 @@ static int socket_instantiate_service(Socket *s) {
 
         assert(s->accept);
 
-        if (!(prefix = unit_name_to_prefix(UNIT(s)->id)))
+        prefix = unit_name_to_prefix(UNIT(s)->id);
+        if (!prefix)
                 return -ENOMEM;
 
-        r = asprintf(&name, "%s@%u.service", prefix, s->n_accepted);
-
-        if (r < 0)
+        if (asprintf(&name, "%s@%u.service", prefix, s->n_accepted) < 0)
                 return -ENOMEM;
 
         r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u);
-
         if (r < 0)
                 return r;
 
index 2650f86..275ad97 100644 (file)
@@ -53,10 +53,10 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret) {
         if (link->ifindex <= 0)
                 return -EINVAL;
 
-        r = asprintf(&link->state_file, "/run/systemd/network/links/%u",
-                     (unsigned) link->ifindex);
+        r = asprintf(&link->state_file, "/run/systemd/network/links/%"PRIu64,
+                     link->ifindex);
         if (r < 0)
-                return r;
+                return -ENOMEM;
 
         mac = udev_device_get_sysattr_value(device, "address");
         if (mac) {
@@ -1381,10 +1381,10 @@ int link_save(Link *link) {
         if (link->dhcp_lease) {
                 char *lease_file;
 
-                r = asprintf(&lease_file, "/run/systemd/network/leases/%u",
-                             (unsigned) link->ifindex);
+                r = asprintf(&lease_file, "/run/systemd/network/leases/%"PRIu64,
+                             link->ifindex);
                 if (r < 0)
-                        return r;
+                        return -ENOMEM;
 
                 r = dhcp_lease_save(link->dhcp_lease, lease_file);
                 if (r < 0)