Re: HCI_MAX_DEV is a bit too small.

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

 



On Mon, 15 Mar 2010, Peter Dons Tychsen wrote:

> > So I could be convinced to add new functions to read/write the limit
> > from within an application itself. So that it can be changed without
> > re-compiling the library. Feel free to propose a patch.
>
> I will see what i can do. What is needed is probably a
> hci_set_max_devices() call. Then hcitool could call that with the number
> of devices needed.

A suggestion. I have used this construct in the past for something that
contains a hard coded limit where somebody might want to override it
without rebuilding, and requires no change to the API..

hci.h:
#define HCI_MAX_DEV	hci_max_dev()

hci.c:
unsigned int
hci_max_dev(void)
{
	static unsigned int max = 0;
	char *env, *ep;
	unsigned long v;

	if (max == 0) {
		max = 16;

		env = getenv("HCI_MAX_DEV");
		if (env == NULL)
			break;

		errno = 0;
		v = strtoul(env, &ep, 0);
		if (env[0] == '\0' || *ep != '\0')
			break;

		if (errno == ERANGE && v == ULONG_MAX)
			break;

		if (v > UINT_MAX)
			break;

		max = v;
	}

	return max;
}

regards,
iain


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