On 7/10/25, 1:45 AM, "Amir Goldstein" <amir73il@xxxxxxxxx <mailto:amir73il@xxxxxxxxx>> wrote: > > IMO, this is shorter and nicer after assigning fd = -ret; above: > > > > if (FAN_GROUP_FLAG(group, FAN_REPORT_FD_ERROR | > > > > FAN_REPORT_RESPONSE_ID)) > > metadata.fd = fd; > > else > > metadata.fd = fd >= 0 ? fd : FAN_NOFD; > > > > And above this code is also a good place to place the build assertion: > > BUILD_BUG_ON(sizeof(metadata.id) != sizeof(metadata.fd)); > BUILD_BUG_ON(offsetof(struct fanotity_event_metadata, id) != offsetof(struct > fanotity_event_metadata, fd)); > > Which provides the justification to use the union fields interchangeably > in this simplified code. > > Thanks, > Amir. I will simplify the code to use union fields interchangeably + add the suggested build assertions and resubmit these soon. It gives a chance to fix the various formatting issues :)