Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - sysconf() and invalid names: (4 Items)
   
sysconf() and invalid names  
The code for sysconf() includes this comment:

  // POSIX says that sysconf returns -1 and does not set errno
  // when the 'name' is valid and has no limit. If 'name' is invalid,
  // it returns -1 and sets errno to EINVAL. What, exactly, is an
  // invalid 'name' isn't specified. For right now, we assume that
  // all 'name' values are OK, and _conf_get returning -1 indicates
  // that 'name' is unset. Assume, for PCTS, that -1 is never valid.
 
I would have expected that any name that isn't a defined _SC_* name would be invalid. If you call sysconf() with a bogus
 value -- I tried -377 (which I assume doesn't correspond to an _SC_* name) -- the function returns -1 but doesn't set 
errno. It sets errno to EINVAL only if you pass a name of -1.

Is this the right thing for this function to do?	
Re: sysconf() and invalid names  
One of the sources of values is from the typed_strings section of the
system page. We didn't want to disallow users from defining their own
private set of name/value pairs that we didn't know about, so it seemed
best to define all possible names as valid and just unset. 

	Brian

On Wed, Sep 02, 2009 at 10:35:09AM -0400, Steve Reid wrote:
> The code for sysconf() includes this comment:
> 
>   // POSIX says that sysconf returns -1 and does not set errno
>   // when the 'name' is valid and has no limit. If 'name' is invalid,
>   // it returns -1 and sets errno to EINVAL. What, exactly, is an
>   // invalid 'name' isn't specified. For right now, we assume that
>   // all 'name' values are OK, and _conf_get returning -1 indicates
>   // that 'name' is unset. Assume, for PCTS, that -1 is never valid.
>  
> I would have expected that any name that isn't a defined _SC_* name would be invalid. If you call sysconf() with a 
bogus value -- I tried -377 (which I assume doesn't correspond to an _SC_* name) -- the function returns -1 but doesn't 
set errno. It sets errno to EINVAL only if you pass a name of -1.
> 
> Is this the right thing for this function to do?	
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post37143
> 

-- 
Brian Stecher (bstecher@qnx.com)        QNX Software Systems
phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
       +1 (613) 591-3579 (fax)          Kanata, Ontario, Canada K2M 1W8
RE: sysconf() and invalid names  
> -----Original Message-----
> From: Brian Stecher [mailto:community-noreply@qnx.com] 
> Sent: September 2, 2009 10:52 AM
> To: ostech-core_os
> Subject: Re: sysconf() and invalid names
> 
> One of the sources of values is from the typed_strings 
> section of the system page. We didn't want to disallow users 
> from defining their own private set of name/value pairs that 
> we didn't know about, so it seemed best to define all 
> possible names as valid and just unset. 

It should be possible for _conf_get to distinguish between unset and
non-existent though, correct?


> 
> 	Brian
> 
> On Wed, Sep 02, 2009 at 10:35:09AM -0400, Steve Reid wrote:
> > The code for sysconf() includes this comment:
> > 
> >   // POSIX says that sysconf returns -1 and does not set errno
> >   // when the 'name' is valid and has no limit. If 'name' 
> is invalid,
> >   // it returns -1 and sets errno to EINVAL. What, exactly, is an
> >   // invalid 'name' isn't specified. For right now, we assume that
> >   // all 'name' values are OK, and _conf_get returning -1 indicates
> >   // that 'name' is unset. Assume, for PCTS, that -1 is never valid.
> >  
> > I would have expected that any name that isn't a defined 
> _SC_* name would be invalid. If you call sysconf() with a 
> bogus value -- I tried -377 (which I assume doesn't 
> correspond to an _SC_* name) -- the function returns -1 but 
> doesn't set errno. It sets errno to EINVAL only if you pass a 
> name of -1.
> > 
> > Is this the right thing for this function to do?	
> > 
> > 
> > 
> > _______________________________________________
> > 
> > OSTech
> > http://community.qnx.com/sf/go/post37143
> > 
> 
> -- 
> Brian Stecher (bstecher@qnx.com)        QNX Software Systems
> phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
>        +1 (613) 591-3579 (fax)          Kanata, Ontario, 
> Canada K2M 1W8
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post37149
> 
> 
Re: sysconf() and invalid names  
Not really. 

On Wed, Sep 02, 2009 at 10:59:31AM -0400, David Sarrazin wrote:
> 
> > -----Original Message-----
> > From: Brian Stecher [mailto:community-noreply@qnx.com] 
> > Sent: September 2, 2009 10:52 AM
> > To: ostech-core_os
> > Subject: Re: sysconf() and invalid names
> > 
> > One of the sources of values is from the typed_strings 
> > section of the system page. We didn't want to disallow users 
> > from defining their own private set of name/value pairs that 
> > we didn't know about, so it seemed best to define all 
> > possible names as valid and just unset. 
> 
> It should be possible for _conf_get to distinguish between unset and
> non-existent though, correct?
> 
> 
> > 
> > 	Brian
> > 
> > On Wed, Sep 02, 2009 at 10:35:09AM -0400, Steve Reid wrote:
> > > The code for sysconf() includes this comment:
> > > 
> > >   // POSIX says that sysconf returns -1 and does not set errno
> > >   // when the 'name' is valid and has no limit. If 'name' 
> > is invalid,
> > >   // it returns -1 and sets errno to EINVAL. What, exactly, is an
> > >   // invalid 'name' isn't specified. For right now, we assume that
> > >   // all 'name' values are OK, and _conf_get returning -1 indicates
> > >   // that 'name' is unset. Assume, for PCTS, that -1 is never valid.
> > >  
> > > I would have expected that any name that isn't a defined 
> > _SC_* name would be invalid. If you call sysconf() with a 
> > bogus value -- I tried -377 (which I assume doesn't 
> > correspond to an _SC_* name) -- the function returns -1 but 
> > doesn't set errno. It sets errno to EINVAL only if you pass a 
> > name of -1.
> > > 
> > > Is this the right thing for this function to do?	
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > 
> > > OSTech
> > > http://community.qnx.com/sf/go/post37143
> > > 
> > 
> > -- 
> > Brian Stecher (bstecher@qnx.com)        QNX Software Systems
> > phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
> >        +1 (613) 591-3579 (fax)          Kanata, Ontario, 
> > Canada K2M 1W8
> > 
> > 
> > 
> > _______________________________________________
> > 
> > OSTech
> > http://community.qnx.com/sf/go/post37149
> > 
> > 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post37153
> 

-- 
Brian Stecher (bstecher@qnx.com)        QNX Software Systems
phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
       +1 (613) 591-3579 (fax)          Kanata, Ontario, Canada K2M 1W8