On Tue, 5 Oct 2021 15:40:29 -0400 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > struct trace_pid_list { > unsigned long ignore; > }; > > Rename the above struct trace_pid_list to struct trace_pid_internal. > > And internally have: > > union trace_pid_data { > struct trace_pid_list external; > struct trace_pid_internal internal; > }; > > Then use the internal version within the C file that modifies it, and just > return a pointer to the external part. So this has proved to be a PITA. > > That should follow the "C standard". Really, thinking about abstraction, I don't believe there's anything wrong with returning a pointer of one type, and then typecasting it to a pointer of another type. Is there? As long as whoever uses the returned type does nothing with it. That is, if I simply do: In the header file: struct trace_pid_list { void *ignore; }; struct trace_pid_list *trace_pid_list_alloc(void); void trace_pid_list_free(struct trace_pid_list *pid_list); And then in the C file: struct pid_list { [...] }; struct trace_pid_list *trace_pid_list_alloc(void) { struct pid_list *pid_list; pid_list = kmalloc(sizeof(*pid_list), GFP_KERNEL); [..] return (struct trace_pid_list *)pid_list; } void trace_pid_list_free(struct trace_pid_list *list) { struct pid_list *pid_list = (struct pid_list *)list; [..] kfree(pid_list); } That should be perfectly fine for standard C. Right? -- Steve