xen/vsprintf: Avoid returning NULL from number()
PATCH 1/1 xen/vsprintf: Avoid returning NULL from number()
In practice this is an unused codepath, as every caller of number() passes an explicit base of 8, 10 or 16. For all other uses, number() returns a pointer between the str and end parameters, as do the other similar helper functions.
However, the fact that there is a NULL return path causes Coverity to check whether the caller makes NULL checks on the return value, and complain.
Change the conditional return into an ASSERT().
No functional change, but this removes 21 instances of NULL_RETURN in Coverity.
---
CC: Jan Beulich <[email protected]>
--- xen/common/vsprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/common/vsprintf.c +2 -2
@@ -153,11 +153,11 @@ static char *number(static const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;int i; +ASSERT (base >=2 && base <=36 ); + digits = (type &LARGE ) ? large_digits : small_digits;if (type &LEFT ) type &= ~ZEROPAD ; -if (base <2 || base >36 ) -return NULL ; c = (type &ZEROPAD ) ?'0' :' ' ; sign =0 ;if (type &SIGN ) {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.06.16 at 12:00, <[email protected]> wrote:
In practice this is an unused codepath, as every caller of
number()passes an explicit base of 8, 10 or 16. For all other uses,number()returns a pointer
between the str and end parameters, as do the other similar helper functions.However, the fact that there is a NULL return path causes Coverity to check whether the caller makes NULL checks on the return value, and complain.
Quoted 6 lines
Change the conditional return into an
ASSERT().No functional change, but this removes 21 instances of
NULL_RETURNin Coverity.Signed-off-by Andrew Cooper <[email protected]>
But should really have Cc-ed the other REST maintainers.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel