coverity: in theory, socket() can return -1

This commit is contained in:
folkert van heusden 2024-04-28 01:22:38 +02:00
parent 2238243940
commit f64f2b78ab
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

View file

@ -83,9 +83,11 @@ 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);
if (s != -1) {
(void)sendto(s, msg.c_str(), msg.size(), 0, reinterpret_cast<sockaddr *>(&syslog_ip_addr), sizeof syslog_ip_addr); (void)sendto(s, msg.c_str(), msg.size(), 0, reinterpret_cast<sockaddr *>(&syslog_ip_addr), sizeof syslog_ip_addr);
close(s); close(s);
} }
}
void closelog() void closelog()
{ {