lib: cbprintf: improve coverage

Providing a literal width or precision that exceeds the non-negative
range of int does not appear to be rejected by the standard, but it
does produce a build diagnostic so we can't test it.  Switch to an
equivalent form that doesn't affect line coverage.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-12-12 13:09:44 -06:00 committed by Carles Cufí
commit 0bc01822a2

View file

@ -360,10 +360,8 @@ static inline const char *extract_width(struct conversion *conv,
if (sp != wp) {
conv->width_present = true;
conv->width_value = width;
if (width != conv->width_value) {
/* Lost width data */
conv->unsupported = true;
}
conv->unsupported |= ((conv->width_value < 0)
|| (width != (size_t)conv->width_value));
}
return sp;
@ -396,10 +394,8 @@ static inline const char *extract_prec(struct conversion *conv,
size_t prec = extract_decimal(&sp);
conv->prec_value = prec;
if (prec != conv->prec_value) {
/* Lost precision data */
conv->unsupported = true;
}
conv->unsupported |= ((conv->prec_value < 0)
|| (prec != (size_t)conv->prec_value));
return sp;
}