linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maninder Singh <maninder1.s@samsung.com>
To: akpm@linux-foundation.org, herbert@gondor.apana.org.au,
	davem@davemloft.net, keescook@chromium.org,
	gustavo@embeddedor.com
Cc: joe@perches.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, a.sahrawat@samsung.com,
	pankaj.m@samsung.com, v.narang@samsung.com,
	Maninder Singh <maninder1.s@samsung.com>
Subject: [PATCH 4/4] zstd: change structure variable from int to char
Date: Mon,  3 Jun 2019 14:32:06 +0530	[thread overview]
Message-ID: <1559552526-4317-5-git-send-email-maninder1.s@samsung.com> (raw)
In-Reply-To: <1559552526-4317-1-git-send-email-maninder1.s@samsung.com>

Elements of ZSTD_frameParameters structure are used as flag, so
just declare them as char. ZSTD_frameParameters structure is used by
ZSTD_parameters.

Before:
======
sizeof(ZSTD_parameters)
$1 = 40

After:
=====
sizeof(ZSTD_parameters)
$1 = 32

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
---
 include/linux/zstd.h  | 6 +++---
 lib/zstd/compress.c   | 4 ++--
 lib/zstd/decompress.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/zstd.h b/include/linux/zstd.h
index 5103efa..a1e3483 100644
--- a/include/linux/zstd.h
+++ b/include/linux/zstd.h
@@ -164,9 +164,9 @@ typedef struct {
  * The default value is all fields set to 0.
  */
 typedef struct {
-	unsigned int contentSizeFlag;
-	unsigned int checksumFlag;
-	unsigned int noDictIDFlag;
+	unsigned char contentSizeFlag;
+	unsigned char checksumFlag;
+	unsigned char noDictIDFlag;
 } ZSTD_frameParameters;
 
 /**
diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
index 306e31b..7e0cea2 100644
--- a/lib/zstd/compress.c
+++ b/lib/zstd/compress.c
@@ -2435,9 +2435,9 @@ static size_t ZSTD_writeFrameHeader(void *dst, size_t dstCapacity, ZSTD_paramete
 {
 	BYTE *const op = (BYTE *)dst;
 	U32 const dictIDSizeCode = (dictID > 0) + (dictID >= 256) + (dictID >= 65536); /* 0-3 */
-	U32 const checksumFlag = params->fParams.checksumFlag > 0;
+	BYTE const checksumFlag = params->fParams.checksumFlag > 0;
 	U32 const windowSize = 1U << params->cParams.windowLog;
-	U32 const singleSegment = params->fParams.contentSizeFlag && (windowSize >= pledgedSrcSize);
+	BYTE const singleSegment = params->fParams.contentSizeFlag && (windowSize >= pledgedSrcSize);
 	BYTE const windowLogByte = (BYTE)((params->cParams.windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN) << 3);
 	U32 const fcsCode =
 	    params->fParams.contentSizeFlag ? (pledgedSrcSize >= 256) + (pledgedSrcSize >= 65536 + 256) + (pledgedSrcSize >= 0xFFFFFFFFU) : 0; /* 0-3 */
diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
index 269ee9a..7828264 100644
--- a/lib/zstd/decompress.c
+++ b/lib/zstd/decompress.c
@@ -233,7 +233,7 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
 		BYTE const fhdByte = ip[4];
 		size_t pos = 5;
 		U32 const dictIDSizeCode = fhdByte & 3;
-		U32 const checksumFlag = (fhdByte >> 2) & 1;
+		BYTE const checksumFlag = (fhdByte >> 2) & 1;
 		U32 const singleSegment = (fhdByte >> 5) & 1;
 		U32 const fcsID = fhdByte >> 6;
 		U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX;
-- 
2.7.4


  parent reply	other threads:[~2019-06-03  9:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190603090227epcas5p348327061a3facbb9dfcf662bf2bc196e@epcas5p3.samsung.com>
2019-06-03  9:02 ` [PATCH 0/4] zstd: reduce stack usage Maninder Singh
     [not found]   ` <CGME20190603090232epcas5p1630d0584e8a1aa9495edc819605664fc@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 1/4] zstd: pass pointer rathen than structure to functions Maninder Singh
2019-06-03 21:41       ` Andrew Morton
2019-06-04 22:43       ` Andrew Morton
2019-06-05 11:57         ` David Sterba
2019-06-05 12:32           ` David Sterba
2019-06-05 21:32             ` Andrew Morton
     [not found]       ` <CGME20190603090232epcas5p1630d0584e8a1aa9495edc819605664fc@epcms5p1>
2019-06-04 13:19         ` Vaneet Narang
2019-06-06 14:10         ` Vaneet Narang
2019-06-06 20:14           ` (2) " Nick Terrell
     [not found]   ` <CGME20190603090236epcas5p1bf0733024f7fb52f8129157b11c8f882@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 2/4] zstd: use U16 data type for rankPos Maninder Singh
     [not found]   ` <CGME20190603090240epcas5p17d0881686df3fa3042d0b2d659e925b3@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 3/4] zstd: move params structure to global variable to reduce stack usage Maninder Singh
2019-06-03 21:47       ` Andrew Morton
     [not found]   ` <CGME20190603090245epcas5p4a6cdfdb7ef72bfd36472f43bb4e1e0f1@epcas5p4.samsung.com>
2019-06-03  9:02     ` Maninder Singh [this message]
2019-06-03 21:49   ` [PATCH 0/4] zstd: " Andrew Morton
     [not found]   ` <CGME20190603090227epcas5p348327061a3facbb9dfcf662bf2bc196e@epcms5p3>
2019-06-04 12:06     ` Vaneet Narang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1559552526-4317-5-git-send-email-maninder1.s@samsung.com \
    --to=maninder1.s@samsung.com \
    --cc=a.sahrawat@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=gustavo@embeddedor.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.m@samsung.com \
    --cc=v.narang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).