All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: avoid possible overflow?
Date: Tue, 16 Feb 2010 13:46:53 +0100	[thread overview]
Message-ID: <4B7A93BD.9010607@gmail.com> (raw)
In-Reply-To: <20100214000510.GA10702@pina.cat>

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

Carles Pina i Estany wrote:
> Hello,
>
> The common pattern when doing a search by bisection is something like:
> +      current = min + (max - min) / 2;
>
> Instead of the first natural idea:
> -      current = (max + min) / 2;
>
> To avoid overflows.
>
> In gettext/gettext.c it's used in the "incorrect" way. It's not a big
> problem since would happen only with .mo files with lot of strings, like
> number that int represents in that architecture divided by 2 (aprox
> aprox.).
>
> See the attached file for a patch if we want to patch.
>   
You forgot to make the same change before the loop. But actually it
doesn't matter because overflow in this statement:
  internal_position = offsettranslation + position * 8;
is reached well before the overflow in bisecting. Anyway this
mattersonly for >4GiB files and unless we put videos in .po I don't see
how this limit would be reached. So I prefer readability and would
reject this patch.
> Else I would at least add a comment that we simplified because we
> consider that will not happen.
>
> Thanks,
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

  reply	other threads:[~2010-02-16 12:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14  0:05 avoid possible overflow? Carles Pina i Estany
2010-02-16 12:46 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-02-16 13:31   ` richardvoigt

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=4B7A93BD.9010607@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.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.