coverity: in theory, socket() can return -1
This commit is contained in:
parent
2238243940
commit
f64f2b78ab
1 changed files with 4 additions and 2 deletions
6
log.cpp
6
log.cpp
|
@ -83,8 +83,10 @@ void send_syslog(const int ll, const std::string & what)
|
||||||
std::string msg = format("<%d>%s", 16 * 8 + ll, what.c_str());
|
std::string msg = format("<%d>%s", 16 * 8 + ll, what.c_str());
|
||||||
|
|
||||||
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
(void)sendto(s, msg.c_str(), msg.size(), 0, reinterpret_cast<sockaddr *>(&syslog_ip_addr), sizeof syslog_ip_addr);
|
if (s != -1) {
|
||||||
close(s);
|
(void)sendto(s, msg.c_str(), msg.size(), 0, reinterpret_cast<sockaddr *>(&syslog_ip_addr), sizeof syslog_ip_addr);
|
||||||
|
close(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void closelog()
|
void closelog()
|
||||||
|
|
Loading…
Add table
Reference in a new issue