summaryrefslogtreecommitdiffstats
path: root/tools/iio/iio_event_monitor.c
diff options
context:
space:
mode:
authorCristina Opriceana <cristina.opriceana@gmail.com>2015-07-17 18:43:42 +0300
committerJonathan Cameron <jic23@kernel.org>2015-07-20 18:41:24 +0100
commitd9abc615ea1659b6967a00e95b1b3a7fd4079b80 (patch)
tree6eac43b77eccb14c697c50bf7ccea372c0e3e918 /tools/iio/iio_event_monitor.c
parent34cbea1908fb686b037e01e5b1ab8e0e67b09ed3 (diff)
downloadop-kernel-dev-d9abc615ea1659b6967a00e95b1b3a7fd4079b80.zip
op-kernel-dev-d9abc615ea1659b6967a00e95b1b3a7fd4079b80.tar.gz
tools: iio: Send error messages to stderr
This patch indends to make some cleanup and send printf error messages to stderr. The changes were performed with coccinelle for failure messages and manual for other cases, such as wrong usage messages. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio/iio_event_monitor.c')
-rw-r--r--tools/iio/iio_event_monitor.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 9ee1959..cd3fd41 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -215,8 +215,8 @@ static void print_event(struct iio_event_data *event)
bool diff = IIO_EVENT_CODE_EXTRACT_DIFF(event->id);
if (!event_is_known(event)) {
- printf("Unknown event: time: %lld, id: %llx\n",
- event->timestamp, event->id);
+ fprintf(stderr, "Unknown event: time: %lld, id: %llx\n",
+ event->timestamp, event->id);
return;
}
@@ -251,7 +251,7 @@ int main(int argc, char **argv)
int fd, event_fd;
if (argc <= 1) {
- printf("Usage: %s <device_name>\n", argv[0]);
+ fprintf(stderr, "Usage: %s <device_name>\n", argv[0]);
return -1;
}
@@ -277,14 +277,14 @@ int main(int argc, char **argv)
fd = open(chrdev_name, 0);
if (fd == -1) {
ret = -errno;
- fprintf(stdout, "Failed to open %s\n", chrdev_name);
+ fprintf(stderr, "Failed to open %s\n", chrdev_name);
goto error_free_chrdev_name;
}
ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
if (ret == -1 || event_fd == -1) {
ret = -errno;
- fprintf(stdout, "Failed to retrieve event fd\n");
+ fprintf(stderr, "Failed to retrieve event fd\n");
if (close(fd) == -1)
perror("Failed to close character device file");
@@ -300,7 +300,7 @@ int main(int argc, char **argv)
ret = read(event_fd, &event, sizeof(event));
if (ret == -1) {
if (errno == EAGAIN) {
- printf("nothing available\n");
+ fprintf(stderr, "nothing available\n");
continue;
} else {
ret = -errno;
@@ -310,7 +310,7 @@ int main(int argc, char **argv)
}
if (ret != sizeof(event)) {
- printf("Reading event failed!\n");
+ fprintf(stderr, "Reading event failed!\n");
ret = -EIO;
break;
}
OpenPOWER on IntegriCloud