[Swan-dev] static things in headers

Sahana Prasad sahana.prasad07 at gmail.com
Thu Sep 7 08:20:04 UTC 2017

On Wed, Sep 6, 2017 at 5:38 PM, D. Hugh Redelmeier <hugh at mimosa.com> wrote:

> Perhaps I'm old fashioned but we have avoided putting static things in
> headers.
> - they notionally take resources in every compilation unit that includes
>   the header.  (But smart compilers can eliminate unused instances.)
> - .h files are about sharing and static things are not shared
> Exception: inline functions.  An inline function is useful as a cleaner
> replacement for macros.  If I remember correctly, making an inline
> function static makes the semantics simpler allowing a compiler to do
> a better job.
> Currently the only exceptions I see are:
> linux/include/des/podd.h:59:static const unsigned char odd_parity[256] = {
> linux/include/des/sk.h:59:static const DES_LONG des_skb[8][64] = {
> osxApp/MainMenuController.h:20:static AuthorizationRef gAuth;
> include/ietf_constants.h:1696:static const unsigned char
> sha1_rsa_oid_blob[ASN1_SHA1_RSA_OID_SIZE] = {0x30,0x0d,0x06,0x09,0x2a,
> 0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00};
> include/ietf_constants.h:1698:static const uint8_t
> len_sha1_rsa_oid_blob[ASN1_LEN_ALGO_IDENTIFIER] =
> The first three are in imported code and should not be changed. The second
> two, in my opinion, ought to be eliminated (definitions moved).
> I will change this. Thank you for the comments.
This was implemented in a hard coded way for one value. But , in future
there are many such blobs of varying lengths that would be used. So, this
hardcoding shall be removed.

> The objects defined in last two are only actually used one place so
> there is probably no serious consequence to the current code.
> _______________________________________________
> Swan-dev mailing list
> Swan-dev at lists.libreswan.org
> https://lists.libreswan.org/mailman/listinfo/swan-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libreswan.org/pipermail/swan-dev/attachments/20170907/d046e55f/attachment-0001.html>

More information about the Swan-dev mailing list