From: David Sterba <dsterba@suse.cz>
To: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Russell King <linux@arm.linux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Michal Marek <mmarek@suse.cz>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
x86@kernel.org, celinux-dev@lists.celinuxforum.org,
Nicolas Pitre <nico@fluxnic.net>,
Nitin Gupta <nitingupta910@gmail.com>,
"Markus F.X.J. Oberhumer" <markus@oberhumer.com>,
Richard Purdie <rpurdie@openedhand.com>,
Josh Triplett <josh@joshtriplett.org>,
Joe Millenbach <jmillenbach@gmail.com>,
David Sterba <dsterba@suse.cz>,
Richard Cochran <richardcochran@gmail.com>,
Albin Tonnerre <albin.tonnerre@free-electrons.com>,
Egon Alter <egon.alter@gmx.net>,
hyojun.im@lge.com, chan.jeong@lge.com,
raphael.andy.lee@gmail.com
Subject: Re: [RFC PATCH v2 1/4] decompressor: Add LZ4 decompressor module
Date: Tue, 26 Feb 2013 14:12:06 +0100 [thread overview]
Message-ID: <20130226131206.GW27541@twin.jikos.cz> (raw)
In-Reply-To: <1361859870-15751-2-git-send-email-kyungsik.lee@lge.com>
On Tue, Feb 26, 2013 at 03:24:27PM +0900, Kyungsik Lee wrote:
> This patch adds support for LZ4 decompression in the Linux Kernel.
> LZ4 Decompression APIs for kernel are based on LZ4 implementation
> by Yann Collet.
>
> LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
> LZ4 source repository : http://code.google.com/p/lz4/
What SVN version did you use?
> --- /dev/null
> +++ b/include/linux/lz4.h
> @@ -0,0 +1,48 @@
> +#ifndef __LZ4_H__
> +#define __LZ4_H__
> +/*
> + * LZ4 Kernel Interface
> + *
> + * Copyright (C) 2013, LG Electronics, Kyungsik Lee <kyungsik.lee@lge.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +/*
> + * LZ4_COMPRESSBOUND()
> + * Provides the maximum size that LZ4 may output in a "worst case" scenario
> + * (input data not compressible)
> + */
> +#define LZ4_COMPRESSBOUND(isize) (isize + ((isize)/255) + 16)
For safety reasons I suggest to add a temporary variable to avoid double
evaluation of isize.
> --- /dev/null
> +++ b/lib/lz4/lz4_decompress.c
> + }
> + cpy = op + length - (STEPSIZE - 4);
> + if (cpy > oend - COPYLENGTH) {
> +
> + /* Error: request to write beyond destination buffer */
> + if (cpy > oend)
> + goto _output_error;
> + LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
> + while (op < cpy)
> + *op++ = *ref++;
> + op = cpy;
> + /*
> + * Check EOF (should never happen, since last 5 bytes
> + * are supposed to be literals)
> + */
> + if (op == oend)
> + goto _output_error;
> + continue;
> + }
> + LZ4_SECURECOPY(ref, op, cpy);
> + op = cpy; /* correction */
> + }
Does this compile? The } is an extra one, and does not match the
original sources.
> + /* end of decoding */
> + return (int) (((char *)ip) - source);
> +
> + /* write overflow error detected */
> +_output_error:
> + return (int) (-(((char *)ip) - source));
> +}
> +
> --- /dev/null
> +++ b/lib/lz4/lz4defs.h
> @@ -0,0 +1,93 @@
> +#define LZ4_COPYSTEP(s, d) \
> + do { \
> + PUT8(s, d); \
> + d += 8; \
> + s += 8; \
> + } while (0)
> +
> +#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d)
> +
> +#define LZ4_SECURECOPY(s, d, e) \
> + do { \
> + if (d < e) { \
> + LZ4_WILDCOPY(s, d, e); \
> + } \
> + } while (0)
> +
> +#else /* 32-bit */
> +#define STEPSIZE 4
> +
> +#define LZ4_COPYSTEP(s, d) \
> + do { \
> + PUT4(s, d); \
> + d += 4; \
> + s += 4; \
> + } while (0)
> +
> +#define LZ4_COPYPACKET(s, d) \
> + do { \
> + LZ4_COPYSTEP(s, d); \
> + LZ4_COPYSTEP(s, d); \
> + } while (0)
> +
> +#define LZ4_SECURECOPY LZ4_WILDCOPY
> +#endif
> +
> +#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
> + (d = s - get_unaligned_le16(p))
> +#define LZ4_WILDCOPY(s, d, e) \
> + do { \
> + LZ4_COPYPACKET(s, d); \
> + } while (d < e)
All the \ at the ends of lines would look better aligned in one column.
david
next prev parent reply other threads:[~2013-02-26 13:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-26 6:24 [RFC PATCH v2 0/4] Add support for LZ4-compressed kernel Kyungsik Lee
2013-02-26 6:24 ` [RFC PATCH v2 1/4] decompressor: Add LZ4 decompressor module Kyungsik Lee
2013-02-26 13:12 ` David Sterba [this message]
2013-02-27 4:38 ` Kyungsik Lee
2013-02-26 6:24 ` [RFC PATCH v2 2/4] lib: Add support for LZ4-compressed kernel Kyungsik Lee
2013-02-26 14:00 ` David Sterba
2013-02-28 5:22 ` Kyungsik Lee
2013-02-26 6:24 ` [RFC PATCH v2 3/4] arm: " Kyungsik Lee
2013-02-26 6:24 ` [RFC PATCH v2 4/4] x86: " Kyungsik Lee
2013-02-26 20:33 ` [RFC PATCH v2 0/4] " Markus F.X.J. Oberhumer
2013-02-26 20:59 ` Nicolas Pitre
2013-02-26 21:58 ` Peter Korsgaard
2013-02-26 22:09 ` Nicolas Pitre
2013-02-26 22:10 ` Russell King - ARM Linux
2013-02-27 1:40 ` Joe Perches
2013-02-27 9:56 ` Russell King - ARM Linux
2013-02-27 15:49 ` Joe Perches
2013-02-27 16:08 ` Nicolas Pitre
2013-02-27 16:31 ` Russell King - ARM Linux
2013-02-27 16:53 ` Borislav Petkov
2013-02-27 17:04 ` Joe Perches
2013-02-27 17:16 ` Nicolas Pitre
2013-02-27 17:39 ` Joe Perches
2013-02-27 17:52 ` Nicolas Pitre
2013-02-27 17:57 ` Russell King - ARM Linux
2013-02-27 17:36 ` Russell King - ARM Linux
2013-02-28 4:22 ` Joe Perches
2013-02-27 7:36 ` Kyungsik Lee
2013-02-27 9:51 ` Russell King - ARM Linux
2013-02-27 10:20 ` Johannes Stezenbach
2013-02-27 15:35 ` Nicolas Pitre
2013-02-27 13:23 ` Kyungsik Lee
2013-02-27 22:21 ` Andrew Morton
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=20130226131206.GW27541@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=albin.tonnerre@free-electrons.com \
--cc=celinux-dev@lists.celinuxforum.org \
--cc=chan.jeong@lge.com \
--cc=egon.alter@gmx.net \
--cc=hpa@zytor.com \
--cc=hyojun.im@lge.com \
--cc=jmillenbach@gmail.com \
--cc=josh@joshtriplett.org \
--cc=kyungsik.lee@lge.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=markus@oberhumer.com \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=nico@fluxnic.net \
--cc=nitingupta910@gmail.com \
--cc=raphael.andy.lee@gmail.com \
--cc=richardcochran@gmail.com \
--cc=rpurdie@openedhand.com \
--cc=tglx@linutronix.de \
--cc=x86@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).