Dag-Erling Smorgrav | 1 May 2003 16:51

incorrect enum warning?

Why does the following code in OpenPAM headers:

/*
 * XSSO 5.4
 */
enum {
        PAM_SILENT                      = 0x80000000,
        PAM_DISALLOW_NULL_AUTHTOK       = 0x1,
        PAM_ESTABLISH_CRED              = 0x1,
        PAM_DELETE_CRED                 = 0x2,
        PAM_REINITIALIZE_CRED           = 0x4,
        PAM_REFRESH_CRED                = 0x8,
        PAM_PRELIM_CHECK                = 0x1,
        PAM_UPDATE_AUTHTOK              = 0x2,
        PAM_CHANGE_EXPIRED_AUTHTOK      = 0x4
};

cause the following warning when compiled with CSTD=c99:

/usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
enumerator values to range of `int'

when 0x80000000 is clearly within the range of 'int' on all platforms
we support?

DES
--

-- 
Dag-Erling Smorgrav - des <at> ofug.org
_______________________________________________
freebsd-hackers <at> freebsd.org mailing list
(Continue reading)

Luigi Rizzo | 1 May 2003 16:59

Re: incorrect enum warning?

On Thu, May 01, 2003 at 04:51:40PM +0200, Dag-Erling Smorgrav wrote:
...
>         PAM_SILENT                      = 0x80000000,
...
> cause the following warning when compiled with CSTD=c99:
> 
> /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
enumerator values to range of `int'
> 
> when 0x80000000 is clearly within the range of 'int' on all platforms
> we support?

maybe 0x80000000 gets interpreted as unsigned and then the compiler
complains. E.g. in machine/limits.h you find

#define INT_MIN         (-0x7fffffff - 1)       /* min value for an int */   

(to tell the truth you also find there the following definition
for UINT_MAX, and I don't understand why the 'U' is necessary then)

#define UINT_MAX        0xffffffffU     /* max value for an unsigned int */

	cheers
	luigi

> DES
> -- 
> Dag-Erling Smorgrav - des <at> ofug.org
> _______________________________________________
> freebsd-hackers <at> freebsd.org mailing list
(Continue reading)

John Baldwin | 1 May 2003 17:06
Picon
Favicon

RE: incorrect enum warning?


On 01-May-2003 Dag-Erling Smorgrav wrote:
> Why does the following code in OpenPAM headers:
> 
> /*
>  * XSSO 5.4
>  */
> enum {
>         PAM_SILENT                      = 0x80000000,
>         PAM_DISALLOW_NULL_AUTHTOK       = 0x1,
>         PAM_ESTABLISH_CRED              = 0x1,
>         PAM_DELETE_CRED                 = 0x2,
>         PAM_REINITIALIZE_CRED           = 0x4,
>         PAM_REFRESH_CRED                = 0x8,
>         PAM_PRELIM_CHECK                = 0x1,
>         PAM_UPDATE_AUTHTOK              = 0x2,
>         PAM_CHANGE_EXPIRED_AUTHTOK      = 0x4
> };
> 
> cause the following warning when compiled with CSTD=c99:
> 
> /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
> enumerator values to range of `int'
> 
> when 0x80000000 is clearly within the range of 'int' on all platforms
> we support?

On an i386:

#define INT_MAX         0x7fffffff      /* max value for an int */
(Continue reading)

Jacques A. Vidrine | 1 May 2003 17:07
Picon
Favicon

Re: incorrect enum warning?

On Thu, May 01, 2003 at 04:51:40PM +0200, Dag-Erling Smorgrav wrote:
> Why does the following code in OpenPAM headers:
> 
> /*
>  * XSSO 5.4
>  */
> enum {
>         PAM_SILENT                      = 0x80000000,
>         PAM_DISALLOW_NULL_AUTHTOK       = 0x1,
>         PAM_ESTABLISH_CRED              = 0x1,
>         PAM_DELETE_CRED                 = 0x2,
>         PAM_REINITIALIZE_CRED           = 0x4,
>         PAM_REFRESH_CRED                = 0x8,
>         PAM_PRELIM_CHECK                = 0x1,
>         PAM_UPDATE_AUTHTOK              = 0x2,
>         PAM_CHANGE_EXPIRED_AUTHTOK      = 0x4
> };
> 
> cause the following warning when compiled with CSTD=c99:
> 
> /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
enumerator values to range of `int'
> 
> when 0x80000000 is clearly within the range of 'int' on all platforms
> we support?

Guessing:
C does not specify one's complement or two's complement representation
of integers.  On a one's complement 32-bit platform, 0x80000000 is -0
(negative zero), which cannot be an `int'.
(Continue reading)

Stefan Farfeleder | 1 May 2003 17:20
Picon

Re: incorrect enum warning?

On Thu, May 01, 2003 at 10:07:13AM -0500, Jacques A. Vidrine wrote:
> On Thu, May 01, 2003 at 04:51:40PM +0200, Dag-Erling Smorgrav wrote:
> > Why does the following code in OpenPAM headers:
> > 
> > enum {
> >         PAM_SILENT                      = 0x80000000,

<...>

> > };
> > 
> > cause the following warning when compiled with CSTD=c99:
> > 
> > /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
enumerator values to range of `int'
> > 
> > when 0x80000000 is clearly within the range of 'int' on all platforms
> > we support?
> 
> Guessing:
> C does not specify one's complement or two's complement representation
> of integers.  On a one's complement 32-bit platform, 0x80000000 is -0
> (negative zero), which cannot be an `int'.

6.4.4.1 Integer constants

<...>

The type of an integer constant is the first of the corresponding list
in which its value can be represented.
(Continue reading)

Jacques A. Vidrine | 1 May 2003 17:24
Picon
Favicon

Re: incorrect enum warning?

On Thu, May 01, 2003 at 05:20:22PM +0200, Stefan Farfeleder wrote:
> Because 0x80000000 > INT_MAX on 32-Bit architectures, 0x80000000 has

You forgot to quote where INT_MAX is defined in the standard.
--

-- 
Jacques Vidrine   . NTT/Verio SME      . FreeBSD UNIX       . Heimdal
nectar <at> celabo.org . jvidrine <at> verio.net . nectar <at> freebsd.org . nectar <at> kth.se
_______________________________________________
freebsd-hackers <at> freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe <at> freebsd.org"

Narvi | 1 May 2003 17:37
Picon

Re: incorrect enum warning?


On Thu, 1 May 2003, Jacques A. Vidrine wrote:

> On Thu, May 01, 2003 at 04:51:40PM +0200, Dag-Erling Smorgrav wrote:
> > Why does the following code in OpenPAM headers:
> >
> > /*
> >  * XSSO 5.4
> >  */
> > enum {
> >         PAM_SILENT                      = 0x80000000,
> >         PAM_DISALLOW_NULL_AUTHTOK       = 0x1,
> >         PAM_ESTABLISH_CRED              = 0x1,
> >         PAM_DELETE_CRED                 = 0x2,
> >         PAM_REINITIALIZE_CRED           = 0x4,
> >         PAM_REFRESH_CRED                = 0x8,
> >         PAM_PRELIM_CHECK                = 0x1,
> >         PAM_UPDATE_AUTHTOK              = 0x2,
> >         PAM_CHANGE_EXPIRED_AUTHTOK      = 0x4
> > };
> >
> > cause the following warning when compiled with CSTD=c99:
> >
> > /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts
enumerator values to range of `int'
> >
> > when 0x80000000 is clearly within the range of 'int' on all platforms
> > we support?
>
> Guessing:
(Continue reading)

Stefan Farfeleder | 1 May 2003 17:43
Picon

Re: incorrect enum warning?

On Thu, May 01, 2003 at 10:24:32AM -0500, Jacques A. Vidrine wrote:
> On Thu, May 01, 2003 at 05:20:22PM +0200, Stefan Farfeleder wrote:
> > Because 0x80000000 > INT_MAX on 32-Bit architectures, 0x80000000 has
> 
> You forgot to quote where INT_MAX is defined in the standard.

5.2.4.2.1 Sizes of integer types <limits.h>

-- maximum value for an object of type int
   INT_MAX                                    +32767 // 2^15 - 1

[where 32767 is the smallest legal value for INT_MAX]

Regards,
Stefan Farfeleder
_______________________________________________
freebsd-hackers <at> freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe <at> freebsd.org"

Nate Lawson | 1 May 2003 21:02

hsf/hcf conexant winmodem support?

This question has come up before but I lost the URL.  I belive someone (I
think in .jp) had done a port of the Linux conexant hsf/hcf winmodem
drivers.  Anyone have a pointer to that?  The Linux code is at:
   http://www.linuxant.com/drivers/

-Nate

_______________________________________________
freebsd-hackers <at> freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe <at> freebsd.org"

Dag-Erling Smorgrav | 1 May 2003 23:03

Re: incorrect enum warning?

Stefan Farfeleder <stefan <at> fafoe.dyndns.org> writes:
> Because 0x80000000 > INT_MAX on 32-Bit architectures, 0x80000000 has
> type unsigned.  But enumeration constants always have type int, that's
> why you're getting this warning.

but 0x80000000 == INT_MIN on 32-bit two's complement systems...

DES
--

-- 
Dag-Erling Smorgrav - des <at> ofug.org
_______________________________________________
freebsd-hackers <at> freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe <at> freebsd.org"


Gmane