stat(), lstat() again.

Jim Jagielski jim at jagmac2.gsfc.nasa.gov
Mon Sep 24 01:25:24 AEST 1990


In article <2842 at sequent.cs.qmw.ac.uk> liam at cs.qmw.ac.uk (William Roberts) writes:
>Do you now accept that
>
>1) the stat and lstat functions require a pointer to a statbuf structure
>2) the stat and lstat functions don't do memory allocation for that structure
>3) NULL is not a good choice of random address for a structure
>4) You should be using &statbuf regardless of the fact that some 
>   compiler/machine/architecture combinations let you get away with
>   what you were doing before.
>

As I wrote to Steve, yes I DID make a major mistake: 1st by passing the wrong
thing to stat and lstat and secondly NOT accepting the obvious reason for
the mistake... that the reason it DIDN'T work with cc and gcc is because stuff
was getting crunched since the pointer either pointed somewhere unknown or to
NULL (0). That is in essense what the entire thing was about... My other
comments about how stuff was being changed by different compilers was really
not appropriate, since even if it DID work with some other compilers, that
still doesn't affect the fact that the code was plain and simple WRONG.

The only thing that reall upset me was the comment concerning my knowledge of
C and that's what caused my flame... a bruised ego is a dangerous thing and
I am sorry for that. Everyone makes mistakes and I just didn't want a stupid
one to give the impression that I don't know C (although at the time, maybe
my mind was such mush that I didn't even know my name :).

Anyway, I hope all this is over with. I made my peace and apologies to Steve
and appreciate all his ( and everyone else's) comments and illumination.

The moral is: Think before you act... I gotta start doing that MORE!
--
=======================================================================
#include <std/disclaimer.h>
                                 =:^)
           Jim Jagielski                    NASA/GSFC, Code 711.1
     jim at jagmac2.gsfc.nasa.gov               Greenbelt, MD 20771

"Kilimanjaro is a pretty tricky climb. Most of it's up, until you reach
 the very, very top, and then it tends to slope away rather sharply."



More information about the Comp.unix.aux mailing list