Re: [PATCH v2 5/5] android: Add calls to adapter methods in haltest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jerzy,

On Tue, Oct 15, 2013, Jerzy Kasenberg wrote:
> +static bt_callbacks_t bt_callbacks = {
> +	sizeof(bt_callbacks),
> +	adapter_state_changed_cb,
> +	adapter_properties_cb,
> +	remote_device_properties_cb,
> +	device_found_cb,
> +	discovery_state_changed_cb,
> +	pin_request_cb,
> +	ssp_request_cb,
> +	bond_state_changed_cb,
> +	acl_state_changed_cb,
> +	thread_evt_cb,
> +	dut_mode_recv_cb,
> +	le_test_mode_cb
> +};

Could we get structure initializations like this to use follow the
coding style, i.e.:

static bt_callbacks_t bt_callbacks = {
	.member1 = sizeof(),
	.member2 = adapter_state_changed_cb,
	...
};

This way you can directly see that the right members are initialized to
the right values and there's no risk that e.g. two members with the same
type are swapped (something the compiler wouldn't warn about).

As a general point to others working on the android code: if there are
any other similar places elsewhere in the code please fix those too.

> +static void init_p(int argc, const char **argv)
> +{
> +	int err;
> +	const hw_module_t *module;
> +	hw_device_t *device;
> +
> +	err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
> +	if (err) {
> +		haltest_error("he_get_module returned %d\n", err);
> +		return;
> +	}
> +
> +	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
> +	if (err) {
> +		haltest_error("module->methods->open returned %d\n", err);
> +		return;
> +	}
> +
> +	if_bluetooth =
> +	    ((bluetooth_device_t *)device)->get_bluetooth_interface();

The user space coding style convention is to have a space between the
type cast and the variable. In this case you might make the code more
readable by adding an extra variable, something like:

	bluetooth_device_t *btdev;

	...

	btdev = (bluetooth_device_t *) device;
	if_bluetooth = btdev->get_bluetooth_interface();
	...

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux