<div dir="ltr"><div dir="ltr"><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 5 Jun 2021 at 15:27, D. Hugh Redelmeier <<a href="mailto:hugh@mimosa.com">hugh@mimosa.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In 8b254f86c6740a4eb900e481c9c21e8da745b130<br>
before: the type for a priority was unsigned, 32 bit.<br>
<br>
Actual bits within that were allocated and documented.<br>
<br>
After: the type was changed to unsigned.  Comments and a passert were <br>
added to make it clear that the type must be at least 32 bits:<br>
<br>
-       uint32_t pmax =<br>
+       /* XXX: assume unsigned >= 32-bits */<br>
+       passert(sizeof(unsigned) >= sizeof(uint32_t));<br>
+<br>
+       unsigned pmax =<br>
<br>
Why change this from uint32_t?<br></blockquote><div><br></div><div>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).</div><div><br></div>Below is some actual context:</div><div class="gmail_quote"><div><br></div><div>commit 8b254f86c6740a4eb900e481c9c21e8da745b130<br>Date:   Fri Jun 4 20:41:00 2021 -0400<br><br>    connections: log priority in more detail<br></div><div><br></div><div>        /* ensure an instance of a template/OE-group always has preference */<br>-       uint32_t instw = (c->kind == CK_INSTANCE ? 0u : 1u);<br>+       unsigned instw = (c->kind == CK_INSTANCE ? 0u : 1u);<br> <br>        uint32_t prio = pmax - (portsw << 18 | protow << 17 | srcw << 9 | dstw << 1 | instw);<br>-<br>-       dbg("priority calculation of connection \"%s\" is %"PRIu32" (%#"PRIx32")",<br>-           c->name, prio, prio);<br>+       dbg("priority calculation of connection \"%s\" is %"PRIu32" (%#"PRIx32") pmax=%u portsw=%u protow=%u, srcw=%u dstw=%u instw=%u",<br>+           c->name, prio, prio,<br>+           pmax, portsw, protow, srcw, dstw, instw);<br></div><div><br></div><div></div><div>the debug line would be a pita with unit32_t and using unsigned is good enough.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
_______________________________________________<br>
Swan-dev mailing list<br>
<a href="mailto:Swan-dev@lists.libreswan.org" target="_blank">Swan-dev@lists.libreswan.org</a><br>
<a href="https://lists.libreswan.org/mailman/listinfo/swan-dev" rel="noreferrer" target="_blank">https://lists.libreswan.org/mailman/listinfo/swan-dev</a><br>
</blockquote></div></div>