network: change condition in if testing section presence

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-02-17 09:34:25 -05:00
parent fd45e522dd
commit 48317c39e2
2 changed files with 6 additions and 4 deletions

View 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);
}

View 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;