gluon-radv-filterd: Fix sock initialization check

A socket with the value 0 is valid (and it the first opened socket). It is
therefore a bad idea to check for 0 when wanting to find out whether a
socket was initialized.

Instead initialize it with -1 and check for < 0 to find out whether the
socket was initialized or not.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
Sven Eckelmann 2017-12-20 18:51:18 +01:00 committed by Jan-Philipp Litza
parent b06f12669a
commit e3cb03010d
No known key found for this signature in database
GPG Key ID: 1FB658053CE27196

View File

@ -267,7 +267,7 @@ static void parse_cmdline(int argc, char *argv[]) {
while ((c = getopt(argc, argv, "c:hi:m:t:")) != -1) {
switch (c) {
case 'i':
if (G.sock != 0)
if (G.sock >= 0)
usage("-i given more than once");
ifindex = if_nametoindex(optarg);
if (ifindex == 0)
@ -737,9 +737,10 @@ int main(int argc, char *argv[]) {
clock_gettime(CLOCK_MONOTONIC, &next_update);
next_update.tv_sec += MIN_INTERVAL;
G.sock = -1;
parse_cmdline(argc, argv);
if (G.sock == 0)
if (G.sock < 0)
usage("No interface set!");
if (G.chain == NULL)