I'm cleaning up ntp_control, the code in ntpd that supports ntpq.

My main goal is to make it easy to add new variables.

I'm setting things up so that each variable you might want to read needs one 
line in a table.  For the common data types, a macro will setup that line with 
reasonable type checking.

An obvious data type is a uint64_t for things like packet counts.

Part of the current code uses procedures to return a variable rather than just 
reading it.  If I was setting up an API, I'd probably do something like that.  
But do we want/need that here?

The procedure means that the client can't write to the variable.  That's nice, 
but that isn't the type of error I'm worried about.  Should I be?  Is there any 
way to get c's type checking to make a variable read only (const) to outside 
world but writeable in the module that implements it?

In this case, I think we could setup a procedure to return a pointer to a const 
struct.

In this case, the variables are in a struct, so the client doesn't need to 
recompile when a new member is added to the struct.  But i/we recompile the 
whole world all the time so that's no an issue here.

>From my point of view, with my nose deep in the code, there is a nasty 
>disadvantage.  Adding a new counter requires 2 more edits, one for the header 
>file and one to setup the procedures.

Will anybody object if I remove those procedures?


-- 
These are my opinions.  I hate spam.



_______________________________________________
devel mailing list
devel@ntpsec.org
https://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to