summaryrefslogtreecommitdiffstats
path: root/fs/pstore
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-05-18 21:00:06 +0900
committerKees Cook <keescook@chromium.org>2016-05-31 12:36:45 -0700
commit235f6d157d43a761052e643b8799f86fdc87b47f (patch)
treeb338ce1083c8b16e11351b27f00c31358387c8eb /fs/pstore
parent98e44fda2ea19c0e8b0a2e0e4dcd3461251f09ea (diff)
downloadlinux-235f6d157d43a761052e643b8799f86fdc87b47f.tar.bz2
pstore: Cleanup pstore_dump()
The code is duplicate between compression is enabled or not. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/platform.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index ad8ef2298047..fe41d8ec663a 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -306,19 +306,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);
@@ -326,21 +332,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;
}