svn commit: r366337 - head/usr.sbin/ctld
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Oct 1 18:56:45 UTC 2020
Author: trasz
Date: Thu Oct 1 18:56:44 2020
New Revision: 366337
URL: https://svnweb.freebsd.org/changeset/base/366337
Log:
Don't ignore the return value from gethostname(3). It probably
cannot happen, but it silences Coverity.
Reviewed by: mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26606
Modified:
head/usr.sbin/ctld/ctld.c
Modified: head/usr.sbin/ctld/ctld.c
==============================================================================
--- head/usr.sbin/ctld/ctld.c Thu Oct 1 18:45:31 2020 (r366336)
+++ head/usr.sbin/ctld/ctld.c Thu Oct 1 18:56:44 2020 (r366337)
@@ -931,7 +931,7 @@ void
isns_register(struct isns *isns, struct isns *oldisns)
{
struct conf *conf = isns->i_conf;
- int s;
+ int error, s;
char hostname[256];
if (TAILQ_EMPTY(&conf->conf_targets) ||
@@ -943,8 +943,10 @@ isns_register(struct isns *isns, struct isns *oldisns)
set_timeout(0, false);
return;
}
- gethostname(hostname, sizeof(hostname));
-
+ error = gethostname(hostname, sizeof(hostname));
+ if (error != 0)
+ log_err(1, "gethostname");
+
if (oldisns == NULL || TAILQ_EMPTY(&oldisns->i_conf->conf_targets))
oldisns = isns;
isns_do_deregister(oldisns, s, hostname);
@@ -957,7 +959,7 @@ void
isns_check(struct isns *isns)
{
struct conf *conf = isns->i_conf;
- int s, res;
+ int error, s, res;
char hostname[256];
if (TAILQ_EMPTY(&conf->conf_targets) ||
@@ -969,8 +971,10 @@ isns_check(struct isns *isns)
set_timeout(0, false);
return;
}
- gethostname(hostname, sizeof(hostname));
-
+ error = gethostname(hostname, sizeof(hostname));
+ if (error != 0)
+ log_err(1, "gethostname");
+
res = isns_do_check(isns, s, hostname);
if (res < 0) {
isns_do_deregister(isns, s, hostname);
@@ -984,7 +988,7 @@ void
isns_deregister(struct isns *isns)
{
struct conf *conf = isns->i_conf;
- int s;
+ int error, s;
char hostname[256];
if (TAILQ_EMPTY(&conf->conf_targets) ||
@@ -994,8 +998,10 @@ isns_deregister(struct isns *isns)
s = isns_do_connect(isns);
if (s < 0)
return;
- gethostname(hostname, sizeof(hostname));
-
+ error = gethostname(hostname, sizeof(hostname));
+ if (error != 0)
+ log_err(1, "gethostname");
+
isns_do_deregister(isns, s, hostname);
close(s);
set_timeout(0, false);
More information about the svn-src-head
mailing list