From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5534226D4C7; Fri, 27 Jun 2025 10:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751021120; cv=none; b=jOPw3eQhvG2e+HoxH2Gd6YEXwAobyfD796Hrzg3LUFJXrHPAkKsKbQGwOfh2zMtYPOafE0PGPH3XD4j0gVCTkONOzoFN+FwdyWZj9HB7pO0FjqJyaULBEJ4OWgUmEbNaeaC6ILsbrtWAE2y8wcgo219bq3fAxYg4dOUBoOMsBg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751021120; c=relaxed/simple; bh=rOC3ZN61YB87VOjCKjWidgsmHChsG4gpfO2vqW9HwGM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YS8axdIdm/Thpc6nCxxMhjwgtPRH0ZgequvY4x5V42LRTw7GUSZXzoTHxhsLtwNUJkq+TakeABnOUcQvIF5ujsWJaNbHeJL4mZIv/WXJEz8tTylCvkqVI/F5H33o1WGsi9YS7ydlHY3YPUzH0xwIRiq99UJaISVHybjrEXOwnpw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 5D31A1A00; Fri, 27 Jun 2025 03:45:00 -0700 (PDT) Received: from [10.163.36.129] (unknown [10.163.36.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A64A3F58B; Fri, 27 Jun 2025 03:45:14 -0700 (PDT) Message-ID: Date: Fri, 27 Jun 2025 16:15:09 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/arm64: Prevent build warnings from -Wmaybe-uninitialized To: Mark Brown Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250625020138.3777454-1-anshuman.khandual@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 25/06/25 3:54 PM, Mark Brown wrote: > On Wed, Jun 25, 2025 at 03:01:38AM +0100, Anshuman Khandual wrote: > >> @@ -96,7 +96,7 @@ static int write_sleep_read(void) >> static int write_fork_read(void) >> { >> pid_t newpid, waiting, oldpid; >> - int status; >> + int status = 0; >> >> set_tpidr2(getpid()); >> > > This will shut the warnings up, but it's a bit of a heavy hammer that > means that the warning can never trigger warnings for that variable > being unused. Is it possible to fix this by updating the control flow > such that the compiler can tell that the initialisation follows the use? The problem might not exist in reality. In the test function test_fork() in the file tools/testing/selftests/arm64/gcs/basic-gcs.c there does not seem to be a path where WIFEXITED(status) might get called when 'status' has not been initialized as there is a preceding waitpid() which would ensure 'status' gets set. Similar scenarios are present in fork_test_c() and write_fork_read() as well. But the compiler still throws these build warnings. Seems to be false positives and this fix just works around that.