lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] kernel/bpf: change "char *" string form to "char []"
From
Date


在 2022年05月13日 04:59, Daniel Borkmann 写道:
> On 5/12/22 7:08 PM, liqiong wrote:
>> 在 2022年05月12日 23:16, Yonghong Song 写道:
>>>
>>> On 5/12/22 7:28 AM, liqiong wrote:
>>>> The string form of "char []" declares a single variable. It is better
>>>> than "char *" which creates two variables.
>>>
>>> Could you explain in details about why it is better in generated codes?
>>> It is not clear to me why your patch is better than the original code.
>>
>> The string form of "char *" creates two variables in the final assembly output,
>> a static string, and a char pointer to the static string. Use "objdump -S -D *.o",
>> can find out the static string occurring at "Contents of section .rodata".
>
> There are ~360 instances of this type in the tree from a quick grep, do you
> plan to convert all them ?

Hi daniel,

I have fixed all the string form in kernel tree, summited two patches.
Have searched the kernel tree by "grep -nHre char.*\*.*=.*\"", and checked all the "char *foo = "bar" "
string form, only five instances are needed to fix in bpf direcotry (2 files) and trace directory (2 files).
In most cases, need a char pointer anyway, just like this:

[const] char *foo = "bar";
if (xxx)
foo = "blash";

In this situation, can't change "char *foo" to "char foo[]".

This work was published in "KernelJanitors/Todo". So, I fixed.

Thanks.

>
> Thanks,
> Daniel

\
 
 \ /
  Last update: 2022-05-13 04:05    [W:2.737 / U:1.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site