mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
- remove headers_{install,check}_all targets
- remove unreasonable 'depends on !UML' from CONFIG_SAMPLES
- re-implement 'make headers_install' more cleanly
- add new header-test-y syntax to compile-test headers
- compile-test exported headers to ensure they are compilable in
user-space
- compile-test headers under include/ to ensure they are self-contained
- remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value flags
- add -Werror=unknown-warning-option for Clang
- add 128-bit built-in types support to genksyms
- fix missed rebuild of modules.builtin
- propagate 'No space left on device' error in fixdep to Make
- allow Clang to use its integrated assembler
- improve some coccinelle scripts
- add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
path for $(srctree).
- do not ignore errors when compression utility is missing
- misc cleanups
-----BEGIN PGP SIGNATURE-----
iQJSBAABCgA8FiEEbmPs18K1szRHjPqEPYsBB53g2wYFAl0oxNkeHHlhbWFkYS5t
YXNhaGlyb0Bzb2Npb25leHQuY29tAAoJED2LAQed4NsGnhcP/AuM8s+3SYFiLitJ
ISbznLFP2Xatq0SPXp5+moez/AMTK6Mm1biPcdo20d+TjVEh4+9F2nq12Ii9U8/D
tds9A6G8+Bb28r9GMIVQPdFohijW6ijtDziS31iQnIWyPsP/yx6PKfLAD9F4ca1x
7/4btmu+BOMjtN0NrMWSNz5MM47xUzoWIALL40SV4PzGVXLCQZ2PBNPeSRIk22Jt
ynDNPuNsmDWcFfwAE+sLSDrhCHZlwM8rg8rf6jmYdc4LcN4cj0oho5+K1TRyC9mn
fO3PT25juFejthxQulxEfyGggnyLM6BNTgPDGcCHSP4nD7mlXA9GcpZICtJOgGGu
SlDadMZ0GRMK5zcZ0MF0GQboeyViwsbXgrRcYuXt6cUFWX4P/1SeAQ5Mf4u1EKqf
hEbwFXV/g81ht0lFS8gyWkvdpoNPtxGHNPusLjp65C4rc0/48/s+7EE/u8JTPl1g
dQTeIOds6XUOkJgqhEfuq+8gfngbjKc9bYhs+ACbkCzBltQdnb6m5aLgk0ODxe8I
WbGn0+cQcS9VVwre7E5DnFSVWVOHAG5taiUwj0KDcHB0Jxw9Gvorq9WU1ppHHYH2
XQIFBx7XHdn28d+plS8R23vAPgDgrGdvE5RYK5tNQLhTJ6BbjlZ1n/Tmxzu62scK
deG3aCOB13Om7OTzTUh9+C3TC9ZQ
=E2Rz
-----END PGP SIGNATURE-----
Merge tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada:
- remove headers_{install,check}_all targets
- remove unreasonable 'depends on !UML' from CONFIG_SAMPLES
- re-implement 'make headers_install' more cleanly
- add new header-test-y syntax to compile-test headers
- compile-test exported headers to ensure they are compilable in
user-space
- compile-test headers under include/ to ensure they are self-contained
- remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value
flags
- add -Werror=unknown-warning-option for Clang
- add 128-bit built-in types support to genksyms
- fix missed rebuild of modules.builtin
- propagate 'No space left on device' error in fixdep to Make
- allow Clang to use its integrated assembler
- improve some coccinelle scripts
- add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
path for $(srctree).
- do not ignore errors when compression utility is missing
- misc cleanups
* tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits)
kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix
kbuild: Inform user to pass ARCH= for make mrproper
kbuild: fix compression errors getting ignored
kbuild: add a flag to force absolute path for srctree
kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
kbuild: remove src and obj from the top Makefile
scripts/tags.sh: remove unused environment variables from comments
scripts/tags.sh: drop SUBARCH support for ARM
kbuild: compile-test kernel headers to ensure they are self-contained
kheaders: include only headers into kheaders_data.tar.xz
kheaders: remove meaningless -R option of 'ls'
kbuild: support header-test-pattern-y
kbuild: do not create wrappers for header-test-y
kbuild: compile-test exported headers to ensure they are self-contained
init/Kconfig: add CONFIG_CC_CAN_LINK
kallsyms: exclude kasan local symbols on s390
kbuild: add more hints about SUBDIRS replacement
coccinelle: api/stream_open: treat all wait_.*() calls as blocking
coccinelle: put_device: Add a cast to an expression for an assignment
coccinelle: put_device: Adjust a message construction
...
106 lines
2.4 KiB
Plaintext
106 lines
2.4 KiB
Plaintext
// SPDX-License-Identifier: GPL-2.0-only
|
|
/// Use kstrdup rather than duplicating its implementation
|
|
///
|
|
// Confidence: High
|
|
// Copyright: (C) 2010-2012 Nicolas Palix.
|
|
// Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
|
|
// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
|
|
// URL: http://coccinelle.lip6.fr/
|
|
// Comments:
|
|
// Options: --no-includes --include-headers
|
|
|
|
virtual patch
|
|
virtual context
|
|
virtual org
|
|
virtual report
|
|
|
|
@depends on patch@
|
|
expression from,to;
|
|
expression flag,E1,E2;
|
|
statement S;
|
|
@@
|
|
|
|
- to = kmalloc(strlen(from) + 1,flag);
|
|
+ to = kstrdup(from, flag);
|
|
... when != \(from = E1 \| to = E1 \)
|
|
if (to==NULL || ...) S
|
|
... when != \(from = E2 \| to = E2 \)
|
|
- strcpy(to, from);
|
|
|
|
@depends on patch@
|
|
expression x,from,to;
|
|
expression flag,E1,E2,E3;
|
|
statement S;
|
|
@@
|
|
|
|
- x = strlen(from) + 1;
|
|
... when != \( x = E1 \| from = E1 \)
|
|
- to = \(kmalloc\|kzalloc\)(x,flag);
|
|
+ to = kstrdup(from, flag);
|
|
... when != \(x = E2 \| from = E2 \| to = E2 \)
|
|
if (to==NULL || ...) S
|
|
... when != \(x = E3 \| from = E3 \| to = E3 \)
|
|
- memcpy(to, from, x);
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
@r1 depends on !patch exists@
|
|
expression from,to;
|
|
expression flag,E1,E2;
|
|
statement S;
|
|
position p1,p2;
|
|
@@
|
|
|
|
* to = kmalloc@p1(strlen(from) + 1,flag);
|
|
... when != \(from = E1 \| to = E1 \)
|
|
if (to==NULL || ...) S
|
|
... when != \(from = E2 \| to = E2 \)
|
|
* strcpy@p2(to, from);
|
|
|
|
@r2 depends on !patch exists@
|
|
expression x,from,to;
|
|
expression flag,E1,E2,E3;
|
|
statement S;
|
|
position p1,p2;
|
|
@@
|
|
|
|
* x = strlen(from) + 1;
|
|
... when != \( x = E1 \| from = E1 \)
|
|
* to = \(kmalloc@p1\|kzalloc@p2\)(x,flag);
|
|
... when != \(x = E2 \| from = E2 \| to = E2 \)
|
|
if (to==NULL || ...) S
|
|
... when != \(x = E3 \| from = E3 \| to = E3 \)
|
|
* memcpy@p2(to, from, x);
|
|
|
|
@script:python depends on org@
|
|
p1 << r1.p1;
|
|
p2 << r1.p2;
|
|
@@
|
|
|
|
cocci.print_main("WARNING opportunity for kstrdup",p1)
|
|
cocci.print_secs("strcpy",p2)
|
|
|
|
@script:python depends on org@
|
|
p1 << r2.p1;
|
|
p2 << r2.p2;
|
|
@@
|
|
|
|
cocci.print_main("WARNING opportunity for kstrdup",p1)
|
|
cocci.print_secs("memcpy",p2)
|
|
|
|
@script:python depends on report@
|
|
p1 << r1.p1;
|
|
p2 << r1.p2;
|
|
@@
|
|
|
|
msg = "WARNING opportunity for kstrdup (strcpy on line %s)" % (p2[0].line)
|
|
coccilib.report.print_report(p1[0], msg)
|
|
|
|
@script:python depends on report@
|
|
p1 << r2.p1;
|
|
p2 << r2.p2;
|
|
@@
|
|
|
|
msg = "WARNING opportunity for kstrdup (memcpy on line %s)" % (p2[0].line)
|
|
coccilib.report.print_report(p1[0], msg)
|