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:
parent
b06f12669a
commit
e3cb03010d
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user