Skip to contentSkip to conversation

Question about redundant copies of json-writer.c

DISCUSSION Jarkko Sakkinen 1 participant 1 message Feb 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Shuah,

I'm working on a kernel patch set where I need to write JSON.

After looking around a bit, I found this C-module with multiple redundant copies scattered around tools/:

❯ find -name json_writer.[ch]
./tools/testing/selftests/bpf/json_writer.h
./tools/testing/selftests/bpf/json_writer.c
./tools/bpf/bpftool/json_writer.h
./tools/bpf/bpftool/json_writer.c
./tools/net/ynl/ynltool/json_writer.h
./tools/net/ynl/ynltool/json_writer.c

My (arbitrary) guess is that one in bpftool is the main copy.

Ssince the module is self-contained, I'm dilating towards doing this:

$(OUTPUT)/kcontainerd: kcontainerd.c ../../../bpf/bpftool/json_writer.c \
                     ../../../bpf/bpftool/json_writer.h
       $(CC) $(CFLAGS) $< ../../../bpf/bpftool/json_writer.c -o $@

(and in kcontainerd.c #include "../../../bpf/bpftool/json_writer.h")

I'm just sanity checking this given that json_writer is utilized with a different pattern :-)

BR, Jarkko