dhcp-sever: check properly for invalid fds
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Mar 2018 19:30:29 +0000 (20:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Mar 2018 19:30:29 +0000 (20:30 +0100)
We generally just compare for negativity, not for equlity to -1, let's
do so here too.

src/libsystemd-network/sd-dhcp-server.c

index 1a15d77..7cc25ef 100644 (file)
@@ -1012,8 +1012,8 @@ int sd_dhcp_server_start(sd_dhcp_server *server) {
         assert_return(server, -EINVAL);
         assert_return(server->event, -EINVAL);
         assert_return(!server->receive_message, -EBUSY);
-        assert_return(server->fd_raw == -1, -EBUSY);
-        assert_return(server->fd == -1, -EBUSY);
+        assert_return(server->fd_raw < 0, -EBUSY);
+        assert_return(server->fd < 0, -EBUSY);
         assert_return(server->address != htobe32(INADDR_ANY), -EUNATCH);
 
         r = socket(AF_PACKET, SOCK_DGRAM | SOCK_NONBLOCK, 0);