*BSD News Article 68689


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!uuneo.neosoft.com!web.nmti.com!peter
From: peter@nmti.com (Peter da Silva)
Newsgroups: comp.unix.misc,comp.unix.bsd.misc
Subject: Re: How to delete files within C programs
Date: 16 May 1996 14:11:29 GMT
Organization: Network/development platform support, NMTI
Lines: 33
Message-ID: <4nfd2h$smf@web.nmti.com>
References: <Oum-El-Kheir.Benkahla-3004961724540001@mac-ugm-3.imag.fr> <4n5cer$33m@news.rhrz.uni-bonn.de> <4n7mse$o34@web.nmti.com> <4nclv9$11s@anorak.coverform.lan>
NNTP-Posting-Host: sonic.nmti.com
Xref: euryale.cc.adfa.oz.au comp.unix.misc:22809 comp.unix.bsd.misc:1066

In article <4nclv9$11s@anorak.coverform.lan>,
Brian Somers <brian@awfulhak.demon.co.uk> wrote:
> Peter da Silva (peter@nmti.com) wrote:
> : Most of the software on the net is that sort of code. Look at all the code
> : that calls:

> : 	execl(arg, arg, arg, arg, 0);

> : The amount of code that uses NULL or casts the 0 to (char *) is definitely
> : in the minority. Yet that's one of the most basic rank beginner mistakes...
> : but it worked fine on 32-bit systems so who cared?

> Also works fine with any compiler worth its salt that's given a prototype.

GOTCHA!

You can't prototype execl! It's a varargs function! You *have* to get the
parameters right. Another problem comes up in printf, where you pass a
long and print it with %d (another one that's caused me problems).

In both cases a paranoid compiler can be given extra information so you
make sure that all the args to execl are (char *) and the format string
matches the printf arguments (thoughthis loses if you generate the format
string at runtime), but there's nothing in the language that can resolve
the problem.

AWTTW: edit!

-- 
Peter da Silva    (NIC: PJD2)      `-_-'             1601 Industrial Boulevard
Bailey Network Management           'U`             Sugar Land, TX  77487-5013
+1 713 274 5180         "Har du kramat din varg idag?"                     USA
Bailey pays for my technical expertise.        My opinions probably scare them