lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100222022735.GC8791@nowhere>
Date:	Mon, 22 Feb 2010 03:27:37 +0100
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Tom Zanussi <tzanussi@...il.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, rostedt@...dmis.org,
	k-keiichi@...jp.nec.com
Subject: Re: [PATCH 06/12] perf trace/scripting: add Python scripting engine

On Wed, Jan 27, 2010 at 02:27:57AM -0600, Tom Zanussi wrote:
> +static void define_value(enum print_arg_type field_type,
> +			 const char *ev_name,
> +			 const char *field_name,
> +			 const char *field_value,
> +			 const char *field_str)
> +{
> +	const char *handler_name = "define_flag_value";
> +	PyObject *handler, *t, *retval;
> +	unsigned long long value;
> +	unsigned n = 0;
> +
> +	if (field_type == PRINT_SYMBOL)
> +		handler_name = "define_symbolic_value";
> +
> +	t = PyTuple_New(MAX_FIELDS);
> +	if (!t)
> +		Py_FatalError("couldn't create Python tuple");
> +
> +	value = eval_flag(field_value);
> +
> +	PyTuple_SetItem(t, n++, PyString_FromString(ev_name));
> +	PyTuple_SetItem(t, n++, PyString_FromString(field_name));
> +	PyTuple_SetItem(t, n++, PyInt_FromLong(value));
> +	PyTuple_SetItem(t, n++, PyString_FromString(field_str));
> +
> +	if (_PyTuple_Resize(&t, n) == -1)
> +		Py_FatalError("error resizing Python tuple");



Why are creating a tuple of 64 fields while you are always using
4?



> +
> +	handler = PyDict_GetItemString(main_dict, handler_name);
> +	if (handler && PyCallable_Check(handler)) {
> +		retval = PyObject_CallObject(handler, t);
> +		if (retval == NULL)
> +			handler_call_die(handler_name);
> +	}
> +
> +	Py_DECREF(t);
> +}
> +
> +

[...]

> +static void define_field(enum print_arg_type field_type,
> +			 const char *ev_name,
> +			 const char *field_name,
> +			 const char *delim)
> +{
> +	const char *handler_name = "define_flag_field";
> +	PyObject *handler, *t, *retval;
> +	unsigned n = 0;
> +
> +	if (field_type == PRINT_SYMBOL)
> +		handler_name = "define_symbolic_field";
> +
> +	t = PyTuple_New(MAX_FIELDS);
> +	if (!t)
> +		Py_FatalError("couldn't create Python tuple");
> +
> +	PyTuple_SetItem(t, n++, PyString_FromString(ev_name));
> +	PyTuple_SetItem(t, n++, PyString_FromString(field_name));
> +	if (field_type == PRINT_FLAGS)
> +		PyTuple_SetItem(t, n++, PyString_FromString(delim));
> +
> +	if (_PyTuple_Resize(&t, n) == -1)
> +		Py_FatalError("error resizing Python tuple");



Same here (except you may or may not have a PRINT_FLAGS type).

This is about neats though. The patch looks pretty nice.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ