diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-04-25 07:40:58 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-25 07:40:58 +0300 |
| commit | d45a846e5ca313e5ab132ef57c495cc0407b50d9 (patch) | |
| tree | 8e0e953356d2bd23d8238120f14b1acf953f5dc1 | |
| parent | c27892b24d21762f3cd4276fa2cca75c958f9b15 (diff) | |
| parent | a7141b85c8ded6f05edf51d5a61e063493fc85c7 (diff) | |
Merge pull request #11067 from donaldsharp/domainname
lib: Ensure an empty string does not get printed for host/domain
| -rw-r--r-- | lib/command.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/command.c b/lib/command.c index 1989668bf0..a429510059 100644 --- a/lib/command.c +++ b/lib/command.c @@ -445,11 +445,15 @@ static bool full_cli; /* This function write configuration of this host. */ static int config_write_host(struct vty *vty) { - if (cmd_hostname_get()) - vty_out(vty, "hostname %s\n", cmd_hostname_get()); + const char *name; - if (cmd_domainname_get()) - vty_out(vty, "domainname %s\n", cmd_domainname_get()); + name = cmd_hostname_get(); + if (name && name[0] != '\0') + vty_out(vty, "hostname %s\n", name); + + name = cmd_domainname_get(); + if (name && name[0] != '\0') + vty_out(vty, "domainname %s\n", name); /* The following are all configuration commands that are not sent to * watchfrr. For instance watchfrr is hardcoded to log to syslog so |
