[Swan-dev] style question
Andrew Cagney
andrew.cagney at gmail.com
Sat Jun 5 20:43:48 UTC 2021
On Sat, 5 Jun 2021 at 15:27, D. Hugh Redelmeier <hugh at mimosa.com> wrote:
> In 8b254f86c6740a4eb900e481c9c21e8da745b130
> before: the type for a priority was unsigned, 32 bit.
>
> Actual bits within that were allocated and documented.
>
> After: the type was changed to unsigned. Comments and a passert were
> added to make it clear that the type must be at least 32 bits:
>
> - uint32_t pmax =
> + /* XXX: assume unsigned >= 32-bits */
> + passert(sizeof(unsigned) >= sizeof(uint32_t));
> +
> + unsigned pmax =
>
> Why change this from uint32_t?
>
Why was it unit32_t? (The question's rhetorical. Somewhere in low-level
kernel code far away the value gets squeezed into a uint32_t field).
Below is some actual context:
commit 8b254f86c6740a4eb900e481c9c21e8da745b130
Date: Fri Jun 4 20:41:00 2021 -0400
connections: log priority in more detail
/* ensure an instance of a template/OE-group always has preference
*/
- uint32_t instw = (c->kind == CK_INSTANCE ? 0u : 1u);
+ unsigned instw = (c->kind == CK_INSTANCE ? 0u : 1u);
uint32_t prio = pmax - (portsw << 18 | protow << 17 | srcw << 9 |
dstw << 1 | instw);
-
- dbg("priority calculation of connection \"%s\" is %"PRIu32"
(%#"PRIx32")",
- c->name, prio, prio);
+ dbg("priority calculation of connection \"%s\" is %"PRIu32"
(%#"PRIx32") pmax=%u portsw=%u protow=%u, srcw=%u dstw=%u instw=%u",
+ c->name, prio, prio,
+ pmax, portsw, protow, srcw, dstw, instw);
the debug line would be a pita with unit32_t and using unsigned is good
enough.
> _______________________________________________
> 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/20210605/5caca791/attachment.html>
More information about the Swan-dev
mailing list