The sr_next_power_of_two() helper routine rejected input value 0
(an index), considered this case invalid. It is not, requires 1 bit
to hold the value. Return a "power of two" value of 1 for that input,
callers expect that result.
if (power)
*power = 0;
- if (!value)
- return SR_ERR_ARG;
+ /*
+ * Handle the special case of input value 0 (needs 1 bit
+ * and results in "power of two" value 1) here. It is not
+ * covered by the generic logic below.
+ */
+ if (!value) {
+ if (bits)
+ *bits = 1;
+ if (power)
+ *power = 1;
+ return SR_OK;
+ }
need_bits = 0;
check_mask = 0;