Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8bf98b89 authored by Irina Tirdea's avatar Irina Tirdea Committed by Arnaldo Carvalho de Melo
Browse files

perf bench: fix assert when NDEBUG is defined



When NDEBUG is defined, the assert macro will be expanded to nothing.
Some assert calls used in perf are also including some functionality
(e.g. system calls), not only validity checks. Therefore, if NDEBUG is
defined, this functionality will be removed along with the assert.  Perf
also defines BUG_ON based on assert, so it has the same problem.

Define BUG_ON so that the condition will be executed when NDEBUG is
defined.  Replace the assert statements that have these side effects
with BUG_ON.

For defining BUG_ON, use "if (cond) {}" insted of "if (cond) ;" because
in the latter case build fails with "error: suggest braces around empty
body in an ‘if’ statement [-Werror=empty-body]"

Suggested-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIrina Tirdea <irina.tirdea@intel.com>
Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
Reviewed-by: default avatarPekka Enberg <penberg@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1347082551-2394-1-git-send-email-irina.tirdea@intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ef34eb4d
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -56,13 +56,13 @@ int bench_sched_pipe(int argc, const char **argv,
	 * causes error in building environment for perf
	 * causes error in building environment for perf
	 */
	 */
	int __used ret, wait_stat;
	int __used ret, wait_stat;
	pid_t pid, retpid;
	pid_t pid, retpid __used;


	argc = parse_options(argc, argv, options,
	argc = parse_options(argc, argv, options,
			     bench_sched_pipe_usage, 0);
			     bench_sched_pipe_usage, 0);


	assert(!pipe(pipe_1));
	BUG_ON(pipe(pipe_1));
	assert(!pipe(pipe_2));
	BUG_ON(pipe(pipe_2));


	pid = fork();
	pid = fork();
	assert(pid >= 0);
	assert(pid >= 0);
+4 −0
Original line number Original line Diff line number Diff line
@@ -47,8 +47,12 @@
#endif
#endif


#ifndef BUG_ON
#ifndef BUG_ON
#ifdef NDEBUG
#define BUG_ON(cond) do { if (cond) {} } while (0)
#else
#define BUG_ON(cond) assert(!(cond))
#define BUG_ON(cond) assert(!(cond))
#endif
#endif
#endif


/*
/*
 * Both need more care to handle endianness
 * Both need more care to handle endianness