Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 77B96431FB6 for ; Thu, 14 Jun 2012 02:43:29 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AujDY1loonF7 for ; Thu, 14 Jun 2012 02:43:28 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id D233C431FAE for ; Thu, 14 Jun 2012 02:43:27 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 352581000D0; Thu, 14 Jun 2012 12:43:37 +0300 (EEST) From: Tomi Ollila To: Jesse Rosenthal , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: derive correct timestamp in FCC unique name In-Reply-To: <87d353ezyw.fsf@jhu.edu> References: <87d353ezyw.fsf@jhu.edu> User-Agent: Notmuch/0.13.2+7~g2fb5bbc (http://notmuchmail.org) Emacs/23.1.1 (x86_64-redhat-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 09:43:29 -0000 On Wed, Jun 13 2012, Jesse Rosenthal wrote: > Previously, the timestamp at the beginning of the FCC maildir unique > maildir name was derived incorrectly, thanks to an integer > overflow. This changes the derivation of timestamp to float > arithmetic, and so gets the number correct. (It is still formatted > with "%d" so it will show up as an integer.) > > This change is mostly a question of consistency, since the unique name > is arbitrary anyway. But since most people use timestamps, and that was > the original intention here as well, we might as well. > > Signed-off-by: Jesse Rosenthal > --- Good point -- did some experiments (on 32bit machine, on 64 (* 65536 *65536) just works OK (4294967296). (insert (format " %d" (* 8191 65536))) 536805376 (insert (format " %d" (* 8192 65536))) -536870912 Wraps now (many times already) (insert (format " %d" (* 32767 65536.0))) 2147418112 (insert (format " %d" (* 32768 65536.0))) -2147483648 Wraps Tue Jan 19 03:14:08 2038 UTC (insert (format " %0.f" (* 32768 65536.0))) 2147483648 (insert (format " %0.f" (* 65536 65536.0))) 4294967296 Does not wrap. On emacs window you can re-experiment by typing C-x C-e after last closing ')' on line. (float-time '(32767 65536)) -> 2147418112.0 (minibuffer output) (float-time '(32768 65536)) -> error "Invalid time specification" On 64-bit machine this latest work ok; i.e 2147483648.0 is returned. Alternatives: 1) Use current patch, filenames will have extra '-' in 2038 on 32-bit systems. 2) Drop 'timeid' and replace it with (float-time) in `format` call a few lines in original source after the patch context below -- No idea how (float-time) works on 32-bit systems after 2038. 3) Use "%0.f" in format string instead of "%d" (there is no "%ld" or "%u" sequences for `format`. I wonder what (current-time-string) in current emacs return in 2038 (maybe I test (sometime(tm)) with (lib)faketime). I suggest option #2. Tomi > emacs/notmuch-maildir-fcc.el | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el > index dcfbc4b..6fd8ff9 100644 > --- a/emacs/notmuch-maildir-fcc.el > +++ b/emacs/notmuch-maildir-fcc.el > @@ -141,7 +141,7 @@ will NOT be removed or replaced." > > (defun notmuch-maildir-fcc-make-uniq-maildir-id () > (let* ((ct (current-time)) > - (timeid (+ (* (car ct) 65536) (cadr ct))) > + (timeid (+ (* (car ct) 65536.0) (cadr ct))) > (microseconds (car (cdr (cdr ct)))) > (hostname (notmuch-maildir-fcc-host-fixer system-name))) > (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1)) > -- > 1.7.9.5