Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1402907 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2016-05-18 14:10 +0200 |
| Last post | 2016-05-21 01:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] pstore: Cleanup pstore_dump() Namhyung Kim <namhyung@kernel.org> - 2016-05-18 14:10 +0200
Re: [PATCH 2/2] pstore: Cleanup pstore_dump() Kees Cook <keescook@chromium.org> - 2016-05-21 01:10 +0200
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-05-18 14:10 +0200 |
| Subject | [PATCH 2/2] pstore: Cleanup pstore_dump() |
| Message-ID | <rA8sy-1WF-15@gated-at.bofh.it> |
The code is duplicate between compression is enabled or not.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
fs/pstore/platform.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 04a0164a2066..277730f6c462 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -304,19 +304,25 @@ static void pstore_dump(struct kmsg_dumper *dumper,
int hsize;
int zipped_len = -1;
size_t len;
- bool compressed;
+ bool compressed = false;
size_t total_len;
if (big_oops_buf && is_locked) {
dst = big_oops_buf;
- hsize = sprintf(dst, "%s#%d Part%u\n", why,
- oopscount, part);
- size = big_oops_buf_sz - hsize;
+ size = big_oops_buf_sz;
+ } else {
+ dst = psinfo->buf;
+ size = psinfo->bufsize;
+ }
- if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
- size, &len))
- break;
+ hsize = sprintf(dst, "%s#%d Part%u\n", why, oopscount, part);
+ size -= hsize;
+
+ if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
+ size, &len))
+ break;
+ if (big_oops_buf && is_locked) {
zipped_len = pstore_compress(dst, psinfo->buf,
hsize + len, psinfo->bufsize);
@@ -324,21 +330,9 @@ static void pstore_dump(struct kmsg_dumper *dumper,
compressed = true;
total_len = zipped_len;
} else {
- compressed = false;
total_len = copy_kmsg_to_buffer(hsize, len);
}
} else {
- dst = psinfo->buf;
- hsize = sprintf(dst, "%s#%d Part%u\n", why, oopscount,
- part);
- size = psinfo->bufsize - hsize;
- dst += hsize;
-
- if (!kmsg_dump_get_buffer(dumper, true, dst,
- size, &len))
- break;
-
- compressed = false;
total_len = hsize + len;
}
--
2.8.0
[toc] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-05-21 01:10 +0200 |
| Message-ID | <rB1Im-3UX-9@gated-at.bofh.it> |
| In reply to | #1402907 |
On Wed, May 18, 2016 at 5:00 AM, Namhyung Kim <namhyung@kernel.org> wrote:
> The code is duplicate between compression is enabled or not.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> fs/pstore/platform.c | 32 +++++++++++++-------------------
> 1 file changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 04a0164a2066..277730f6c462 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -304,19 +304,25 @@ static void pstore_dump(struct kmsg_dumper *dumper,
> int hsize;
> int zipped_len = -1;
> size_t len;
> - bool compressed;
> + bool compressed = false;
> size_t total_len;
>
> if (big_oops_buf && is_locked) {
> dst = big_oops_buf;
> - hsize = sprintf(dst, "%s#%d Part%u\n", why,
> - oopscount, part);
> - size = big_oops_buf_sz - hsize;
> + size = big_oops_buf_sz;
> + } else {
> + dst = psinfo->buf;
> + size = psinfo->bufsize;
> + }
>
> - if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
> - size, &len))
> - break;
> + hsize = sprintf(dst, "%s#%d Part%u\n", why, oopscount, part);
> + size -= hsize;
> +
> + if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
> + size, &len))
> + break;
>
> + if (big_oops_buf && is_locked) {
> zipped_len = pstore_compress(dst, psinfo->buf,
> hsize + len, psinfo->bufsize);
>
> @@ -324,21 +330,9 @@ static void pstore_dump(struct kmsg_dumper *dumper,
> compressed = true;
> total_len = zipped_len;
> } else {
> - compressed = false;
> total_len = copy_kmsg_to_buffer(hsize, len);
> }
> } else {
> - dst = psinfo->buf;
> - hsize = sprintf(dst, "%s#%d Part%u\n", why, oopscount,
> - part);
> - size = psinfo->bufsize - hsize;
> - dst += hsize;
> -
> - if (!kmsg_dump_get_buffer(dumper, true, dst,
> - size, &len))
> - break;
> -
> - compressed = false;
> total_len = hsize + len;
> }
>
> --
> 2.8.0
>
Nice cleanup, thanks! Applied.
-Kees
--
Kees Cook
Chrome OS & Brillo Security
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web