Skip to content

Commit

Permalink
Devel: coccinelle: add patch for using __func__ instead of __FUNCTION__
Browse files Browse the repository at this point in the history
  • Loading branch information
kgaillot committed Aug 24, 2020
1 parent 776b224 commit 2fd370f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
25 changes: 12 additions & 13 deletions devel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#

EXTRA_SCRIPTS = coccinelle/test/testrunner.sh
EXTRA_DIST = $(EXTRA_SCRIPTS) \
coccinelle/ref-passed-variables-inited.cocci \
coccinelle/string-any-of.cocci \
coccinelle/string-empty.cocci \
coccinelle/string-null-matches.cocci \
coccinelle/string-replacements.cocci \
coccinelle/test/ref-passed-variables-inited.input.c \
coccinelle/test/ref-passed-variables-inited.output

# Coccinelle is a tool that takes special patch-like files (called semantic patches) and
# applies them throughout a source tree. This is useful when refactoring, changing APIs,
# catching dangerous or incorrect code, and other similar tasks. It's not especially
Expand All @@ -35,9 +25,18 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
#
# ref-passed-variables-inited.cocci seems to be returning some false positives around
# GHashTableIters, so it is disabled for the moment.
COCCI_FILES ?= coccinelle/string-any-of.cocci \
coccinelle/string-empty.cocci \
coccinelle/string-null-matches.cocci
COCCI_FILES ?= coccinelle/string-any-of.cocci \
coccinelle/string-empty.cocci \
coccinelle/string-null-matches.cocci \
coccinelle/use-func.cocci


EXTRA_SCRIPTS = coccinelle/test/testrunner.sh
EXTRA_DIST = $(EXTRA_SCRIPTS) $(COCCI_FILES) \
coccinelle/ref-passed-variables-inited.cocci \
coccinelle/string-replacements.cocci \
coccinelle/test/ref-passed-variables-inited.input.c \
coccinelle/test/ref-passed-variables-inited.output

# Any file in this list is allowed to use any of the pcmk__ internal functions.
# Coccinelle can use any transformation that depends on "internal" to rewrite
Expand Down
22 changes: 22 additions & 0 deletions devel/coccinelle/use-func.cocci
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2020 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*/

/*
* Always use __func__ (which is in the C99 standard) instead of __FUNCTION__
* (which is an older GNU C extension)
*/

virtual internal

@ use_func @
@@
(
- __FUNCTION__
+ __func__
)

0 comments on commit 2fd370f

Please sign in to comment.