Coverity doesn't know at this point that fr_high_bit_pos() will
necessarily return a value between 5 and 64, so that ret will
have a value in {1, 2, ..., 8}, NOT
2305843009213693952. We add
a check only coverity will see to convince it there is no overflow.
uint8_t swapped[sizeof(uint64_t)];
ret = ROUND_UP_DIV((size_t)fr_high_bit_pos(num | 0x80), 8);
+#ifdef __COVERITY__
+ /*
+ * Coverity doesn't realize that ret is necessarily <= 8,
+ * so we give it a hint.
+ */
+ if (ret > 8) return 0;
+#endif
fr_nbo_from_uint64(swapped, num);
memcpy(out, (swapped + (sizeof(uint64_t) - ret)), ret); /* aligned */