lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6ffc76fe-f25e-c9e2-8b0a-6548525d3150@amd.com>
Date:   Fri, 3 Jun 2022 10:50:12 +0530
From:   Ravi Bangoria <ravi.bangoria@....com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>, rrichter@....com,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...en8.de>,
        James Clark <james.clark@....com>,
        Leo Yan <leo.yan@...aro.org>, Andi Kleen <ak@...ux.intel.com>,
        Stephane Eranian <eranian@...gle.com>, like.xu.linux@...il.com,
        x86@...nel.org,
        linux-perf-users <linux-perf-users@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Sandipan Das <sandipan.das@....com>, ananth.narayan@....com,
        Kim Phillips <kim.phillips@....com>, santosh.shukla@....com,
        Ravi Bangoria <ravi.bangoria@....com>
Subject: Re: [PATCH v5 4/8] perf headers: Store pmu caps in an array of
 strings

Hi Namhyung,

On 03-Jun-22 3:07 AM, Namhyung Kim wrote:
> On Tue, May 31, 2022 at 8:28 PM Ravi Bangoria <ravi.bangoria@....com> wrote:
>>
>> Currently all capabilities are stored in a single string separated
>> by NULL character. Instead, store them in an array which makes
>> searching of capability easier.
>>
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@....com>
>> ---
> [SNIP]
>> @@ -3231,12 +3226,16 @@ static int process_per_cpu_pmu_caps(struct feat_fd *ff, int *nr_cpu_pmu_caps,
>>                 if (!value)
>>                         goto free_name;
>>
>> -               if (strbuf_addf(&sb, "%s=%s", name, value) < 0)
>> +               name_size = strlen(name);
>> +               value_size = strlen(value);
>> +               ptr = zalloc(sizeof(char) * (name_size + value_size + 2));
>> +               if (!ptr)
>>                         goto free_value;
>>
>> -               /* include a NULL character at the end */
>> -               if (strbuf_add(&sb, "", 1) < 0)
>> -                       goto free_value;
>> +               memcpy(ptr, name, name_size);
>> +               ptr[name_size] = '=';
>> +               memcpy(ptr + name_size + 1, value, value_size);
> 
> What about using asprintf() instead?

Yeah asprintf() would make that code bit simpler. I think I'll have to
respin the series :)

Thanks,
Ravi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ