[OpenAFS-devel] afs_buffer.c:DRead()
Derek Atkins
warlord@MIT.EDU
12 Nov 2002 19:08:31 -0500
Why is it a void* -- can't you just define:
struct osi_file;
and then prototype the function as:
foo (struct osi_file *tfile);
-derek
Nickolai Zeldovich <kolya@MIT.EDU> writes:
> > tfile = afs_CFileOpen(fid[0]);
> > sizep = (afs_int32 *)tfile;
> > if (page * AFS_BUFFER_PAGESIZE >= *sizep) {
> > give_up...
> >
> > Since tfile is really a struct osi_file *, this can't possibly work except
> > by accident.
>
> This does seem very backwards, but as far as I can tell, it actually does
> work. As afs_osi.h says:
>
> struct osi_file {
> afs_int32 size; /* file size in bytes XXX Must be first field XXX */
> ...
> }
>
> so sizep points at osi_file.size, and dereferencing it should infact give
> you the size value. I'm really unclear on why they decided to manually
> decode struct fields, instead of using, oh, say, tfile->size. Oh, I guess
> tfile is void*; but casting it to osi_file seems like a much better way
> to do it than this..
>
> -- kolya
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord@MIT.EDU PGP key available