From patchwork Thu May 17 15:56:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10407061 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 1EEF660247 for ; Thu, 17 May 2018 15:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08A1F28535 for ; Thu, 17 May 2018 15:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED631285BD; Thu, 17 May 2018 15:57:17 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A6E9728535 for ; Thu, 17 May 2018 15:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbeEQP5Q (ORCPT ); Thu, 17 May 2018 11:57:16 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:45548 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610AbeEQP5P (ORCPT ); Thu, 17 May 2018 11:57:15 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4HFoPA3013383; Thu, 17 May 2018 08:57:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=ES84ORqv9FlOeMyLoJtvPYFtvDcotyfADmczjRbMUvc=; b=UEvOysVgXFly9QSTahsziWOjwFgyn2c6M0OFH8DAswrqUihA1aed0joT3yURM1ieQimf qpgyEkaGZyHsfzeQSBiHOhHXmaggA7Dvy4pMYDQUbi7mEUbIPQqyyCwOxw6QBx3TW47g GmBuWhDukEp+assRPogG0VIzzvYgQQC48Eo= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2j17eq8uec-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 17 May 2018 08:57:12 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.29) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 17 May 2018 11:57:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ES84ORqv9FlOeMyLoJtvPYFtvDcotyfADmczjRbMUvc=; b=cAwaVDlzMpgfpipr7IrQVs8EIhROx0khtpLJyvWJoWfawQY9qn/UPgDvOOSpC9xEc8xhUMN6oz8pXf+PwecdALQr3EVy+eftQq0tyMrIOYQYVb4YGAp1E6bKZk3BFvIXxP7GzMgyM0khPhk+nUoWTQmPKn4Ro9ckh6MLHUv8RfM= Received: from castle.DHCP.thefacebook.com (2620:10d:c092:200::1:b68d) by CO1PR15MB1077.namprd15.prod.outlook.com (2a01:111:e400:7b66::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Thu, 17 May 2018 15:57:07 +0000 Date: Thu, 17 May 2018 16:56:51 +0100 From: Roman Gushchin To: Dan Carpenter CC: Subject: Re: [bug report] selftests: cgroup: add memory controller self-tests Message-ID: <20180517155646.GA1134@castle.DHCP.thefacebook.com> References: <20180517132225.GA13289@mwanda> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180517132225.GA13289@mwanda> User-Agent: Mutt/1.9.2 (2017-12-15) X-Originating-IP: [2620:10d:c092:200::1:b68d] X-ClientProxiedBy: AM5PR0402CA0011.eurprd04.prod.outlook.com (2603:10a6:203:90::21) To CO1PR15MB1077.namprd15.prod.outlook.com (2a01:111:e400:7b66::7) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CO1PR15MB1077; X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1077; 3:3nNarUZ3oETJOkmsqTSqQecVOrAF9RVk3hyu+586tVLm18YYjNuninv00YMUfYZuwLIC676iYTZDHnIlBZd8VACRaXW4Ig2NerPY3bl82aFQ440FCDhBGxNR4tcQUNLuVfqAMb6fejNaseiRPLIzk5QrXTNRMQFwwG/NmCQipDzVWhcLp1F9JExqoC2ckwnh1xLRnUduunNOgagnH4bQlZ7jKfXfJUxowq3chgwUQ17jSO/tc1SvQ+jUsNAwSvlq; 25:YURcR5rKqVHS9gW3u9ilSIoE1J8kEjHX/8JeDXdF0ivMCofEe2h4E+L6bdgeMqqArVikRBX2eBqEqLy8kcUKU/S7SYv+RiupewYODqG5b6VX236n8y6T4Rbxo62lGrh4OjMLcEnTHmwVTcftQcDqLkFYV1nWctnlIjyC7pB889SI/UH472xhNu2Z7S7FAeAqZuQLlqMKfvFXI0GK+b2FLdaVuIjbsjRnnjyCYi7e9r/nNHEqagJZC7ML5YkKuv2R35VOdM8351oXxIEp5SHZrokK1yHdkflwnjGZrx4jjkXSP4E+U1hbC4T74euXBGFZSAacTzu9UkVsyxnErzAxCA==; 31:xf9snG5Egja/Kf1RCdTyv4R7Mu7jMWjlSgTjaIyyV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l8K69jNmEa1eJ8bp5g8ARaOxUNNudKxaYUc6fI8LPpbncKfa4PvTcasRrzHgaa4ahI94FRYsYlGLUeGibCY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(67672495146484)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231254)(11241501184)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:CO1PR15MB1077; BCL:0; PCL:0; RULEID:; SRVR:CO1PR15MB1077; X-Forefront-PRVS: 067553F396 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(396003)(376002)(366004)(39860400002)(39380400002)(199004)(189003)(486006)(9686003)(2906002)(53936002)(305945005)(6916009)(59450400001)(1076002)(11346002)(23726003)(53546011)(476003)(6666003)(446003)(6506007)(386003)(52396003)(52116002)(6116002)(106356001)(345774005)(7696005)(47776003)(8936002)(6246003)(105586002)(81156014)(81166006)(4326008)(8676002)(5660300001)(33656002)(55016002)(86362001)(575784001)(7736002)(50466002)(58126008)(316002)(25786009)(97736004)(478600001)(76176011)(16526019)(68736007)(46003)(16586007)(229853002)(186003)(18370500001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR15MB1077; H:castle.DHCP.thefacebook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO1PR15MB1077; 23:tNIQN7380Nc1sNzeRRjXEhQd1IYxBSRrRJH2+BTt7?= =?us-ascii?Q?XKGZ9Wa+3ZmbRDtrSLGOgmnyaeMvkurtzEclAhWL5Sq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YzUN3Rz1ommFfKesNvhGuf7SGpoR9B0UpIT3a03j2FiHjBbiHfPbsXdN8Y4NAEeV1Lfj+tph99DflCJ1PiHg9LnxyRSIIbuzjkcshicQXFtYjNpSMzw05wg==; 5:oQuE4BSdUYJ8L3P6wEAAE83VMQ3j1Ia8hs/E9IL61iNe0pqOZNlpXfPvstdUGD8cxXX/ZSBbC5xZ/AxXVjCXNn6pxL5IuT+SiV6CNEfHZgTeqtwraaldPIpnzVTfy+tKYD/7Jzc2CBG/7a8q+VMqSFPuzTUB1mExOsTN+IgrJ4k=; 24:TORPLcxCA7mv4EM5tl3xznsOQJ0jYZkb58IG5KSP4eVX9gU0z0FOeyirAAH0vSRM0cNOw24mPeteUE5hf28lDriRqw5dv3HArkhBTumxq3Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1077; 7:KcI3Bi3KdJ6lQ1ueSffxylJZx5IVI0sqsitZuCZ6u0ninBLKKc7Q+5ek03AFRkIvJsEAEkA2d8GmJzbhVQMYyp638b6mThdI8JjV82KWLTl3frVuG7Tex/DOHB/nYA5fwObbRvz6O2/yRygVV8qrZBw7pehOgvM9yOCdXnsEIcIs8yU4bP5ozFgtRclXIjCXhzNhJ/GBkJl5eUf1K+DEShcNy24AW5kDS/+S+KgzryyhmsVDJQP+aMrQUf3V75ZE; 20:v7/Wc8TM50dvPM1t3gr09KlKd/7c0Rzpy5AS3OSfGhGaI39ZkM8Keagcj1Npfqp2NuD1dMaezKGFqMd6cPrsihgqTgg77vRCzAv4AXvWQYlQQQqz1K9Kr84M/TAmj+VkGCly4CUZSfr/xY7JPN9T5lHqJxps76xDpQkUk8N+Mt4= X-MS-Office365-Filtering-Correlation-Id: ec3b5c38-0965-46fb-8b1d-08d5bc0ed825 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2018 15:57:07.7508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec3b5c38-0965-46fb-8b1d-08d5bc0ed825 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1077 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-17_08:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, May 17, 2018 at 04:22:25PM +0300, Dan Carpenter wrote: > Hello Roman Gushchin, > > The patch a62213fe9b77: "selftests: cgroup: add memory controller > self-tests" from May 11, 2018, leads to the following static checker > warning: > > ./tools/testing/selftests/cgroup/cgroup_util.c:62 cg_name() > warn: variable dereferenced before check 'name' (see line 59) > Hi Dan! Thank you for the report! The fix is below. Roman --- From ec990dc816b0a36201bed84e5b38b928b9bb9138 Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date: Thu, 17 May 2018 16:53:15 +0100 Subject: [PATCH] kselftest/cgroup: fix variable dereferenced before check warning cg_name(const char *root, const char *name) is always called with non-empty root and name arguments, so there is no sense in checking it in the function body (after using in strlen()). Signed-off-by: Roman Gushchin Reported-by: Dan Carpenter Cc: linux-kselftest@vger.kernel.org --- tools/testing/selftests/cgroup/cgroup_util.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c index 41cc3b5e5be1..b69bdeb4b9fe 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/cgroup_util.c @@ -59,8 +59,7 @@ char *cg_name(const char *root, const char *name) size_t len = strlen(root) + strlen(name) + 2; char *ret = malloc(len); - if (name) - snprintf(ret, len, "%s/%s", root, name); + snprintf(ret, len, "%s/%s", root, name); return ret; } @@ -70,8 +69,7 @@ char *cg_name_indexed(const char *root, const char *name, int index) size_t len = strlen(root) + strlen(name) + 10; char *ret = malloc(len); - if (name) - snprintf(ret, len, "%s/%s_%d", root, name, index); + snprintf(ret, len, "%s/%s_%d", root, name, index); return ret; }