Re: [PATCH v2 0/2] cpupower: fix topology array handling

Shuah Khan <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/5/26 05:43, Ali Ahmet Memis wrote:
> On Tue, 4 Aug 2026 14:45:48 -0600 Shuah Khan wrote:
>> Did you think about a scenario when the following check will be tru - i.e
>> core == -1 is trur?
> 
> I went looking for one and could not find it, so that branch may well be
> dead. What I checked:

That is really the questions - the branch isn't dead, it is in the wrong
place.

Sounds like you don't have a real scenario to test this change. This why
I am not eager to take either of these patches.

However, did you consider simplifying the logic in these conditionals?


if(sysfs_topology_read_file(
                         cpu,
                         "physical_package_id",
                         &(cpu_top->core_info[cpu].pkg)) < 0) {
                         cpu_top->core_info[cpu].pkg = -1;
                         cpu_top->core_info[cpu].core = -1;
                         continue;

-- Is this continue necessary here?

                 }
                 if(sysfs_topology_read_file(
                         cpu,
                         "core_id",
                         &(cpu_top->core_info[cpu].core)) < 0) {
                         cpu_top->core_info[cpu].pkg = -1;
                         cpu_top->core_info[cpu].core = -1;
                         continue;

-- Is this continue necessary here?

                 }

I think the following logic makes sense without the continue(s)

                 if (cpu_top->core_info[cpu].core == -1) {
                         strncpy(cpu_top->core_info[cpu].core_cpu_list, "-1", CPULIST_BUFFER);
                         continue;
                 }

thanks,
-- Shuah
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.