On Sat, 5 Jun 2021 at 15:27, D. Hugh Redelmeier <[email protected]> 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
> [email protected]
> https://lists.libreswan.org/mailman/listinfo/swan-dev
>
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev

Reply via email to