From 2a897566541f1374db5820e30b3af5b19ebb050c Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Tue, 14 May 2013 15:12:16 -0700 Subject: [PATCH] phc2sys: update usage/error reporting This patch updates phc2sys usage reporting to give a slightly better indication of why the program was unable to run. Signed-off-by: Jacob Keller --- phc2sys.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index 409704e..1dbe2bc 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -663,9 +663,23 @@ int main(int argc, char *argv[]) } } - if (!(pps_fd >= 0 || src != CLOCK_INVALID) || - dst_clock.clkid == CLOCK_INVALID || - (pps_fd >= 0 && dst_clock.clkid != CLOCK_REALTIME)) { + if (pps_fd < 0 && src == CLOCK_INVALID) { + fprintf(stderr, + "valid source clock must be selected.\n"); + usage(progname); + return -1; + } + + if (dst_clock.clkid == CLOCK_INVALID) { + fprintf(stderr, + "valid destination clock must be selected.\n"); + usage(progname); + return -1; + } + + if (pps_fd >= 0 && dst_clock.clkid != CLOCK_REALTIME) { + fprintf(stderr, + "cannot use a pps device unless destination is CLOCK_REALTIME\n"); usage(progname); return -1; }