]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: change condition in if testing section presence 5275/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 17 Feb 2017 14:34:25 +0000 (09:34 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 17 Feb 2017 14:34:25 +0000 (09:34 -0500)
section_line and filename should be set together or not at all. Change the
if to test filename, since it's the first of the pair and it seems more natural
to test that.

src/network/networkd-address.c
src/network/networkd-route.c

index 9e41244eb747cc7e9404f2f637d532cf591f5dee..9d0311d76f9fdcaffe8837179a644178e768ce4d 100644 (file)
@@ -60,8 +60,9 @@ int address_new_static(Network *network, const char *filename, unsigned section_
 
         assert(network);
         assert(ret);
+        assert(!!filename == (section_line > 0));
 
-        if (section_line > 0) {
+        if (filename) {
                 r = network_config_section_new(filename, section_line, &n);
                 if (r < 0)
                         return r;
@@ -82,7 +83,7 @@ int address_new_static(Network *network, const char *filename, unsigned section_
         if (r < 0)
                 return r;
 
-        if (section_line > 0) {
+        if (filename) {
                 address->section = n;
                 hashmap_put(network->addresses_by_section, n, address);
         }
index ca606c3d25aefad674fd8ae8c4e1b15a3a475278..a8ba293ae8ab88ec1ea9ad713bc1421053622ae6 100644 (file)
@@ -84,8 +84,9 @@ int route_new_static(Network *network, const char *filename, unsigned section_li
 
         assert(network);
         assert(ret);
+        assert(!!filename == (section_line > 0));
 
-        if (section_line > 0) {
+        if (filename) {
                 r = network_config_section_new(filename, section_line, &n);
                 if (r < 0)
                         return r;
@@ -108,7 +109,7 @@ int route_new_static(Network *network, const char *filename, unsigned section_li
 
         route->protocol = RTPROT_STATIC;
 
-        if (section_line > 0) {
+        if (filename) {
                 route->section = n;
                 n = NULL;