Re: [PATCH bpf-next v6 3/5] bpftool: generated shadow variables for struct_ops maps.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2/29/24 14:25, Andrii Nakryiko wrote:
On Wed, Feb 28, 2024 at 10:45 PM Kui-Feng Lee <thinker.li@xxxxxxxxx> wrote:

... skipped ...
+static int gen_st_ops_shadow(const char *obj_name, struct btf *btf, struct bpf_object *obj)
+{
+       int err, st_ops_cnt = 0;
+       struct bpf_map *map;
+       char ident[256];
+
+       if (!btf)
+               return 0;
+
+       /* Generate the pointers to shadow types of
+        * struct_ops maps.
+        */
+       bpf_object__for_each_map(map, obj) {
+               if (bpf_map__type(map) != BPF_MAP_TYPE_STRUCT_OPS)
+                       continue;
+               if (!get_map_ident(map, ident, sizeof(ident)))
+                       continue;
+
+               if (!st_ops_cnt++)

goodness, too much operator precedence knowledge assumed, I simplified
this to what I can follow myself:

if (st_ops_cnt == 0)
     printf(...);
st_ops_cnt++;

I don't think saving one line of code is worth it.

It is totally reasonable.

Thanks for review!




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux