learning dragonfly or C...

Matthew Dillon dillon at apollo.backplane.com
Thu Nov 11 12:20:57 PST 2004

    Well, George... in fact I've already made precisely the optimization
    you thought would clean up the code a few days ago.  It's part of my
    VFS patchset.

    Now is that a coincidence or not?

    Generally speaking, however, programmers do not make that sort of
    unoptimized algorithm mistake very often, and you will find that most
    of the other situations in the codebase where a double-indirect pointer
    is used have to be coded the way they are coded.

    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 ?

					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>

More information about the Kernel mailing list