From patchwork Thu Jun 9 10:00:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9166685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13E716048F for ; Thu, 9 Jun 2016 10:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A7B28328 for ; Thu, 9 Jun 2016 10:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC60A28047; Thu, 9 Jun 2016 10:02:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86C1528047 for ; Thu, 9 Jun 2016 10:02:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAwlG-0000Cp-7L; Thu, 09 Jun 2016 10:00:26 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAwlF-0000CV-15 for xen-devel@lists.xen.org; Thu, 09 Jun 2016 10:00:25 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id A8/22-25713-83E39575; Thu, 09 Jun 2016 10:00:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKLMWRWlGSWpSXmKPExsXitHSDva65XWS 4we4nlhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b3Qy/YCr5zVvR/ucLWwPiZvYuRg0NCwF/i 4jfTLkZODjYBfYndLz4xgdgiAuoSpzsusoKUMAv4SRx64AsSFhZwlDj39SMLiM0ioCIx6VkXC 0gJr4CnxIs5jCBhCQE5ifPHfzKD2EICahLX+i+xg9i8AoISJ2c+AWtlFpCQOPjiBTNEPbfE7d NTmScw8sxCUjYLSdkCRqZVjOrFqUVlqUW6xnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXr J+bmbGIHBwQAEOxg7/jkdYpTkYFIS5X1iHRkuxJeUn1KZkVicEV9UmpNafIhRhoNDSYK3zBYo J1iUmp5akZaZAwxTmLQEB4+SCG8aSJq3uCAxtzgzHSJ1ilFRSpzXBSQhAJLIKM2Da4PFxiVGW SlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ8xaATOHJzCuBm/4KaDET0OLlR8JBFpckIqSkGhjbz/ ds+uVUnjNB6SCD+o7dTh6nF+w6aXm5nKcqz7V9fcU1i0+1cZUZjVzb1045vOuB75d9es6n5L5 +mbZJNfznpLkfvwY9+77qbUjLjl+6689fvO1yXuJ222qRL035LOZ/bnaJzvtl8/7YxW+/TX+b TBR4e+z/4agyt/+rmIsV3B6G8J5k4hGdrcRSnJFoqMVcVJwIAPArJqSIAgAA X-Env-Sender: prvs=961d0c8cc=Andrew.Cooper3@citrix.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1465466422!18217715!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44717 invoked from network); 9 Jun 2016 10:00:23 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-12.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Jun 2016 10:00:23 -0000 X-IronPort-AV: E=Sophos;i="5.26,444,1459814400"; d="scan'208";a="366212253" From: Andrew Cooper To: Xen-devel Date: Thu, 9 Jun 2016 11:00:20 +0100 Message-ID: <1465466420-20352-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH] xen/vsprintf: Avoid returning NULL from number() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich --- xen/common/vsprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index b050ea3..f92fb67 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -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) {