glibc/include/stap-probe.h
Joseph Myers 0538372096 Fix -Wempty-body warnings in glibc.
One group of warnings seen building glibc with -Wextra is -Wempty-body
warnings about an 'if' body (or in one case an 'else' body) that is
just a semicolon, "warning: suggest braces around empty body in an
'if' statement [-Wempty-body]" - I think the point of the warning
being to make it more visible whether an 'if' body is actually present
or not.

This patch fixes such warnings in glibc.  There's one place, with a
semicolon at the end of a comment, where this is clearly making the
presence of an 'else' body more visible.  The other cases involve
macro definitions expanding to nothing.  While there's no issue there
with visibility at the call sites, I think it's still cleaner to have
a macro that expands to something nonempty appropriate for the context
- so do {} while (0) if it's only intended to be usable as a
statement, or ((void) 0) where the macro definition is an alternative
to a call to a function returning void, so this patch makes those
changes.

Tested for x86_64.

	* catgets/gencat.c (normalize_line): Use braces around empty
	'else' body.
	* include/stap-probe.h [!USE_STAP_PROBE && !__ASSEMBLER__]
	(STAP_PROBE0): Use do {} while (0) for do-nothing definition.
	[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE1): Likewise.
	[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE2): Likewise.
	[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE3): Likewise.
	[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE4): Likewise.
	* libio/libio.h (_IO_funlockfile): Use ((void) 0) for do-nothing
	definition.
2019-02-13 13:50:13 +00:00

79 lines
2.6 KiB
C

/* Macros for defining Systemtap <sys/sdt.h> static probe points.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _STAP_PROBE_H
#define _STAP_PROBE_H 1
#ifdef USE_STAP_PROBE
# include <stap-probe-machine.h>
# include <sys/sdt.h>
/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
Without USE_STAP_PROBE, that does nothing but evaluates all
its arguments (to prevent bit rot, unlike e.g. assert).
Systemtap's header defines the macros STAP_PROBE (provider, name) and
STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
in MODULE_NAME (libc, libpthread, etc.) automagically.
The format of the arg parameters is discussed here:
https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
The precise details of how register names are specified is
architecture specific and can be found in the gdb and SystemTap
source code. */
# define LIBC_PROBE(name, n, ...) \
LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__)
# define LIBC_PROBE_1(lib, name, n, ...) \
STAP_PROBE##n (lib, name, ## __VA_ARGS__)
# define STAP_PROBE0 STAP_PROBE
# define LIBC_PROBE_ASM(name, template) \
STAP_PROBE_ASM (MODULE_NAME, name, template)
# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
#else /* Not USE_STAP_PROBE. */
# ifndef __ASSEMBLER__
/* Evaluate all the arguments and verify that N matches their number. */
# define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__)
# define STAP_PROBE0() do {} while (0)
# define STAP_PROBE1(a1) do {} while (0)
# define STAP_PROBE2(a1, a2) do {} while (0)
# define STAP_PROBE3(a1, a2, a3) do {} while (0)
# define STAP_PROBE4(a1, a2, a3, a4) do {} while (0)
# else
# define LIBC_PROBE(name, n, ...) /* Nothing. */
# endif
# define LIBC_PROBE_ASM(name, template) /* Nothing. */
# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
#endif /* USE_STAP_PROBE. */
#endif /* stap-probe.h */