From 06e2d40f999e2b7586a8608faf6d581f6ae91687 Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Fri, 17 Mar 2017 20:12:17 +0100 Subject: [PATCH] Improvements for cit - Added error checking. - Added help text. - Added info. Signed-off-by: Jasmin Jessich --- apps/cit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/cit.c b/apps/cit.c index 2a3f6e7..6e2dc74 100644 --- a/apps/cit.c +++ b/apps/cit.c @@ -92,6 +92,10 @@ void *get_ts(void *a) return NULL; sprintf(fname, "/dev/dvb/adapter%u/ci%u", adapter, device); fdi = open(fname, O_RDONLY); + if (fdi == -1) { + printf("Failed to open %s for read: %m\n", fname); + return NULL; + } while (1) { memset(buf, 0, 188*rnum); @@ -123,6 +127,10 @@ int send(void) return -1; sprintf(fname, "/dev/dvb/adapter%u/ci%u", adapter, device); fdo=open(fname, O_WRONLY); + if (fdo == -1) { + printf("Failed to open %s to write: %m\n", fname); + exit(2); + } while (1) { for (i=0; i -d\n"); + exit(-1); break; - } } if (optind < argc) { printf("Warning: unused arguments\n"); } + printf("adpter %d, device: %d\n", adapter, device); memset(ts+8, 180, 0x5a); pthread_create(&th, NULL, get_ts, NULL); usleep(10000);