From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753064AbcERMAt (ORCPT ); Wed, 18 May 2016 08:00:49 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35773 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752952AbcERMAc (ORCPT ); Wed, 18 May 2016 08:00:32 -0400 From: Namhyung Kim To: Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck Cc: LKML Subject: [PATCH 2/2] pstore: Cleanup pstore_dump() Date: Wed, 18 May 2016 21:00:06 +0900 Message-Id: <1463572806-16194-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1463572806-16194-1-git-send-email-namhyung@kernel.org> References: <1463572806-16194-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code is duplicate between compression is enabled or not. Signed-off-by: Namhyung Kim --- 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