From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92B9AC36002 for ; Wed, 9 Apr 2025 10:25:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 606FB280061; Wed, 9 Apr 2025 06:25:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58CDD28005F; Wed, 9 Apr 2025 06:25:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4525D280061; Wed, 9 Apr 2025 06:25:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2610528005F for ; Wed, 9 Apr 2025 06:25:33 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 812EBB8E3E for ; Wed, 9 Apr 2025 10:25:33 +0000 (UTC) X-FDA: 83314123746.13.083492B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id AA9DFA0008 for ; Wed, 9 Apr 2025 10:25:31 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf25.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744194331; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CqvJ14WZgk/8M9mm5FNPapWatmwfo5b+3T+dGd08F8Y=; b=l/7oi6ybZC0KcZcPAub6rAMdDxtv4PR092DerXKfdLCvsf2bNE4zNec+or2EYfOlRWa4Md obVGkguM9YnrCORejSsxtoi0lNNooISR6ORz45/Q+NcxLc5hxGBGC3oipnbKSxDm+/GLo0 f+6lYWQ8T78IYZCE0uxk25C/IVledrU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf25.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744194331; a=rsa-sha256; cv=none; b=PXMxmwSVb4GYXZrk3EgpIzkOzHWh1V0erEHR5sQhUZp0iMANB9+rsa/vwHDCRP1NM4CRHh O9P3sYqrrrRttTvo5dWvDJ01ydhbe1Y9JARF2lvrtTrH4CuOacmcgurLqADLb4zsHYjoLS S6KWoNKOOL9bBCqFhjxGq/3kU5blvEY= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 688B6106F; Wed, 9 Apr 2025 03:25:31 -0700 (PDT) Received: from [10.162.42.12] (a077893.blr.arm.com [10.162.42.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7F933F59E; Wed, 9 Apr 2025 03:25:28 -0700 (PDT) Message-ID: <5c37c129-a8cb-4f17-8af1-059450083c73@arm.com> Date: Wed, 9 Apr 2025 15:55:25 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/mm: Fix compiler -Wmaybe-uninitialized warning To: David Hildenbrand , linux-mm@kvack.org Cc: Andrew Morton , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250409095006.1422620-1-anshuman.khandual@arm.com> <9da46633-e9c1-42a7-b52b-16cf89836abc@redhat.com> <0ec536d2-4b82-4e97-9985-15cd431059ba@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AA9DFA0008 X-Stat-Signature: rd3c8ysfdfw8kxd4fit1jicgdt4ue15e X-HE-Tag: 1744194331-537757 X-HE-Meta: U2FsdGVkX18eT58ZdbeNHBwwytO2EoKEKtHiupcVwlRUq5Vz5zLPVhoSBuBU9DN/GaQ4pNO+ir/17Q+PGAhFKKiHBjBbret5wKlP95Stfcm5nML2gRNB6dwjznDtnGmVdLYYZJY0nPYz56Plx73DXZ/ecrx2kJQCirs6J3aFV3PRTDFpT2ctA4vvaih+1nmGGnzz3msTIL7iJT4fFLDB7P5LdiJViO6qBDPrcsMJpq+dQcmyARh4QAEM02lOsRogxVCVbogk+BBdT/Ar1QBCbaCTqLd/KV7UGi1G8QsEpoLBKqoBzJ8FRZKx0fTNAL3alJcm6+2lacLfze9WxvL4cStYMFX/LCGFCvFG/cUiOvrKVec+dPilsgGoS3kxGYY3en4OVBn5OZgDdsk0KQawgH2X1xJULg4d3TWuUSGXk2aVtN/b0Wj0lEqH9BfHZnw68MLiF98ojuacuWqA+MjPIKIixzGAvALc2moTGS1/vX5JaZZ0bD+ve8t3kWxSFMulKjW+ofBgfHbiUQ7CcBg4M1Pl/qYJM0DlEA9qwH1hUsCV9S84QlqDFNKNBME6pqsthCAbTYeLPOYVO662vNRo8HyA7fwdYXi/mj22BUUem7gf62845x9RAX7VwKEN01oGCNthmupC3w42zE/BiX2T/RTPFPd/5bPMi7kswMK/hXjKqZxT6U1ZQkljXf33frVPkIJjTteFGQKOsUgE4le9lzPQ6JihvZa2Z3tSkMwZ+EoDRygFKF/Walq+R7eP/nrQcEcUvS1Gs59wNlGpZ6Q9DJdq9xYoth0RSRgFRnSAWnRkWpJVQwk1+uH3NwTHKZCTo0FCEgjJfxKGkuTEPeLqxwYna216MDwS7eHfpvDbdOSPLpzlEXIDqMmWEFla8RPM0s5FLERISuJXooq8K5P8sGRKpghkAOx76bpoWNMB/IN3czzkINP2q6fDGlSec3011kOfEpwnYiaWCSb9o+E myw12LXx wQhH0v2vDVXey9inY/MXoWaTvXaRoBlEn77Jwle6brzOMmFbkdvkKog80uZpGgHTbIs2gkW18r2g/CICiSnFulWPdl9F3VVBHddQD8MNcCSOdb41KaP1c/G3gp2RYepxFVbPS6zT37KpZ2Pa+rpuFv9ElwKYQg5/gbPw65FLdGhFqTMxu2VWMryXLMsVXef17oXW52UEFKCHlXW0A2cyvcLQ79BM6s7YMn5O6IEJTO8XHrOcgln1zqYxj1xcAJeTYop/DJGi5hkrVgMXOVSn1Gzh7DQUqC/smhGwm5ai11fQj2GmA2tL2ozr+VC39m/pwcoLIHSYEYoZCkCtGhNMmTtaLSyI0GVGWC7wmL4Wvzqh/OBk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 4/9/25 15:51, David Hildenbrand wrote: > On 09.04.25 12:09, Anshuman Khandual wrote: >> >> >> On 4/9/25 15:27, David Hildenbrand wrote: >>> On 09.04.25 11:50, Anshuman Khandual wrote: >>>> Following build warning comes up for cow test as 'transferred' variable has >>>> not been initialized. Fix the warning via zero init for the variable. >>>> >>>>     CC       cow >>>> cow.c: In function ‘do_test_vmsplice_in_parent’: >>>> cow.c:365:61: warning: ‘transferred’ may be used uninitialized [-Wmaybe-uninitialized] >>>>     365 |                 cur = read(fds[0], new + total, transferred - total); >>>>         |                                                 ~~~~~~~~~~~~^~~~~~~ >>>> cow.c:296:29: note: ‘transferred’ was declared here >>>>     296 |         ssize_t cur, total, transferred; >>>>         |                             ^~~~~~~~~~~ >>>>     CC       compaction_test >>>>     CC       gup_longterm >>>> >>>> Cc: Andrew Morton >>>> Cc: Shuah Khan >>>> Cc: linux-mm@kvack.org >>>> Cc: linux-kselftest@vger.kernel.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Signed-off-by: Anshuman Khandual >>>> --- >>>>    tools/testing/selftests/mm/cow.c | 2 +- >>>>    1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c >>>> index f0cb14ea8608..b6cfe0a4b7df 100644 >>>> --- a/tools/testing/selftests/mm/cow.c >>>> +++ b/tools/testing/selftests/mm/cow.c >>>> @@ -293,7 +293,7 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size, >>>>            .iov_base = mem, >>>>            .iov_len = size, >>>>        }; >>>> -    ssize_t cur, total, transferred; >>>> +    ssize_t cur, total, transferred = 0; >>>>        struct comm_pipes comm_pipes; >>>>        char *old, *new; >>>>        int ret, fds[2]; >>> >>> >>> if (before_fork) { >>>      transferred = vmsplice(fds[1], &iov, 1, 0); >>> ... >>> >>> if (!before_fork) { >>>      transferred = vmsplice(fds[1], &iov, 1, 0); >>> ... >>> >>> for (total = 0; total < transferred; total += cur) { >>> ... >>> >>> >>> And I don't see any jump label that could jump to code that would ve using transferred. >>> >>> What am I missing? >> >> Probably because both those conditional statements are not mutually >> exclusive above with an if-else construct. Hence compiler flags it >> rather as a false positive ? Initializing with 0 just works around >> that false positive. > > This is something the compiler should clearly be able to verify. before_fork is never changed in that function. > > We should not work around wrong compilers. > > Which compiler are you using such that you run into this issue? gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0