Re: [PATCH 2/2] android: Add set/get for discovery timeout

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

 



Hi Johan,

>> static bool get_discoverable_timeout(void)
>> {
>> -	DBG("Not implemented");
>> +	struct hal_ev_adapter_props_changed *ev;
>> +	int len;
>> 
>> -	/* TODO: Add implementation */
>> +	len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(uint32_t);
>> 
> 
> The dynamic memory allocation seems a bit overkill here since the size is
> not very big and can be determined even at compile time. I'd consider
> doing something like:
> 
> 	uint8_t buf[sizeof(struct hal_ev_adapter_props_changed) +
> 			sizeof(struct hal_property) + sizeof(uint32_t)];
> 	struct hal_ev_adapter_props_changed *ev = (void *) buf;

actually having some #define for the base len would be easier to read.

	uint8_t buf[BASELEN + sizeof(uint32_t));
 
> 
> 	...
> 
> 	ipc_send(..., sizeof(buf), buf, ...);

Of course an alternative is to use alloca to just allocate on the stack. Then no free is actually needed.

Regards

Marcel

--
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