NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-sparc64/46652 (sparc ofwboot.net fails to load kernel viatftp)



> > Ok, tftp requires own initialization (net_sock in of->f_devdata),
> > but the previous code (using int**) was a bit confusing.
> > 
> > How about passing (struct open_file *) as
> > lib/libsa/tftp.c:tftp_open() does?
> 
> Why do you want to obscure what kind of data gets carried from
> generator to consumer in f_devdata in the tftp case?
> Using int ** is a (poor, but present) type check by the compiler,
> after all.

See actual consumer of the f_devdata, sys/lib/libsa/tftp.c:tftp_open():
---
__compactcall int
tftp_open(const char *path, struct open_file *f)
{

 :

        tftpfile->iodesc = io = socktodesc(*(int *)(f->f_devdata));
---
which indicates what should be initialized.

On the other hand, nfs.c (which also use net_open()) doesn't require
any data in f_devdata at all and it confused me.

> If the reason why it's int ** is too confusing, a comment should be added.
> 
> The code would be less clear to me, not more, if you handed over the
> pointer to the entire open_file struct when all you want to do is set
> one member of it (which is a dedicated "I'm void * so you can stick in
> whatever both ends need", too).

What kind of comment is reasonable for you?
Even if you don't want void *, Why not int * but int **?
I don't see any reason to prefer int **.

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index