[PATCH 2/6] ptrace: introduce ptrace_syscall_enter to consolidate PTRACE_SYSEMU handling

Segher Boessenkool segher at kernel.crashing.org
Mon Mar 4 23:23:32 AEDT 2019


On Mon, Mar 04, 2019 at 10:46:43AM +0000, Sudeep Holla wrote:
> On Mon, Mar 04, 2019 at 08:03:47AM +0000, Haibo Xu (Arm Technology China) wrote:
> > On 2019/3/1 2:32, Sudeep Holla wrote:
> > > +long ptrace_syscall_enter(struct pt_regs *regs)
> > > +{
> > > +#ifdef TIF_SYSCALL_EMU
> > > +	if (test_thread_flag(TIF_SYSCALL_EMU)) {
> > > +		if (tracehook_report_syscall_entry(regs));
> > 
> > Shall we remove the semi-colon at end of the above line?
> 
> Added intentionally to keep GCC happy.

GCC warns because the user explicitly asked for it, with __must_check.
If you want to do things with an "if" like this, you should write e.g.

		if (tracehook_report_syscall_entry(regs))
			/*
			 * We can ignore the return code here, because of
			 * X and Y and Z.
			 */
			;

Or it probably is nicer to use a block:

		if (tracehook_report_syscall_entry(regs)) {
			/*
			 * We can ignore the return code here, because of
			 * X and Y and Z.
			 */
		}

The point is, you *always* should have a nice fat comment if you are
ignoring the return code of a __must_check function.


Segher


More information about the Linuxppc-dev mailing list