util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/5] hwclock: Fix --date debug messages
@ 2014-10-24  2:53 JWP
  2014-10-24 11:41 ` Benno Schulenberg
  0 siblings, 1 reply; 3+ messages in thread
From: JWP @ 2014-10-24  2:53 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux


Fix --date debug messages with:
* Empty results for invalid arguments
* Empty lines(superfluous line breaks)
* Uncapitalized and missing words
* Inconsistent language
* Outdated message:
  --date is now used for --predict so
  'cannot set clock' makes no sense.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
---
 sys-utils/hwclock.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 3ad3791..6d05d46 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -765,15 +765,14 @@ static int interpret_date_string(const char *date_opt, time_t * const time_p)
 	}

 	if (!fgets(date_resp, sizeof(date_resp), date_child_fp))
-		date_resp[0] = '\0';	/* in case fgets fails */
+		strcpy(date_resp, "NULL\n");	/* in case fgets fails */
 	if (debug)
-		printf(_("response from date command = %s"), date_resp);
+		printf(_("The response was: %s"), date_resp);
 	if (strncmp(date_resp, magic, sizeof(magic) - 1) != 0) {
 		warnx(_("The date command issued by %s returned "
-				  "unexpected results\n"
-				  "The command was:\n  %s\n"
-				  "The response was:\n  %s"),
-			program_invocation_short_name, date_command, date_resp);
+			"unexpected results\nThe response was: %s"
+			"The command was: %s"),
+		      program_invocation_short_name, date_resp, date_command);
 		retcode = 8;
 	} else {
 		long seconds_since_epoch;
@@ -783,16 +782,14 @@ static int interpret_date_string(const char *date_opt, time_t * const time_p)
 			warnx(_("The date command issued by %s returned "
 				"something other\nthan an integer where the "
 				"converted time value was expected\n"
-				"The command was:\n  %s\n"
-				"The response was:\n %s\n"),
-			      program_invocation_short_name, date_command,
-			      date_resp);
+				"The response was: %sThe command was: %s"),
+			      program_invocation_short_name, date_resp, date_command);
 			retcode = 6;
 		} else {
 			retcode = 0;
 			*time_p = seconds_since_epoch;
 			if (debug)
-				printf(_("date string %s equates to "
+				printf(_("The date string '%s' equates to:\n"
 					 "%ld seconds since 1969\n"),
 				       date_opt, (long)*time_p);
 		}
@@ -1905,8 +1902,7 @@ int main(int argc, char **argv)
 		rc = interpret_date_string(date_opt, &set_time);
 		/* (time-consuming) */
 		if (rc != 0) {
-			warnx(_("No usable set-to time,  "
-				"cannot set clock"));
+			warnx(_("Invalid --date argument, see date(1)"));
 			hwclock_exit(EX_USAGE);
 		}
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/5] hwclock: Fix --date debug messages
  2014-10-24  2:53 [PATCH 4/5] hwclock: Fix --date debug messages JWP
@ 2014-10-24 11:41 ` Benno Schulenberg
  2014-10-24 11:51   ` Benno Schulenberg
  0 siblings, 1 reply; 3+ messages in thread
From: Benno Schulenberg @ 2014-10-24 11:41 UTC (permalink / raw)
  To: JWP; +Cc: Karel Zak, Util-Linux


On Fri, Oct 24, 2014, at 04:53, JWP wrote:
>  	if (debug)
> -		printf(_("response from date command = %s"), date_resp);
> +		printf(_("The response was: %s"), date_resp);
>  	if (strncmp(date_resp, magic, sizeof(magic) - 1) != 0) {
>  		warnx(_("The date command issued by %s returned "
> -				  "unexpected results\n"
> -				  "The command was:\n  %s\n"
> -				  "The response was:\n  %s"),
> -			program_invocation_short_name, date_command, date_resp);
> +			"unexpected results\nThe response was: %s"
> +			"The command was: %s"),
> +		      program_invocation_short_name, date_resp, date_command);

Oh no.  If the user does not use --debug, hwclock will warn that
a command gave an unexpected result and will print the command
but not the actual result.  This is silly.

By the way, the --debug flag is improperly named.  It should actually
be called --verbose, because in all the rest of util-linux debug messages
are never gettextized (using calls to _()).  The use of --debug is not
meant to debug hwclock itself but to debug the user's use of hwclock.
It should therefore be called --verbose.

Benno

-- 
http://www.fastmail.fm - A fast, anti-spam email service.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/5] hwclock: Fix --date debug messages
  2014-10-24 11:41 ` Benno Schulenberg
@ 2014-10-24 11:51   ` Benno Schulenberg
  0 siblings, 0 replies; 3+ messages in thread
From: Benno Schulenberg @ 2014-10-24 11:51 UTC (permalink / raw)
  To: JWP; +Cc: Karel Zak, Util-Linux


On Fri, Oct 24, 2014, at 13:41, Benno Schulenberg wrote:
> On Fri, Oct 24, 2014, at 04:53, JWP wrote:
> > -				  "unexpected results\n"
> > -				  "The command was:\n  %s\n"
> > -				  "The response was:\n  %s"),
> > -			program_invocation_short_name, date_command, date_resp);
> > +			"unexpected results\nThe response was: %s"
> > +			"The command was: %s"),
> > +		      program_invocation_short_name, date_resp, date_command);
> 
> Oh no.  If the user does not use --debug, hwclock will warn that
> a command gave an unexpected result and will print the command
> but not the actual result.  This is silly.

Sorry, I misread.  That's what you get with a \n in the middle of a line.

Benno

-- 
http://www.fastmail.fm - Same, same, but different...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-24 11:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-24  2:53 [PATCH 4/5] hwclock: Fix --date debug messages JWP
2014-10-24 11:41 ` Benno Schulenberg
2014-10-24 11:51   ` Benno Schulenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).