• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..24-Nov-2021-

.gitignoreH A D24-Nov-20219 21

READMEH A D24-Nov-20212.1 KiB4434

array.cocciH A D24-Nov-20211.3 KiB9992

commit.cocciH A D24-Nov-20211 KiB5348

flex_alloc.cocciH A D24-Nov-2021266 1412

free.cocciH A D24-Nov-2021146 1916

hashmap.cocciH A D24-Nov-2021280 1715

object_id.cocciH A D24-Nov-20211.2 KiB8876

preincr.cocciH A D24-Nov-202150 65

qsort.cocciH A D24-Nov-2021610 3832

strbuf.cocciH A D24-Nov-2021867 6355

swap.cocciH A D24-Nov-2021280 2926

the_repository.pending.cocciH A D24-Nov-20212 KiB145127

xcalloc.cocciH A D24-Nov-202196 1110

xopen.cocciH A D24-Nov-2021295 2018

xstrdup_or_null.cocciH A D24-Nov-2021161 1412

README

1This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
2semantic patches that might be useful to developers.
3
4There are two types of semantic patches:
5
6 * Using the semantic transformation to check for bad patterns in the code;
7   The target 'make coccicheck' is designed to check for these patterns and
8   it is expected that any resulting patch indicates a regression.
9   The patches resulting from 'make coccicheck' are small and infrequent,
10   so once they are found, they can be sent to the mailing list as per usual.
11
12   Example for introducing new patterns:
13   67947c34ae (convert "hashcmp() != 0" to "!hasheq()", 2018-08-28)
14   b84c783882 (fsck: s/++i > 1/i++/, 2018-10-24)
15
16   Example of fixes using this approach:
17   248f66ed8e (run-command: use strbuf_addstr() for adding a string to
18               a strbuf, 2018-03-25)
19   f919ffebed (Use MOVE_ARRAY, 2018-01-22)
20
21   These types of semantic patches are usually part of testing, c.f.
22   0860a7641b (travis-ci: fail if Coccinelle static analysis found something
23               to transform, 2018-07-23)
24
25 * Using semantic transformations in large scale refactorings throughout
26   the code base.
27
28   When applying the semantic patch into a real patch, sending it to the
29   mailing list in the usual way, such a patch would be expected to have a
30   lot of textual and semantic conflicts as such large scale refactorings
31   change function signatures that are used widely in the code base.
32   A textual conflict would arise if surrounding code near any call of such
33   function changes. A semantic conflict arises when other patch series in
34   flight introduce calls to such functions.
35
36   So to aid these large scale refactorings, semantic patches can be used.
37   However we do not want to store them in the same place as the checks for
38   bad patterns, as then automated builds would fail.
39   That is why semantic patches 'contrib/coccinelle/*.pending.cocci'
40   are ignored for checks, and can be applied using 'make coccicheck-pending'.
41
42   This allows to expose plans of pending large scale refactorings without
43   impacting the bad pattern checks.
44