Skip to content

Commit 1a263ae

Browse files
committed
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 <[email protected]>
1 parent adc7192 commit 1a263ae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crypto/lrw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
287287
crypto_free_skcipher(ctx->child);
288288
}
289289

290-
static void free(struct skcipher_instance *inst)
290+
static void free_inst(struct skcipher_instance *inst)
291291
{
292292
crypto_drop_skcipher(skcipher_instance_ctx(inst));
293293
kfree(inst);
@@ -400,12 +400,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
400400
inst->alg.encrypt = encrypt;
401401
inst->alg.decrypt = decrypt;
402402

403-
inst->free = free;
403+
inst->free = free_inst;
404404

405405
err = skcipher_register_instance(tmpl, inst);
406406
if (err) {
407407
err_free_inst:
408-
free(inst);
408+
free_inst(inst);
409409
}
410410
return err;
411411
}

crypto/xts.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
322322
crypto_free_cipher(ctx->tweak);
323323
}
324324

325-
static void free(struct skcipher_instance *inst)
325+
static void free_inst(struct skcipher_instance *inst)
326326
{
327327
crypto_drop_skcipher(skcipher_instance_ctx(inst));
328328
kfree(inst);
@@ -434,12 +434,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
434434
inst->alg.encrypt = encrypt;
435435
inst->alg.decrypt = decrypt;
436436

437-
inst->free = free;
437+
inst->free = free_inst;
438438

439439
err = skcipher_register_instance(tmpl, inst);
440440
if (err) {
441441
err_free_inst:
442-
free(inst);
442+
free_inst(inst);
443443
}
444444
return err;
445445
}

0 commit comments

Comments
 (0)