From daca2773ded610633ba524179a64d6e1946681aa Mon Sep 17 00:00:00 2001 From: Libor Pechacek Date: Mon, 17 Jun 2013 16:54:02 +0200 Subject: [PATCH] phc2sys: common code exit point for bad usage case Removed duplicate calls to usage() by providing common exit point for the case. Signed-off-by: Libor Pechacek --- phc2sys.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index d4c9b65..594fc1e 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -684,37 +684,32 @@ int main(int argc, char *argv[]) usage(progname); return 0; default: - usage(progname); - return -1; + goto bad_usage; } } if (pps_fd < 0 && src == CLOCK_INVALID) { fprintf(stderr, "valid source clock must be selected.\n"); - usage(progname); - return -1; + goto bad_usage; } if (dst_clock.clkid == CLOCK_INVALID) { fprintf(stderr, "valid destination clock must be selected.\n"); - usage(progname); - return -1; + goto bad_usage; } 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; + goto bad_usage; } if (!wait_sync && !forced_sync_offset) { fprintf(stderr, "time offset must be specified using -w or -O\n"); - usage(progname); - return -1; + goto bad_usage; } if (dst_clock.stats_max_count > 0) { @@ -793,4 +788,8 @@ int main(int argc, char *argv[]) phc_readings); return do_phc_loop(&dst_clock, src, &phc_interval_tp, phc_readings); + +bad_usage: + usage(progname); + return -1; }