2018-11-15 00:28:19

by Adeodato Simó

[permalink] [raw]
Subject: [PATCH 1/2] lib/zstd: mark several internal functions as static

This silences -Wmissing-prototypes.

Signed-off-by: Adeodato Simó <[email protected]>
---
It was suggested in the kernel-janitors mailing list that silencing
-Wmissing-prototypes would make for a worthy cause.

https://www.spinics.net/lists/linux-kernel-janitors/msg43981.html

I know the original commit for zstd says (73f3d1b48f50):

> We would like to avoid as much further manual modification to the
> source code as possible, so it will be easier to keep the kernel
> zstd up to date.

so you may have to help me figure out if this is worth doing at this
stage. (I hope it is!)

Thanks for considering.

lib/zstd/compress.c | 7 +++++--
lib/zstd/decompress.c | 10 +++++-----
lib/zstd/huf_compress.c | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
index f9166cf4f7a9..3eee699e1fd6 100644
--- a/lib/zstd/compress.c
+++ b/lib/zstd/compress.c
@@ -2249,7 +2249,10 @@ void ZSTD_compressBlock_lazy_extDict_generic(ZSTD_CCtx *ctx, const void *src, si
}
}

-void ZSTD_compressBlock_greedy_extDict(ZSTD_CCtx *ctx, const void *src, size_t srcSize) { ZSTD_compressBlock_lazy_extDict_generic(ctx, src, srcSize, 0, 0); }
+static void ZSTD_compressBlock_greedy_extDict(ZSTD_CCtx *ctx, const void *src, size_t srcSize)
+{
+ ZSTD_compressBlock_lazy_extDict_generic(ctx, src, srcSize, 0, 0);
+}

static void ZSTD_compressBlock_lazy_extDict(ZSTD_CCtx *ctx, const void *src, size_t srcSize)
{
@@ -2979,7 +2982,7 @@ size_t ZSTD_CStreamWorkspaceBound(ZSTD_compressionParameters cParams)
return ZSTD_CCtxWorkspaceBound(cParams) + ZSTD_ALIGN(sizeof(ZSTD_CStream)) + ZSTD_ALIGN(inBuffSize) + ZSTD_ALIGN(outBuffSize);
}

-ZSTD_CStream *ZSTD_createCStream_advanced(ZSTD_customMem customMem)
+static ZSTD_CStream *ZSTD_createCStream_advanced(ZSTD_customMem customMem)
{
ZSTD_CStream *zcs;

diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
index b17846725ca0..ead0292be308 100644
--- a/lib/zstd/decompress.c
+++ b/lib/zstd/decompress.c
@@ -123,7 +123,7 @@ size_t ZSTD_decompressBegin(ZSTD_DCtx *dctx)
return 0;
}

-ZSTD_DCtx *ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
+static ZSTD_DCtx *ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
{
ZSTD_DCtx *dctx;

@@ -391,7 +391,7 @@ typedef struct {

/*! ZSTD_getcBlockSize() :
* Provides the size of compressed block from block header `src` */
-size_t ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
+static size_t ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
{
if (srcSize < ZSTD_blockHeaderSize)
return ERROR(srcSize_wrong);
@@ -429,7 +429,7 @@ static size_t ZSTD_setRleBlock(void *dst, size_t dstCapacity, const void *src, s

/*! ZSTD_decodeLiteralsBlock() :
@return : nb of bytes read from src (< srcSize ) */
-size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
+static size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
{
if (srcSize < MIN_CBLOCK_SIZE)
return ERROR(corruption_detected);
@@ -791,7 +791,7 @@ static size_t ZSTD_buildSeqTable(FSE_DTable *DTableSpace, const FSE_DTable **DTa
}
}

-size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
+static size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
{
const BYTE *const istart = (const BYTE *const)src;
const BYTE *const iend = istart + srcSize;
@@ -1494,7 +1494,7 @@ size_t ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSiz
return blockSize;
}

-size_t ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length)
+static size_t ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length)
{
if (length > dstCapacity)
return ERROR(dstSize_tooSmall);
diff --git a/lib/zstd/huf_compress.c b/lib/zstd/huf_compress.c
index 40055a7016e6..1f4bc4b010c6 100644
--- a/lib/zstd/huf_compress.c
+++ b/lib/zstd/huf_compress.c
@@ -79,7 +79,7 @@ unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxS
* Note : all elements within weightTable are supposed to be <= HUF_TABLELOG_MAX.
*/
#define MAX_FSE_TABLELOG_FOR_HUFF_HEADER 6
-size_t HUF_compressWeights_wksp(void *dst, size_t dstSize, const void *weightTable, size_t wtSize, void *workspace, size_t workspaceSize)
+static size_t HUF_compressWeights_wksp(void *dst, size_t dstSize, const void *weightTable, size_t wtSize, void *workspace, size_t workspaceSize)
{
BYTE *const ostart = (BYTE *)dst;
BYTE *op = ostart;
--
2.19.1



2018-11-15 00:28:19

by Adeodato Simó

[permalink] [raw]
Subject: [PATCH 2/2] lib/zstd: mark some internal functions as static with ZSTD_STATIC

Use ZSTD_STATIC instead of vanilla static because the functions are
actually unused, and the macro adds the unused attribute.

This silences -Wmissing-prototypes when defining.

Signed-off-by: Adeodato Simó <[email protected]>
---
I separated these two functions into a separate patch because they
are actually unused.

If you'd rather have them removed, we may do that as well.

Note that the ZSTD_STATIC macro adds the unused attribute in addition
to static, but it adds __inline as well.

lib/zstd/compress.c | 2 +-
lib/zstd/fse_compress.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
index 3eee699e1fd6..c572d064775f 100644
--- a/lib/zstd/compress.c
+++ b/lib/zstd/compress.c
@@ -431,7 +431,7 @@ static void ZSTD_reduceIndex(ZSTD_CCtx *zc, const U32 reducerValue)

/* See doc/zstd_compression_format.md for detailed format description */

-size_t ZSTD_noCompressBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
+ZSTD_STATIC size_t ZSTD_noCompressBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
{
if (srcSize + ZSTD_blockHeaderSize > dstCapacity)
return ERROR(dstSize_tooSmall);
diff --git a/lib/zstd/fse_compress.c b/lib/zstd/fse_compress.c
index ef3d1741d532..05a148eabd09 100644
--- a/lib/zstd/fse_compress.c
+++ b/lib/zstd/fse_compress.c
@@ -474,7 +474,7 @@ size_t FSE_count_wksp(unsigned *count, unsigned *maxSymbolValuePtr, const void *
`FSE_symbolCompressionTransform symbolTT[maxSymbolValue+1];` // This size is variable
Allocation is manual (C standard does not support variable-size structures).
*/
-size_t FSE_sizeof_CTable(unsigned maxSymbolValue, unsigned tableLog)
+ZSTD_STATIC size_t FSE_sizeof_CTable(unsigned maxSymbolValue, unsigned tableLog)
{
if (tableLog > FSE_MAX_TABLELOG)
return ERROR(tableLog_tooLarge);
--
2.19.1