Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang format 14 #8

Merged
merged 2 commits into from
May 24, 2024
Merged

Clang format 14 #8

merged 2 commits into from
May 24, 2024

Conversation

rscampos
Copy link

No description provided.

clang-format-14 is support by ubuntu-24.04.
libbpfgo.c Outdated
@@ -6,8 +6,8 @@ extern void perfLostCallback(void *ctx, int cpu, __u64 cnt);
extern int ringbufferCallback(void *ctx, void *data, size_t size);

int libbpf_print_fn(enum libbpf_print_level level, // libbpf print level
const char *format, // format used for the msg
va_list args) // args used by format
const char *format, // format used for the msg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do prefer the old indentation, it resembles Golang formatting. Which clang-format option should be returned?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's AlignTrailingComments.

libbpfgo.c Outdated
Comment on lines 129 to 130
struct bpf_iter_attach_opts *
cgo_bpf_iter_attach_opts_new(__u32 map_fd, enum bpf_cgroup_iter_order order,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can notice that some wrapping is being done due to the limit PenaltyReturnTypeOnItsOwnLine. So some functions with the small signature has the return type and name in the same line and others will have it with break line.

That's my proposal, enforce it as FreeBSD does: https://github.com/freebsd/freebsd-src/blob/main/.clang-format.

Can we give it a try, disregarding the linux one?

libbpfgo.c Outdated
Comment on lines 194 to 197
struct bpf_map_create_opts *cgo_bpf_map_create_opts_new(
__u32 btf_fd, __u32 btf_key_type_id, __u32 btf_value_type_id,
__u32 btf_vmlinux_value_type_id, __u32 inner_map_fd, __u32 map_flags,
__u64 map_extra, __u32 numa_node, __u32 map_ifindex)
Copy link
Owner

@geyslan geyslan May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's other oddity (ugliness)... some functions will align its params using the first line, others like this will break to the next.

@rscampos
Copy link
Author

rscampos commented May 24, 2024

I've pushed a modified PR, without touching .clang_format, in future we can work on that together. Agreed with the suggestions.

@geyslan geyslan merged commit 8f3887a into geyslan:bumps May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants