Commit f7a858bf authored by Liam Howlett's avatar Liam Howlett Committed by Arnaldo Carvalho de Melo
Browse files

tools: Rename __fallthrough to fallthrough



Rename the fallthrough attribute to better align with the kernel
version.  Copy the definition from include/linux/compiler_attributes.h
including the #else clause.  Adding the #else clause allows the tools
compiler.h header to drop the check for a definition entirely and keeps
both definitions together.

Change any __fallthrough statements to fallthrough anywhere it was used
within perf.

This allows other tools to use the same key word as the kernel.

Committer notes:

Did some missing conversions to:

  builtin-list.c

Also included gtk.h before the 'fallthrough' definition in:

  tools/perf/ui/gtk/hists.c
  tools/perf/ui/gtk/helpline.c
  tools/perf/ui/gtk/browser.c

As it is the arg name for a macro in glib.h:

  /var/home/acme/git/perf-tools-next/tools/include/linux/compiler-gcc.h:16:55: error: missing binary operator before token "("
     16 | # define fallthrough                    __attribute__((__fallthrough__))
        |                                                       ^
  /usr/include/glib-2.0/glib/gmacros.h:637:28: note: in expansion of macro ‘fallthrough’
    637 | #if g_macro__has_attribute(fallthrough)

Reviewed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
Signed-off-by: default avatarLiam Howlett <Liam.Howlett@oracle.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Tom Rix <trix@redhat.com>
Cc: linux-sparse@vger.kernel.org <linux-sparse@vger.kernel.org>
Cc: llvm@lists.linux.dev <llvm@lists.linux.dev>
Link: https://lore.kernel.org/r/20221125154947.2163498-1-Liam.Howlett@oracle.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0ea8920e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -12,8 +12,10 @@
		     + __GNUC_PATCHLEVEL__)
#endif

#if GCC_VERSION >= 70000 && !defined(__CHECKER__)
# define __fallthrough __attribute__ ((fallthrough))
#if __has_attribute(__fallthrough__)
# define fallthrough                    __attribute__((__fallthrough__))
#else
# define fallthrough                    do {} while (0)  /* fallthrough */
#endif

#if __has_attribute(__error__)
+0 −4
Original line number Diff line number Diff line
@@ -186,10 +186,6 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
})


#ifndef __fallthrough
# define __fallthrough
#endif

/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
#define ___PASTE(a, b) a##b
#define __PASTE(a, b) ___PASTE(a, b)
+2 −2
Original line number Diff line number Diff line
@@ -278,10 +278,10 @@ static void fix_escape_printf(struct strbuf *buf, const char *fmt, ...)
						strbuf_addstr(buf, "\\n");
						break;
					case '\\':
						__fallthrough;
						fallthrough;
					case '\"':
						strbuf_addch(buf, '\\');
						__fallthrough;
						fallthrough;
					default:
						strbuf_addch(buf, s[s_pos]);
						break;
+1 −1
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ __cmd_probe(int argc, const char **argv)
			pr_err("  Error: --bootconfig doesn't support uprobes.\n");
			return -EINVAL;
		}
		__fallthrough;
		fallthrough;
	case 'a':

		/* Ensure the last given target is used */
+1 −1
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ static void process_evlist(struct evlist *evlist, unsigned int interval)
	if (evlist__ctlfd_process(evlist, &cmd) > 0) {
		switch (cmd) {
		case EVLIST_CTL_CMD_ENABLE:
			__fallthrough;
			fallthrough;
		case EVLIST_CTL_CMD_DISABLE:
			if (interval)
				process_interval();
Loading