Re: [PATCH net-next] tools: ynl: make ynl.c more c++ friendly

From: Jakub Kicinski
Date: Thu Aug 14 2025 - 20:05:27 EST


On Thu, 14 Aug 2025 16:36:25 -0700 Stanislav Fomichev wrote:
> > As I mentioned in person, ynl-cpp is a separate thing, and you'd all
> > benefit from making it more C++ than going the other way and massaging
> > YNL C.
> >
> > With that said, commenting below on the few that I think would be okay.
>
> Ok, and the rest (typecasts mostly and the namespace) - you're not supper
> happy about? I can drop that test_cpp if that helps :-)

No, they are illogical from C's standpoint :(
I really don't get the need for the adjustments, the code generator is
obviously different for C++, and that's a major effort. The ynl.c casts
are trivial in comparison.

> > > @@ -149,7 +153,7 @@ ynl_err_walk(struct ynl_sock *ys, void *start, void *end, unsigned int off,
> > > return n;
> > > }
> > >
> > > - data_len = end - start;
> > > + data_len = (char *)end - (char *)start;
> >
> > can we make the arguments char * instead of the casts?
>
> Let me try. That might require to char-ify helpers like ynl_nlmsg_data_offset
> and ynl_nlmsg_end_addr.

Hm, then probably let's leave it as void *