We currently have
        struct ip_protocol {...};

As far as I can tell, all uses of it are of the form
        const struct ip_protocol

Why not
        typedef const struct {...} ip_protocol;

Then all uses should be changed appropriately (a sed script would do it).

That way the "const" could not be left off accidentally, the code becomes 
more concise, easier to fit on a line, easier to type, easier to read 
("chunking"), etc.  More importantly, I think that the code becomes easier 
to think about -- the power of abstraction.

BETTER:

Almost all uses would be of the form
        ip_protocol *

If instead, we define:
        struct ip_protocol {...};
        typedef const struct *ip_protocol;

then the table initialization can use "const struct ip_protocol" and all 
other uses get to eliminate the *.  This should make the use even simpler 
and less error prone.  A better abstraction all around.

This change might not be a simple sed operation (I haven't checked) but it 
should be easy to do it without introducing errors.

I propose to make this change if there are no serious objections.

It should be done when most code is at rest.  Can people tell me if they 
have code in-flight that would be affected?

Practical detail:

We can make the transition "hard" by naming the struct differently 
(perhaps "ip_protocol_").  That way unconverted code would fail to 
compile.  That would be my preference.

Perhaps an initial soft transition would be easier.  Then we could switch 
to hard after we think all in-flight code has landed.
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev

Reply via email to