]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: formatting tweaks reported by Coccinelle
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 21 Apr 2020 18:23:33 +0000 (20:23 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 21 Apr 2020 21:21:04 +0000 (23:21 +0200)
coccinelle/strempty.cocci
src/home/homework.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/sd-dhcp-server.c
src/test/test-install-root.c

index 7901da3652ce7bb4c9d023e2ffaf7cb84b15ac5d..0868184c5d41edbe101356b5188ccff639fd64f0 100644 (file)
@@ -1,6 +1,18 @@
 @@
-/* Avoid running this transformation on the strempty function itself */
-position p : script:python() { p[0].current_element != "strempty" };
+/* Avoid running this transformation on the strempty function itself and
+ * on the "make_expression" macro in src/libsystemd/sd-bus/bus-convenience.c.
+ * As Coccinelle's Location object doesn't support macro "detection", use
+ * a pretty horrifying combo of specifying a file and a special "something_else"
+ * position element, which is, apparently, the default value of
+ * "current_element" before it's set (according to the source code), thus
+ * matching any "top level" position, including macros. Let's hope we never
+ * introduce a function called "something_else"...
+ */
+position p : script:python() {
+        not (p[0].current_element == "strempty" or
+                (p[0].file == "src/libsystemd/sd-bus/bus-convenience.c" and
+                        p[0].current_element == "something_else"))
+};
 expression s;
 @@
 (
index fc9f03039270cfca479d07e43ef39d86611620d5..38b740729c505394c79c8af3b073ec2273dbafcf 100644 (file)
@@ -1038,10 +1038,9 @@ static int home_remove(UserRecord *h) {
 
         if (deleted)
                 log_info("Everything completed.");
-        else {
-                log_notice("Nothing to remove.");
-                return -EALREADY;
-        }
+        else
+                return log_notice_errno(SYNTHETIC_ERRNO(EALREADY),
+                                        "Nothing to remove.");
 
         return 0;
 }
index 5154af23049ef1ff75b28ff0affc683aa829aa2e..57b412b6cdae95ce8580ae9b8075e0ccd288ac10 100644 (file)
@@ -141,8 +141,8 @@ int sd_dhcp_lease_get_servers(
                 return (int) lease->smtp_server_size;
 
         default:
-                log_debug("Uknown DHCP lease info item %d.", what);
-                return -ENXIO;
+                return log_debug_errno(SYNTHETIC_ERRNO(ENXIO),
+                                       "Uknown DHCP lease info item %d.", what);
         }
 }
 
index a4dcddd95d32c3f51129e11ebece787d0549a53f..3a75649aed95345885651d7de340eada59d90e83 100644 (file)
@@ -1162,8 +1162,8 @@ int sd_dhcp_server_set_servers(
                 break;
 
         default:
-                log_debug("Uknown DHCP lease info item %d.", what);
-                return -ENXIO;
+                return log_debug_errno(SYNTHETIC_ERRNO(ENXIO),
+                                       "Uknown DHCP lease info item %d.", what);
         }
 
         if (*n_a == n_addresses &&
index 0dabc9782e3fbd60543ba202696f0627ec8717ab..79a105c5c3762141a03181849c15b312f654dd10 100644 (file)
@@ -1058,7 +1058,8 @@ static void verify_one(
         r = unit_file_verify_alias(i, alias, &alias2);
         log_info_errno(r, "alias %s ← %s: %d/%m (expected %d)%s%s%s",
                        i->name, alias, r, expected,
-                       alias2 ? " [" : "", alias2 ?: "", alias2 ? "]" : "");
+                       alias2 ? " [" : "", strempty(alias2),
+                       alias2 ? "]" : "");
         assert(r == expected);
 
         /* This is is test for "instance propagation". This propagation matters mostly for WantedBy= and