Avoid prompting error on empty line
authorJosé Bollo <jose.bollo@iot.bzh>
Thu, 6 Apr 2017 12:52:04 +0000 (14:52 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Thu, 6 Apr 2017 14:26:13 +0000 (16:26 +0200)
Change-Id: I9da7f17f93f1948da23f6a2304f0718d7bee6464
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-client-demo.c

index 4f8882e..434c6d1 100644 (file)
@@ -222,9 +222,10 @@ static int io_event_callback(sd_event_source *src, int fd, uint32_t revents, voi
                rest[0] = i; while(i < count && line[i] != '\n') i++; rest[1] = i;
                if (i == count) break;
                line[i++] = 0;
-               if (api[0] == api[1] || verb[0] == verb[1])
-                       fprintf(stderr, "bad line: %s\n", line+pos);
-               else {
+               if (api[0] == api[1] || verb[0] == verb[1]) {
+                       if (api[0] != api[1] || verb[0] != verb[1])
+                               fprintf(stderr, "bad line: %s\n", line+pos);
+               } else {
                        line[api[1]] = line[verb[1]] = 0;
                        emit(line + api[0], line + verb[0], line + rest[0]);
                }