DragonFly kernel List (threaded) for 2004-11
Re: learning dragonfly or C...
:> This brings up an interesting ancillary issue in that you might also
:> see a very experienced C programmer use a slightly different sort
:> of construction, like this:
:> struct vnode *vp;
:> struct vnode *nvp;
:> if ((error = ckpt_fhtovp(&vnh->vnh_fh, &nvp)) != 0)
:> return error;
:> vp = nvp;
:> /* nvp ignored, vp used from here on */
:> Care to take a guess at why advanced C programmers use this construction
:> instead of simply passing &vp ?
:well not knowing what vnh_fh or ckpt_fhtovp is, sets me back a bit, but
:...need more info...
:is it a buffer to throw out illegal file handles inherited by NFS?
Nope. Ignore the actual function names and ignore the function of
the code, its irrelevant. Just focus on the question: Why is
&nvp being passed to a function and then vp assigned to nvp when
one could simply pass &vp to the function and get rid of nvp entirely?
Let me modify the example a little:
struct fubar *blah;
struct fubar *nblah;
blah = nblah;
blech = blah->this + blah->that - somefunction(blah);
blah blah blah...
Ok, so, the question is, why would an advanced C programmer every
want to create a separate variable to pass the address to a function
and then simply assign the result back to the first variable and never
use the second variable again?