All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: J William Piggott <elseifthen@gmx.com>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: pull: hwclock 27 changes
Date: Sun, 8 Jan 2017 09:39:40 +0000	[thread overview]
Message-ID: <CAG27Bk2Kg4MQFKSDwAxM849HJ7AxZWLX1vGL21qO042za=V1pw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.20.1701072212010.9096@imuri>

On 7 January 2017 at 23:06, Sami Kerola <kerolasa@iki.fi> wrote:
> On Sat, 7 Jan 2017, J William Piggott wrote:
>   git://github.com/kerolasa/lelux-utiliteetit.git hwclock-jwp-reviewed
>
> that has in almost all changes 'Reviewed-by: J William Piggott
> <elseifthen@gmx.com>'. Notice also that the latest update is not 100%
> ready. We have question of --compare open, and 'hwclock: move command-line
> options to control structure' has issue that is not yet corrected yet.

hwclock-jwp-reviewed got update:

-- snip
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index b41acd450..c3bcc2fa0 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1245,11 +1245,6 @@ manipulate_clock(const struct hwclock_control
*ctl, const time_t set_time,
  adjtime->dirty = TRUE;
  }

- if (ctl->noadjfile || (ctl->systz && (ctl->utc || ctl->local_opt))) {
- /* A little trick to avoid writing the file if we don't have to */
- adjtime->dirty = FALSE;
- }
-
  if (ctl->show || ctl->get || ctl->adjust || ctl->hctosys
     || (!ctl->noadjfile && !ctl->systz && !ctl->predict)) {
  /* data from HW-clock are required */
@@ -1558,7 +1553,7 @@ int main(int argc, char **argv)
 {
  struct hwclock_control ctl = { 0 };
  struct timeval startup_time;
- struct adjtime adjtime;
+ struct adjtime adjtime = { 0 };
  /*
  * The time we started up, in seconds into the epoch, including
  * fractions.
@@ -1839,8 +1834,12 @@ int main(int argc, char **argv)
  }
  }

- if ((rc = read_adjtime(&ctl, &adjtime)) != 0)
- hwclock_exit(&ctl, rc);
+ if (!ctl.noadjfile && !(ctl.systz && (ctl.utc || ctl.local_opt))) {
+ if ((rc = read_adjtime(&ctl, &adjtime)) != 0)
+ hwclock_exit(&ctl, rc);
+ } else
+ /* avoid writing adjtime file if we don't have to */
+ adjtime.dirty = FALSE;
  ctl.universal = hw_clock_is_utc(&ctl, adjtime);
  if (ctl.compare) {
  if (compare_clock(&ctl))
-- snip

that should fix:

>> commit 59aff057349335cd089c34bb0eaa972cf60ff96a
>> Author: Sami Kerola <kerolasa@iki.fi>
>> Date:   Sat Jul 16 16:45:07 2016 +0100
>>
>>     hwclock: move command-line options to control structure
>>
>>     The control structure is read-only everywhere else but in main().  Almost
>>     all changes are about how variables are referred, with one exception.  Calls
>>     to read_adjtime() from manipulate_clock() and compare_clock() are moved to
>>     main().  This way it is possible to keep variable that tells if hwclock is
>>     using UTC-0 be part of control structure.
>>
>>     Changes within #ifdef __alpha__ segments were tested by flipping the
>>     preprocessor directivive otherway around and getting good compilaton all the
>>     way to the point where linking on none-alpha system failed.
>>
>>     Signed-off-by: Sami Kerola <kerolasa@iki.fi>
>>
>>  8< -------
>>
>> @@ -1255,32 +1233,27 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
>>       /* local return code */
>>       int rc = 0;
>>
>> -     if (!systz && !predict) {
>> +     if (!ctl->systz && !ctl->predict) {
>>               no_auth = ur->get_permissions();
>>               if (no_auth)
>>                       return EX_NOPERM;
>>       }
>>
>> -     if (!noadjfile && !(systz && (utc || local_opt))) {
>> -             rc = read_adjtime(&adjtime);
>> -             if (rc)
>> -                     return rc;
>> -     } else {
>> -             /* A little trick to avoid writing the file if we don't have to */
>> -             adjtime.dirty = FALSE;
>>
>> >
>> > You have to move the above to where you read_adjtime in main. The
>> > concept behind --systz is speed, so we don't want to read the file
>> > then unless they also are changing timescales from the command line.
>> > It is not intended to use --systz for changing timescales, so that
>> > shouldn't happen. More importantly, hwclock depends on *adjtime having
>> > default values when using --noadjfile. For example comparing the
>> > patched version to master using the --get function:
>>
>> ./hwclock-master --get --debug --noadjfile --utc | grep -E 'Calculated|2017\-'; ./hwclock-sami --get --debug --noadjfile --utc | grep -E 'Calculated|2017\-'
>> Calculated Hardware Clock drift is 0.000000 seconds
>> 2017-01-06 10:11:32.294942-0500
>> Calculated Hardware Clock drift is 1.325654 seconds
>> 2017-01-06 10:11:34.339980-0500
>>
>> >
>> >
>> >
>>
>> +     if ((ctl->set || ctl->systohc || ctl->adjust) &&
>> +         (adjtime->local_utc == UTC) != ctl->universal) {
>> +             adjtime->local_utc = ctl->universal ? UTC : LOCAL;
>> +             adjtime->dirty = TRUE;
>>       }
>>
>> -     universal = hw_clock_is_utc(utc, local_opt, adjtime);
>> -
>> -     if ((set || systohc || adjust) &&
>> -         (adjtime.local_utc == UTC) != universal) {
>> -             adjtime.local_utc = universal ? UTC : LOCAL;
>> -             adjtime.dirty = TRUE;
>> +     if (ctl->noadjfile || (ctl->systz && (ctl->utc || ctl->local_opt))) {
>> +             /* A little trick to avoid writing the file if we don't have to */
>> +             adjtime->dirty = FALSE;
>>
>> >
>> > So the above addition won't be here.
>> >
>
> This issue is not corrected yet. It's getting a bit too late in my
> timezone to do change that requires concentration. I will send notify to
> email list when necessary update is done.


-- 
Sami Kerola
http://www.iki.fi/kerolasa/

  reply	other threads:[~2017-01-08  9:39 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-31 21:41 pull: hwclock 27 changes Sami Kerola
2017-01-03 14:34 ` J William Piggott
     [not found] ` <05e4405f-8096-9261-f9f2-d2c6b84675bc@gmx.com>
2017-01-07 19:37   ` J William Piggott
2017-01-07 20:32     ` J William Piggott
2017-01-07 23:06     ` Sami Kerola
2017-01-08  9:39       ` Sami Kerola [this message]
2017-01-08 21:21         ` J William Piggott
2017-01-08 10:09       ` Sami Kerola
2017-01-08 21:21         ` J William Piggott
2017-01-08 21:21       ` J William Piggott
2017-01-11 21:44         ` Sami Kerola
2017-01-13  1:30           ` J William Piggott
2017-01-14  9:34             ` Sami Kerola
2017-01-14 22:51               ` J William Piggott
2017-01-22 19:03                 ` J William Piggott
2017-01-25 21:54                   ` Sami Kerola
2017-01-27  2:07                     ` J William Piggott
2017-02-02 15:04                       ` [ping] Karel: " J William Piggott
2017-02-03 22:41                         ` Sami Kerola
2017-02-11 17:10                           ` J William Piggott
2017-02-04 18:47                         ` Karel Zak
2017-02-05 22:37                           ` Sami Kerola
2017-02-09 10:43                         ` Karel Zak
2017-02-09 11:09                         ` Karel Zak
2017-02-11 17:10                           ` J William Piggott
2017-01-09 11:32       ` Karel Zak
2017-01-09 13:53         ` J William Piggott
2017-01-09 20:48           ` Bjarni Ingi Gislason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG27Bk2Kg4MQFKSDwAxM849HJ7AxZWLX1vGL21qO042za=V1pw@mail.gmail.com' \
    --to=kerolasa@iki.fi \
    --cc=elseifthen@gmx.com \
    --cc=kerolasa@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.