Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Moinak Ghosh
[EMAIL PROTECTED] wrote: As a related note glibc has some questionable protections, like free(NULL) which it simply ignores resulting in bugs remaining hidden. GNU ls does a free(NULL) somewhere which we discovered while demoing truss on linux processes in BrandZ. It is also visible

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Joerg Schilling
Moinak Ghosh <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > [...] > >> Strictly conformant to the above would therefore be: > >> > >> #definedirfd(dp) ((dp) ? (dp)->dd_fd : -1) > >> > > > > No. Nothing to do with strictly conformant; while it is possible > > to have a DI

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Ian Collins
Joerg Schilling wrote: >Ian Collins <[EMAIL PROTECTED]> wrote: > > > >>>Solaris libc, unfortunately, also allows free(foo); free(foo); >>> >>> >>> >>> >>> >>Legal undefined behaviour :) >> >> > >Calling free(foo); free(foo); is not legal and may result in anything, >including >pink s

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Joerg Schilling
Ian Collins <[EMAIL PROTECTED]> wrote: > >Solaris libc, unfortunately, also allows free(foo); free(foo); > > > > > > > Legal undefined behaviour :) Calling free(foo); free(foo); is not legal and may result in anything, including pink smoke on top of your screen. free(foo); free(foo); however i

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Joerg Schilling
[EMAIL PROTECTED] wrote: > > > > As a related note glibc has some questionable protections, like > >free(NULL) > > which it simply ignores resulting in bugs remaining hidden. GNU ls > >does a > > free(NULL) somewhere which we discovered while demoing truss on linux > > processes in Brand

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Ian Collins
[EMAIL PROTECTED] wrote: > > >> As a related note glibc has some questionable protections, like >>free(NULL) >> which it simply ignores resulting in bugs remaining hidden. GNU ls >>does a >> free(NULL) somewhere which we discovered while demoing truss on linux >> processes in BrandZ. It is

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-23 Thread Casper . Dik
> As a related note glibc has some questionable protections, like >free(NULL) > which it simply ignores resulting in bugs remaining hidden. GNU ls >does a > free(NULL) somewhere which we discovered while demoing truss on linux > processes in BrandZ. It is also visible when you use ltrac

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Ian Collins
Moinak Ghosh wrote: > [EMAIL PROTECTED] wrote: > >> [...] >> >>> Strictly conformant to the above would therefore be: >>> >>> #definedirfd(dp)((dp) ? (dp)->dd_fd : -1) >>> >> >> >> No. Nothing to do with strictly conformant; while it is possible >> to have a DIR * which is NULL, usin

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Moinak Ghosh
[EMAIL PROTECTED] wrote: [...] Strictly conformant to the above would therefore be: #define dirfd(dp) ((dp) ? (dp)->dd_fd : -1) No. Nothing to do with strictly conformant; while it is possible to have a DIR * which is NULL, using it immediately gets you undefined behaviour. IMHO,

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Joerg Schilling
Stefan Teleman <[EMAIL PROTECTED]> wrote: > On Thursday 22 March 2007 15:42, [EMAIL PROTECTED] wrote: > > >> getc(NULL) also blows up; what is your point? > > > > > >My point is that it should not SEGV on NULL pointer. It should > > >return -1 and set EBADF. > > > > You are wrong; the standard dis

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Casper . Dik
>On Thursday 22 March 2007 15:42, [EMAIL PROTECTED] wrote: >> >> getc(NULL) also blows up; what is your point? >> > >> >My point is that it should not SEGV on NULL pointer. It should >> >return -1 and set EBADF. >> >> You are wrong; the standard disagrees with you. > >7.19.7.5.3: > >The [getc] fun

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread James Carlson
Stefan Teleman writes: > On Thursday 22 March 2007 15:42, [EMAIL PROTECTED] wrote: > > >> getc(NULL) also blows up; what is your point? > > > > > >My point is that it should not SEGV on NULL pointer. It should > > >return -1 and set EBADF. > > > > You are wrong; the standard disagrees with you. >

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Stefan Teleman
On Thursday 22 March 2007 15:42, [EMAIL PROTECTED] wrote: > >> getc(NULL) also blows up; what is your point? > > > >My point is that it should not SEGV on NULL pointer. It should > >return -1 and set EBADF. > > You are wrong; the standard disagrees with you. 7.19.7.5.3: The [getc] function return

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Casper . Dik
>> getc(NULL) also blows up; what is your point? > >My point is that it should not SEGV on NULL pointer. It should >return -1 and set EBADF. You are wrong; the standard disagrees with you. What point is there to have obviously broken code do plausible things? FILE *fp = fopen("no-such

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Stefan Teleman
On Thursday 22 March 2007 15:03, [EMAIL PROTECTED] wrote: > >On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > >> But BTW: dirfd() would be just: > >> > >> #define dirfd(dp) (dp)->dd_fd > > > >This works really well when (dp) is NULL. > > Yes, is will SEGV; is that an issue? Yes. It can r

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Casper . Dik
>None of them mentions whether DIR can be NULL. NULL is not a valid DIR * therefor you invoke undefined behaviour; then anything goes. >One could argue 'returns -1 on error' would mean they should return -1 >then - but then, neither of the above specify what errno would have to be >set to. No

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Casper . Dik
>On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > >> But BTW: dirfd() would be just: >> >> #define dirfd(dp)(dp)->dd_fd > >This works really well when (dp) is NULL. Yes, is will SEGV; is that an issue? getc(NULL) also blows up; what is your point? If you right buggy code without er

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread James Carlson
Stefan Teleman writes: > On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > > > But BTW: dirfd() would be just: > > > > #define dirfd(dp) (dp)->dd_fd > > This works really well when (dp) is NULL. Ignoring the NULL question for a moment, think it would be quite wrong to implement this as

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Joerg Schilling
Stefan Teleman <[EMAIL PROTECTED]> wrote: > /* testnulldir.c */ > > #include > #include > #include > > #define dirfd(dp)(dp)->dd_fd > static const char* dirname = "/this/baby/does/not/exist"; > > int > main(int argc, char* argv[]) > { > DIR* dir; > int fd; > > fd = dirfd(opendir

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Joerg Schilling
Frank Hofmann <[EMAIL PROTECTED]> wrote: > On Thu, 22 Mar 2007, Stefan Teleman wrote: > > > On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > > > >> But BTW: dirfd() would be just: > >> > >> #define dirfd(dp) (dp)->dd_fd > > > > This works really well when (dp) is NULL. > > > > --Stefan >

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Stefan Teleman
On Thursday 22 March 2007 12:29, Joerg Schilling wrote: > Stefan Teleman <[EMAIL PROTECTED]> wrote: > > On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > > > But BTW: dirfd() would be just: > > > > > > #define dirfd(dp) (dp)->dd_fd > > > > This works really well when (dp) is NULL. > > ??? >

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Frank Hofmann
On Thu, 22 Mar 2007, Stefan Teleman wrote: On Thursday 22 March 2007 10:21, Joerg Schilling wrote: But BTW: dirfd() would be just: #define dirfd(dp) (dp)->dd_fd This works really well when (dp) is NULL. --Stefan Found those: http://www.die.net/doc/linux/man/man3/dirfd.3.html http:

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Joerg Schilling
Stefan Teleman <[EMAIL PROTECTED]> wrote: > On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > > > But BTW: dirfd() would be just: > > > > #define dirfd(dp) (dp)->dd_fd > > This works really well when (dp) is NULL. ??? Garbage in -> garbage out. Do not expect to get useful results in c

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Stefan Teleman
On Thursday 22 March 2007 10:21, Joerg Schilling wrote: > But BTW: dirfd() would be just: > > #define dirfd(dp) (dp)->dd_fd This works really well when (dp) is NULL. --Stefan -- Stefan Teleman 'Nobody Expects the Spanish Inquisition' KDE e.V.

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-22 Thread Joerg Schilling
Jonathan Wheeler <[EMAIL PROTECTED]> wrote: > Hi All, > > Though I don't personally have enough knowledge about the subject to really > make a very good argument here, it's been suggested by steleman (from > #opensolaris), that I start a thread on OpenSolaris-discuss about this > function, and

Re: [osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-17 Thread Casper . Dik
A function like dirfd() is probably needed for completeness and compatibility, though I wonder what people are using it for Casper ___ opensolaris-discuss mailing list opensolaris-discuss@opensolaris.org

[osol-discuss] Proposal to include dirfd(3C) into OpenSolaris

2007-03-17 Thread Jonathan Wheeler
Hi All, Though I don't personally have enough knowledge about the subject to really make a very good argument here, it's been suggested by steleman (from #opensolaris), that I start a thread on OpenSolaris-discuss about this function, and the possibility of including it within upcoming builds