]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: fix watch return code
authorVincent Bernat <vincent@bernat.im>
Tue, 14 Jun 2016 10:12:25 +0000 (12:12 +0200)
committerVincent Bernat <vincent@bernat.im>
Tue, 14 Jun 2016 10:12:25 +0000 (12:12 +0200)
When watch terminates normally (after hitting a limit), ensure lldpcli
exits with status code 0.

src/client/show.c

index 57fc8b20eda0a752a97c437f31c7422debf2697f..fa704b864635ca275000d6008ec93715a739415d 100644 (file)
@@ -187,7 +187,6 @@ static int
 cmd_watch_neighbors(struct lldpctl_conn_t *conn, struct writer *w,
     struct cmd_env *env, void *arg)
 {
-       int watch = 1;
        struct watcharg wa = {
                .env = env,
                .w = w,
@@ -211,14 +210,14 @@ cmd_watch_neighbors(struct lldpctl_conn_t *conn, struct writer *w,
                    lldpctl_last_strerror(conn));
                return 0;
        }
-       while (watch) {
+       while (1) {
                if (lldpctl_watch(conn) < 0) {
                        log_warnx("lldpctl", "unable to watch for neighbors. %s",
                            lldpctl_last_strerror(conn));
-                       watch = 0;
+                       return 0;
                }
                if (limit > 0 && wa.nb >= limit)
-                       watch = 0;
+                       return 1;
        }
        return 0;
 }