Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: pcomp - Constify (de)compression parameters

In testmgr, struct pcomp_testvec takes a non-const 'params' field, which is
pointed to a const deflate_comp_params or deflate_decomp_params object. With
gcc-5 this incurs the following warnings:

In file included from ../crypto/testmgr.c:44:0:
../crypto/testmgr.h:28736:13: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
.params = &deflate_comp_params,
^
../crypto/testmgr.h:28748:13: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
.params = &deflate_comp_params,
^
../crypto/testmgr.h:28776:13: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
.params = &deflate_decomp_params,
^
../crypto/testmgr.h:28800:13: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
.params = &deflate_decomp_params,
^

Fix this by making the parameters pointer const and constifying the things
that use it.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

David Howells and committed by
Herbert Xu
f94a3597 dcd93e83

+7 -7
+1 -1
crypto/testmgr.h
··· 28591 28591 }; 28592 28592 28593 28593 struct pcomp_testvec { 28594 - void *params; 28594 + const void *params; 28595 28595 unsigned int paramsize; 28596 28596 int inlen, outlen; 28597 28597 char input[COMP_BUF_SIZE];
+2 -2
crypto/zlib.c
··· 78 78 } 79 79 80 80 81 - static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params, 81 + static int zlib_compress_setup(struct crypto_pcomp *tfm, const void *params, 82 82 unsigned int len) 83 83 { 84 84 struct zlib_ctx *ctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm)); ··· 209 209 } 210 210 211 211 212 - static int zlib_decompress_setup(struct crypto_pcomp *tfm, void *params, 212 + static int zlib_decompress_setup(struct crypto_pcomp *tfm, const void *params, 213 213 unsigned int len) 214 214 { 215 215 struct zlib_ctx *ctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
+4 -4
include/crypto/compress.h
··· 55 55 }; 56 56 57 57 struct pcomp_alg { 58 - int (*compress_setup)(struct crypto_pcomp *tfm, void *params, 58 + int (*compress_setup)(struct crypto_pcomp *tfm, const void *params, 59 59 unsigned int len); 60 60 int (*compress_init)(struct crypto_pcomp *tfm); 61 61 int (*compress_update)(struct crypto_pcomp *tfm, 62 62 struct comp_request *req); 63 63 int (*compress_final)(struct crypto_pcomp *tfm, 64 64 struct comp_request *req); 65 - int (*decompress_setup)(struct crypto_pcomp *tfm, void *params, 65 + int (*decompress_setup)(struct crypto_pcomp *tfm, const void *params, 66 66 unsigned int len); 67 67 int (*decompress_init)(struct crypto_pcomp *tfm); 68 68 int (*decompress_update)(struct crypto_pcomp *tfm, ··· 97 97 } 98 98 99 99 static inline int crypto_compress_setup(struct crypto_pcomp *tfm, 100 - void *params, unsigned int len) 100 + const void *params, unsigned int len) 101 101 { 102 102 return crypto_pcomp_alg(tfm)->compress_setup(tfm, params, len); 103 103 } ··· 120 120 } 121 121 122 122 static inline int crypto_decompress_setup(struct crypto_pcomp *tfm, 123 - void *params, unsigned int len) 123 + const void *params, unsigned int len) 124 124 { 125 125 return crypto_pcomp_alg(tfm)->decompress_setup(tfm, params, len); 126 126 }