[PATCH v4 1/1] Initial support for LuaJIT scripting

Dmitry V. Levin ldv at altlinux.org
Mon Jun 26 17:46:16 UTC 2017


On Fri, Jun 23, 2017 at 06:05:34PM +0300, Victor Krapivensky wrote:
[...]
> +#define MBRESTART(res, sig)								\
> +	if ((res) >= 0 && ptrace_restart(PTRACE_SYSCALL, current_tcp, sig) < 0) {	\
> +		/* Note: ptrace_restart emitted error message */			\
> +		exit_code = 1;								\
> +		return NULL;								\
> +	}

Consider enclosing macros starting with "if" statement in a do/while loop.

> +
> +	if (!first) {
> +		unsigned int sig = 0;
> +		int res;
> +		if (entering(current_tcp)) {
> +			res = syscall_entering_trace(current_tcp, &sig);
> +			syscall_entering_finish(current_tcp, res);
> +		} else {
> +			res = syscall_exiting_trace(current_tcp, tv, 1);
> +			syscall_exiting_finish(current_tcp);
> +		}
> +		MBRESTART(res, sig);

This MBRESTART expands into if (...) {...};

[...]
> +#define EXPOSE(type, ptr, name)								\
> +	lua_getfield(L, -2, "cast"); /* L: chunk ffi table cast */			\
> +	lua_pushstring(L, type); /* L: chunk ffi table cast str */			\
> +	lua_pushlightuserdata(L, (void *) ptr); /* L: chunk ffi table cast str ptr */	\
> +	assert_lua(lua_pcall(L, 2, 1, 0)); /* L: chunk ffi table value */		\
> +	lua_setfield(L, -2, name); /* L: chunk ffi table */

Consider enclosing macros with multiple statements in a do/while loop.

> +
> +	EXPOSE("const struct_sysent **", sysent_vec, "sysent_vec")
> +	EXPOSE("const char ***", errnoent_vec, "errnoent_vec")
> +	EXPOSE("const char ***", signalent_vec, "signalent_vec")
> +	EXPOSE("const struct_ioctlent **", ioctlent_vec, "ioctlent_vec");

The last EXPOSE expands into ...;;


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170626/e338ea49/attachment.bin>


More information about the Strace-devel mailing list