Skip to content

Commit

Permalink
pstore: Cleanup pstore_dump()
Browse files Browse the repository at this point in the history
The code is duplicate between compression is enabled or not.

Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
namhyung authored and kees committed May 31, 2016
1 parent 98e44fd commit 235f6d1
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,41 +306,35 @@ 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);

if (zipped_len > 0) {
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;
}

Expand Down

0 comments on commit 235f6d1

Please sign in to comment.