[Swan-dev] proposal: "const struct ip_protocol" => "ip_protocol"

D. Hugh Redelmeier hugh at mimosa.com
Sun Oct 13 17:29:09 UTC 2019


| From: Andrew Cagney <andrew.cagney at gmail.com>

| because it gets confusing and is obscure; better to spell out:
|    const something
| where the code is being used than leave everyone wondering, for instance, given:
|    ip_something(something *foo, const someotherthing *bar, somethingelse *baz);
| which are typos and which are correct?  imnsho field_desc et.al.,
| being made typedef const struct were a massive mistake

Clearly I disagree (since I created most of them).

Why is it a mistake?  Confusing and obscure?  No use should be without
the const, so make it built-in.  The const is part of the abstraction.
The "const" is something you should not have to think about separately
at each use of the abstraction.

If I remember correctly, the C const qualifier is now idempotent so
adding a redundant one doesn't generate a compiler error.

| for struct something vs typedef something;
| kernel guidelines say don't use typedefs; we've modified that to say
| "typedef" denotes stay-out but here we're saying welcome aboard

We don't use kernel guidelines except for formatting.  This isn't
kernel code.

I don't know what you mean by "stay-out" vs. "welcome aboard".

Very very roughly, struct meant: structuring data transparently,
typedef meant: an abstraction (with varying transparency).


More information about the Swan-dev mailing list