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

Configure Feed

Select the types of activity you want to include in your feed.

gcc-10: avoid shadowing standard library 'free()' in crypto

gcc-10 has started warning about conflicting types for a few new
built-in functions, particularly 'free()'.

This results in warnings like:

crypto/xts.c:325:13: warning: conflicting types for built-in function ‘free’; expected ‘void(void *)’ [-Wbuiltin-declaration-mismatch]

because the crypto layer had its local freeing functions called
'free()'.

Gcc-10 is in the wrong here, since that function is marked 'static', and
thus there is no chance of confusion with any standard library function
namespace.

But the simplest thing to do is to just use a different name here, and
avoid this gcc mis-feature.

[ Side note: gcc knowing about 'free()' is in itself not the
mis-feature: the semantics of 'free()' are special enough that a
compiler can validly do special things when seeing it.

So the mis-feature here is that gcc thinks that 'free()' is some
restricted name, and you can't shadow it as a local static function.

Making the special 'free()' semantics be a function attribute rather
than tied to the name would be the much better model ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+6 -6
+3 -3
crypto/lrw.c
··· 287 287 crypto_free_skcipher(ctx->child); 288 288 } 289 289 290 - static void free(struct skcipher_instance *inst) 290 + static void free_inst(struct skcipher_instance *inst) 291 291 { 292 292 crypto_drop_skcipher(skcipher_instance_ctx(inst)); 293 293 kfree(inst); ··· 400 400 inst->alg.encrypt = encrypt; 401 401 inst->alg.decrypt = decrypt; 402 402 403 - inst->free = free; 403 + inst->free = free_inst; 404 404 405 405 err = skcipher_register_instance(tmpl, inst); 406 406 if (err) { 407 407 err_free_inst: 408 - free(inst); 408 + free_inst(inst); 409 409 } 410 410 return err; 411 411 }
+3 -3
crypto/xts.c
··· 322 322 crypto_free_cipher(ctx->tweak); 323 323 } 324 324 325 - static void free(struct skcipher_instance *inst) 325 + static void free_inst(struct skcipher_instance *inst) 326 326 { 327 327 crypto_drop_skcipher(skcipher_instance_ctx(inst)); 328 328 kfree(inst); ··· 434 434 inst->alg.encrypt = encrypt; 435 435 inst->alg.decrypt = decrypt; 436 436 437 - inst->free = free; 437 + inst->free = free_inst; 438 438 439 439 err = skcipher_register_instance(tmpl, inst); 440 440 if (err) { 441 441 err_free_inst: 442 - free(inst); 442 + free_inst(inst); 443 443 } 444 444 return err; 445 445 }