From: Andreas Gruenbacher <agruen@suse.de>
To: git@vger.kernel.org
Cc: Andreas Gruenbacher <agruen@suse.de>
Subject: [PATCH 3/3] base85: Make the code more obvious instead of explaining the non-obvious
Date: Fri, 8 Jan 2010 14:40:00 +0100 [thread overview]
Message-ID: <1262958000-27181-3-git-send-email-agruen@suse.de> (raw)
In-Reply-To: <alpine.LFD.2.00.1001071253400.21025@xanadu.home>
Here is another cleanup ...
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
base85.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/base85.c b/base85.c
index 7204ce2..e459fee 100644
--- a/base85.c
+++ b/base85.c
@@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len)
de = de85[ch];
if (--de < 0)
return error("invalid base85 alphabet %c", ch);
- /*
- * Detect overflow. The largest
- * 5-letter possible is "|NsC0" to
- * encode 0xffffffff, and "|NsC" gives
- * 0x03030303 at this point (i.e.
- * 0xffffffff = 0x03030303 * 85).
- */
- if (0x03030303 < acc ||
+ /* Detect overflow. */
+ if (0xffffffff / 85 < acc ||
0xffffffff - de < (acc *= 85))
return error("invalid base85 sequence %.5s", buffer-5);
acc += de;
--
1.6.6.75.g37bae
next prev parent reply other threads:[~2010-01-08 13:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-07 14:58 base85: Two tiny fixes Andreas Gruenbacher
2010-01-07 17:58 ` Nicolas Pitre
2010-01-08 13:02 ` Andreas Gruenbacher
2010-01-08 13:39 ` [PATCH 1/3] base85 debug code: Fix length byte calculation Andreas Gruenbacher
2010-01-08 13:39 ` [PATCH 2/3] base85: No need to initialize the decode table in encode_85 Andreas Gruenbacher
2010-01-08 15:46 ` Michael J Gruber
2010-01-08 15:55 ` Junio C Hamano
2010-01-08 16:17 ` [PATCH] base85: encode85() does not use the decode table Andreas Gruenbacher
2010-01-08 16:22 ` [PATCH] base85: encode_85() " Andreas Gruenbacher
2010-01-08 13:40 ` Andreas Gruenbacher [this message]
2010-01-08 23:15 ` [PATCH 3/3] base85: Make the code more obvious instead of explaining the non-obvious A Large Angry SCM
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=1262958000-27181-3-git-send-email-agruen@suse.de \
--to=agruen@suse.de \
--cc=git@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 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).