public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Iain Hibbert <plunky@rya-online.net>
To: Peter Dons Tychsen <donpedro@tdcadsl.dk>
Cc: Marcel Holtmann <marcel@holtmann.org>, linux-bluetooth@vger.kernel.org
Subject: Re: HCI_MAX_DEV is a bit too small.
Date: Mon, 15 Mar 2010 08:34:27 +0000 (GMT)	[thread overview]
Message-ID: <1268642067.696573.16664.nullmailer@galant.ukfsn.org> (raw)
In-Reply-To: <1268619078.6278.10.camel@donpedro>

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

  reply	other threads:[~2010-03-15  8:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-14 23:20 HCI_MAX_DEV is a bit too small Peter Dons Tychsen
2010-03-14 23:34 ` Marcel Holtmann
2010-03-15  2:11   ` Peter Dons Tychsen
2010-03-15  8:34     ` Iain Hibbert [this message]
2010-03-21 22:26     ` Peter Dons Tychsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268642067.696573.16664.nullmailer@galant.ukfsn.org \
    --to=plunky@rya-online.net \
    --cc=donpedro@tdcadsl.dk \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox