From patchwork Wed Dec 6 23:49:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10097413 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 E398260567 for ; Wed, 6 Dec 2017 23:49:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D000629ED4 for ; Wed, 6 Dec 2017 23:49:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3F0B2A0E8; Wed, 6 Dec 2017 23:49:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FCDF2A0CD for ; Wed, 6 Dec 2017 23:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751990AbdLFXtX (ORCPT ); Wed, 6 Dec 2017 18:49:23 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57096 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbdLFXtW (ORCPT ); Wed, 6 Dec 2017 18:49:22 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB6Nl5Rh112761; Wed, 6 Dec 2017 23:49:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=wbb0d061xZM+xXilNTSh8t14DrYyRoqNtZv9tiwqiHU=; b=RmQ1J72dEr5LHKgZjAV9dDcOFtiYBkA0Uboa3SNz13X7V3ek1R/djSxMtdwl3bce7L8X pSSgomkbx7oz67sgBIsWu/xactw6cOYImsKbBYPykSXzzcp3Of0/zY9BEfMjCATc9CDA erfqieTWYglCWQ9EXCcru5JE9JAKpegBqsEdTpHQzr5rP6SUTqds40MRplNG8WIjyoZD qKYq10tAqPgAYtfbAlczGj+cmZ4Q1dnGv2ls14T+DAWZOsqtG7wu2Ykqx8jaa0Oivv/8 4Z6GpPrRdL/l9nSwl2OHqSiCx8DpPxabeNoh+D8JP2WJ5w6MP19saDuME7J73iGHJsif jA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2epcvqkk42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Dec 2017 23:49:20 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vB6NnJQL026515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Dec 2017 23:49:19 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vB6NnJLl026569; Wed, 6 Dec 2017 23:49:19 GMT Received: from localhost (/10.145.178.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Dec 2017 15:49:18 -0800 Date: Wed, 6 Dec 2017 15:49:17 -0800 From: "Darrick J. Wong" To: Eric Sandeen Cc: xfs Subject: [PATCH] libxfs: libxfs_nproc should never return negative numbers Message-ID: <20171206234917.GM4910@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8737 signatures=668643 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712060330 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Prevent libxfs_nproc from returning a negative/zero CPU count if platform_nproc happens to error out. Fixes-coverity-id: 1425909 Fixes-coverity-id: 1425910 Fixes-coverity-id: 1425913 Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- libxfs/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/libxfs/init.c b/libxfs/init.c index a007b3b..302f088 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -910,7 +910,12 @@ libxfs_report(FILE *fp) int libxfs_nproc(void) { - return platform_nproc(); + int nr; + + nr = platform_nproc(); + if (nr < 1) + nr = 1; + return nr; } unsigned long