From 7c501032b212f2229e72e6c50f520fe1ca47070c Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 20 Aug 2012 10:56:08 -0700 Subject: [PATCH] ptp4l: correct print global set functions this patch updates the global set functions to allow the user to set the proper value instead of only being allowed to enable (or disable) a particular feature. The new patch allows the function to specify exactly what they want the value to be. This patch also clarifies what -q and -v do by removing mention of quiet mode and verbose mode. It is easy for a user to confuse and assume that -q disables -v when this is not true. Signed-off-by: Jacob Keller --- pmc.c | 4 ++-- print.c | 10 +++++----- print.h | 4 ++-- ptp4l.c | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pmc.c b/pmc.c index 5c44d94..d9f4613 100644 --- a/pmc.c +++ b/pmc.c @@ -347,8 +347,8 @@ int main(int argc, char *argv[]) pollfd[1].fd = fdarray.fd[FD_GENERAL]; pollfd[1].events = POLLIN|POLLPRI; - print_no_syslog(); - print_verbose(); + print_set_syslog(1); + print_set_verbose(1); while (1) { cnt = poll(pollfd, N_FD, -1); diff --git a/print.c b/print.c index f42d254..069cec6 100644 --- a/print.c +++ b/print.c @@ -24,13 +24,13 @@ #include "print.h" -static int verbose; +static int verbose = 0; static int print_level = LOG_INFO; static int use_syslog = 1; -void print_no_syslog(void) +void print_set_syslog(int value) { - use_syslog = 0; + use_syslog = value ? 1 : 0; } void print_set_level(int level) @@ -38,9 +38,9 @@ void print_set_level(int level) print_level = level; } -void print_verbose(void) +void print_set_verbose(int value) { - verbose = 1; + verbose = value ? 1 : 0; } void print(int level, char const *format, ...) diff --git a/print.h b/print.h index 1b42b2b..ad18105 100644 --- a/print.h +++ b/print.h @@ -24,9 +24,9 @@ void print(int level, char const *format, ...); -void print_no_syslog(void); +void print_set_syslog(int value); void print_set_level(int level); -void print_verbose(void); +void print_set_verbose(int value); #define pr_emerg(x...) print(LOG_EMERG, x) #define pr_alert(x...) print(LOG_ALERT, x) diff --git a/ptp4l.c b/ptp4l.c index 764d1d4..14d93f2 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -63,8 +63,8 @@ static void usage(char *progname) " (ignored for SOFTWARE/LEGACY HW time stamping)\n" " -s slave only mode (overrides configuration file)\n" " -l [num] set the logging level to 'num'\n" - " -q quiet mode, do not use syslog(3)\n" - " -v verbose mode, print messages to stdout\n" + " -q do not print messages to the syslog\n" + " -v print messages to stdout\n" " -h prints this message and exits\n" "\n", progname); @@ -137,10 +137,10 @@ int main(int argc, char *argv[]) print_set_level(atoi(optarg)); break; case 'q': - print_no_syslog(); + print_set_syslog(1); break; case 'v': - print_verbose(); + print_set_verbose(1); break; case 'h': usage(progname);