Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools: ynl: make the attr and msg helpers more C++ friendly

Folks working on a C++ codegen would like to reuse the attribute
helpers directly. Add the few necessary casts, it's not too ugly.

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20240529192031.3785761-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+11 -11
+11 -11
tools/net/ynl/lib/ynl-priv.h
··· 79 79 struct ynl_dump_list_type *list; 80 80 81 81 uptr -= offsetof(struct ynl_dump_list_type, data); 82 - list = (void *)uptr; 82 + list = (struct ynl_dump_list_type *)uptr; 83 83 uptr = (unsigned long)list->next; 84 84 uptr += offsetof(struct ynl_dump_list_type, data); 85 85 ··· 139 139 140 140 static inline struct nlmsghdr *ynl_nlmsg_put_header(void *buf) 141 141 { 142 - struct nlmsghdr *nlh = buf; 142 + struct nlmsghdr *nlh = (struct nlmsghdr *)buf; 143 143 144 144 memset(nlh, 0, sizeof(*nlh)); 145 145 nlh->nlmsg_len = NLMSG_HDRLEN; ··· 196 196 197 197 static inline void *ynl_attr_data_end(const struct nlattr *attr) 198 198 { 199 - return ynl_attr_data(attr) + ynl_attr_data_len(attr); 199 + return (char *)ynl_attr_data(attr) + ynl_attr_data_len(attr); 200 200 } 201 201 202 202 #define ynl_attr_for_each(attr, nlh, fixed_hdr_sz) \ ··· 228 228 { 229 229 struct nlattr *attr; 230 230 231 - attr = (void *)((char *)prev + NLA_ALIGN(prev->nla_len)); 231 + attr = (struct nlattr *)((char *)prev + NLA_ALIGN(prev->nla_len)); 232 232 return ynl_attr_if_good(end, attr); 233 233 } 234 234 ··· 237 237 { 238 238 struct nlattr *attr; 239 239 240 - attr = (void *)((char *)start + NLMSG_ALIGN(skip)); 241 - return ynl_attr_if_good(start + len, attr); 240 + attr = (struct nlattr *)((char *)start + NLMSG_ALIGN(skip)); 241 + return ynl_attr_if_good((char *)start + len, attr); 242 242 } 243 243 244 244 static inline bool ··· 262 262 struct nlattr *attr; 263 263 264 264 if (__ynl_attr_put_overflow(nlh, 0)) 265 - return ynl_nlmsg_end_addr(nlh) - NLA_HDRLEN; 265 + return (struct nlattr *)ynl_nlmsg_end_addr(nlh) - 1; 266 266 267 - attr = ynl_nlmsg_end_addr(nlh); 267 + attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); 268 268 attr->nla_type = attr_type | NLA_F_NESTED; 269 269 nlh->nlmsg_len += NLA_HDRLEN; 270 270 ··· 286 286 if (__ynl_attr_put_overflow(nlh, size)) 287 287 return; 288 288 289 - attr = ynl_nlmsg_end_addr(nlh); 289 + attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); 290 290 attr->nla_type = attr_type; 291 291 attr->nla_len = NLA_HDRLEN + size; 292 292 ··· 305 305 if (__ynl_attr_put_overflow(nlh, len)) 306 306 return; 307 307 308 - attr = ynl_nlmsg_end_addr(nlh); 308 + attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); 309 309 attr->nla_type = attr_type; 310 310 311 - strcpy(ynl_attr_data(attr), str); 311 + strcpy((char *)ynl_attr_data(attr), str); 312 312 attr->nla_len = NLA_HDRLEN + NLA_ALIGN(len); 313 313 314 314 nlh->nlmsg_len += NLMSG_ALIGN(attr->nla_len);