Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!samsung!spool.mu.edu!yale.edu!think.com!sdd.hp.com!mips!newsun!gateway.novell.com!terry From: terry@npd.Novell.COM (Terry Lambert) Newsgroups: comp.unix.bsd Subject: Re: gcc 2.2.2 or 386BSD bug? Message-ID: <1992Jun23.232355.1382@gateway.novell.com> Date: 23 Jun 92 23:23:55 GMT References: <1992Jun22.164943.18294@ntuix.ntu.ac.sg> <1992Jun23.194137.3165@email.tuwien.ac.at> Sender: news@gateway.novell.com (NetNews) Organization: Novell NPD -- Sandy, UT Lines: 62 Nntp-Posting-Host: thisbe.eng.sandy.novell.com In article <1992Jun23.194137.3165@email.tuwien.ac.at> hp@vmars.tuwien.ac.at (Peter Holzer) writes: >eoahmad@ntuix.ntu.ac.sg (Othman Ahmad) writes: > >[ I moved the error messages to the lines they belong to. I think it is >easier to read that way.] > >>ocreat(p, uap, retval) > >Here starts a new scope. This scope lasts until the closing } of the >function (see X3.159-1989 3.1.2.1). The standard is not entirely clear >in this respect, but as I understand it, the opening brace of the >function body does not start a new scope. > >You are defining a struct stat here. It is uncommon, but legal to >redefine a type in an inner scope level, so you get a warning. You forgot "outrageously bad form". >open is usually defined as > int open (const char *name, int mode, ...), >and you are calling it as if it were defined as > int open (struct proc *, struct { char *; int; int } *, int *); > >No wonder GCC complains. What are you trying to achieve? Actually, he is dealing with the implementation of the open/creat system calls in 386BSD and trying to recompile the kernel with the new GCC; this is not an attempt to rewrite open in user space. The cannonical method would be to leave uap a generic pointer, or, at worst, a caddr_t or int *. This is what is done in other UNIX's (UNICes?); the data is then accessed as a cast. This is not strictly ANSI conforming, but I don't know of any UNIX (or any other OS, for that matter) written in entirely conforming ANSI C. As Arsenio Hall would say "Hmmmmmmmm....". The "corrected" ocreat() code would be (I cheated on structure overlay): ocreat(p, uap, retval) register struct proc *p; int *uap; int *retval; { struct args { char *fname; int mode; int crtmode; } openuap; openuap.fname = ((struct args *)uap)->fname; openuap.crtmode = ((struct args *)uap)->mode; openuap.mode = O_WRONLY | O_CREAT | O_TRUNC; return (open(p, &openuap, retval)); } Terry Lambert terry_lambert@gateway.novell.com terry@icarus.weber.edu --- Disclaimer: Any opinions in this posting are my own and not those of my present or previous employers.