From alsa-devel-owner@alsa.jcu.cz  Sun Dec 13 15:52:32 1998
Received: from entry.jcu.cz (IDENT:perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.9.1a/8.9.1) with SMTP id PAA31164;
	Sun, 13 Dec 1998 15:52:19 +0100
Date: Sun, 13 Dec 1998 15:52:26 +0100 (CET)
From: Jaroslav Kysela <perex@jcu.cz>
To: Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>
cc: alsa-devel@alsa.jcu.cz
Subject: Re: unsigned/signed mess
In-Reply-To: <19981213153155.B24824@ruhr-uni-bochum.de>
Message-ID: <Pine.LNX.3.96.981213153958.3930D-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Sun, 13 Dec 1998, Marcus Brinkmann wrote:

> On Sun, Dec 13, 1998 at 11:53:55AM +0000, Chris Butler wrote:
> > Hi,
> > 
> > In the info structures, the device numbers for mixers, pcm devices,
> > etc are all unsigned integers. However, when alsa-lib requires a
> > device number, the function prototype specifies an int, and not an
> > unsigned int.
> > 
> > Is it possible to sort this confusion out? It is causing some trouble
> > with the C++ interface (as C++ is more heavily typechecked).
> 
> My suggestion is that we use signed int for all. Using unsigned int to
> ensure a value is positive is almost never a good idea, because implicit type
> conversion works against this.

Note that device numbers are like constants. I don't see any reason for
which implicit compiler conversion will be used (arithmetic operations
willn't be applied for these constants).

But if anyone change asound.h and recode kernel side conditions from

if (device >= MAX_DEVICES)

to

if (device < 0 || device >= MAX_DEVICES)

I'll include patch to ALSA driver sources... There is a lot of other
variables which are unsigned and should be signed (include strings)...
For me are these changes only cosmetic which willn't have any other 
result (than possible problems with negative values in kernel code
if all conditions willn't be changed).

							Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


