]> git.itanic.dy.fi Git - log-plotter/commitdiff
Convert all existing prints into appropriate trace print
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 6 Oct 2013 14:58:10 +0000 (17:58 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 6 Oct 2013 15:24:24 +0000 (18:24 +0300)
Don't use printf for trace messages as we have the new tracing code.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
baud.c
main.c

diff --git a/baud.c b/baud.c
index 834974e35fd0750091486c9b446517b612eafb99..4fd5168db7e373570e8846055abb2f9c591f2bba 100644 (file)
--- a/baud.c
+++ b/baud.c
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <linux/termios.h>
 #include <unistd.h>
 #include <string.h>
 #include <linux/termios.h>
 #include <unistd.h>
+#include "debug.h"
 
 /*
  * HACK: declare the ioctl function by hand...
 
 /*
  * HACK: declare the ioctl function by hand...
@@ -33,12 +34,12 @@ int open_at_baud(const char *device, int *baud)
        fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
 
        if (fd == -1) {
        fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
 
        if (fd == -1) {
-               fprintf(stderr, "error opening %s: %m\n",       device);
+               pr_err("error opening %s: %m\n", device);
                return fd;
        }
 
        if (ioctl(fd, TCGETS2, &tios)) {
                return fd;
        }
 
        if (ioctl(fd, TCGETS2, &tios)) {
-               perror("TCGETS2");
+               pr_err("TCGETS2: %m\n");
                goto err;
        }
 
                goto err;
        }
 
@@ -48,12 +49,12 @@ int open_at_baud(const char *device, int *baud)
        tios.c_ospeed = *baud;
 
        if (ioctl(fd, TCSETS2, &tios)) {
        tios.c_ospeed = *baud;
 
        if (ioctl(fd, TCSETS2, &tios)) {
-               perror("TCSETS2");
+               pr_err("TCSETS2: %m");
                goto err;
        }
 
        if (ioctl(fd, TCGETS2, &tios)) {
                goto err;
        }
 
        if (ioctl(fd, TCGETS2, &tios)) {
-               perror("TCGETS2");
+               pr_err("TCGETS2: %m");
                goto err;
        }
 
                goto err;
        }
 
diff --git a/main.c b/main.c
index d81f7333e25f062c28e15e4b43f3f9e77335c6f6..065d9dc2b1f20a19ecaf5a07e95409866a16382a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,6 +4,7 @@
 
 #include "options.h"
 #include "baud.h"
 
 #include "options.h"
 #include "baud.h"
+#include "debug.h"
 
 int main(int argc, char *argv[])
 {
 
 int main(int argc, char *argv[])
 {
@@ -23,7 +24,7 @@ int main(int argc, char *argv[])
                return 1;
 
        if (baud != options.baud_rate) {
                return 1;
 
        if (baud != options.baud_rate) {
-               printf("Failed to set baudrate to %d, only got %d\n",
+               pr_err("Failed to set baudrate to %d, only got %d\n",
                        options.baud_rate, baud);
                close(fd);
                return 1;
                        options.baud_rate, baud);
                close(fd);
                return 1;
@@ -34,7 +35,7 @@ int main(int argc, char *argv[])
        ev.events = EPOLLIN;
        ev.data.fd = fd;
        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
        ev.events = EPOLLIN;
        ev.data.fd = fd;
        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
-               perror("epoll_ctl");
+               pr_err("epoll_ctl: %m\n");
                return 1;
        }
 
                return 1;
        }
 
@@ -44,22 +45,24 @@ int main(int argc, char *argv[])
                        continue;
 
                if (ret < 0) {
                        continue;
 
                if (ret < 0) {
-                       perror("epoll");
+                       pr_err("epoll: %m\n");
                        return 1;
                }
 
                ret = read(fd, buf, sizeof(buf));
                if (read < 0) {
                        return 1;
                }
 
                ret = read(fd, buf, sizeof(buf));
                if (read < 0) {
-                       perror("read");
+                       pr_err("read: %m\n");
                        break;
                }
 
                        break;
                }
 
-               if (ret == 0)
+               if (ret == 0) {
+                       pr_err("Read EOF, stopping\n");
                        break;
                        break;
+               }
 
                ret = write(1, buf, ret);
                if (read < 0) {
 
                ret = write(1, buf, ret);
                if (read < 0) {
-                       perror("write");
+                       pr_err("write: %m\n");
                        break;
                }
        }
                        break;
                }
        }