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>
This commit is contained in:
parent
98e44fda2e
commit
235f6d157d
|
@ -306,19 +306,25 @@ static void pstore_dump(struct kmsg_dumper *dumper,
|
||||||
int hsize;
|
int hsize;
|
||||||
int zipped_len = -1;
|
int zipped_len = -1;
|
||||||
size_t len;
|
size_t len;
|
||||||
bool compressed;
|
bool compressed = false;
|
||||||
size_t total_len;
|
size_t total_len;
|
||||||
|
|
||||||
if (big_oops_buf && is_locked) {
|
if (big_oops_buf && is_locked) {
|
||||||
dst = big_oops_buf;
|
dst = big_oops_buf;
|
||||||
hsize = sprintf(dst, "%s#%d Part%u\n", why,
|
size = big_oops_buf_sz;
|
||||||
oopscount, part);
|
} else {
|
||||||
size = big_oops_buf_sz - hsize;
|
dst = psinfo->buf;
|
||||||
|
size = psinfo->bufsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
hsize = sprintf(dst, "%s#%d Part%u\n", why, oopscount, part);
|
||||||
|
size -= hsize;
|
||||||
|
|
||||||
if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
|
if (!kmsg_dump_get_buffer(dumper, true, dst + hsize,
|
||||||
size, &len))
|
size, &len))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (big_oops_buf && is_locked) {
|
||||||
zipped_len = pstore_compress(dst, psinfo->buf,
|
zipped_len = pstore_compress(dst, psinfo->buf,
|
||||||
hsize + len, psinfo->bufsize);
|
hsize + len, psinfo->bufsize);
|
||||||
|
|
||||||
|
@ -326,21 +332,9 @@ static void pstore_dump(struct kmsg_dumper *dumper,
|
||||||
compressed = true;
|
compressed = true;
|
||||||
total_len = zipped_len;
|
total_len = zipped_len;
|
||||||
} else {
|
} else {
|
||||||
compressed = false;
|
|
||||||
total_len = copy_kmsg_to_buffer(hsize, len);
|
total_len = copy_kmsg_to_buffer(hsize, len);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
total_len = hsize + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue