On Thu, Jul 26, 2018 at 04:37:14PM -0600, Jason Gunthorpe wrote: > This clearly indicates that the input is a bitwise combination of values > in an enum, and identifies which enum contains the definition of the bits. > > Special accessors are provided that handle the mandatory validation of the > allowed bits and enforce the correct type for bitwise flags. > > If we had introduced this at the start then the kabi would have uniformly > used u64 data to pass flags, however today there is a mixture of u64 and > u32 flags. All places are converted to accept both sizes and the accessor > fixes it. This allows all existing flags to grow to u64 in future without > any hassle. > > Finally all flags are, by definition, optional. If flags are not passed > the accessor does not fail, but provides a value of zero. > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > --- <...> > > +/* > + * An input value that is a bitwise combination of values of _enum_type. > + * This permits the flag value to be passed as either a u32 or u64, it must > + * be retrieved via uverbs_get_flag(). > + */ > +#define UVERBS_ATTR_FLAGS_IN(_attr_id, _enum_type, ...) \ > + UVERBS_ATTR_PTR_IN( \ > + _attr_id, \ Why did you put BUILD_BUG_ON_ZERO into UVERBS_ATTR_SIZE? Wasn't it be better to write it like this? + BUILD_BUG_ON_ZERO(!sizeof(_enum_type *)); \ + UVERBS_ATTR_SIZE(sizeof(u32), sizeof(u64)), \ + __VA_ARGS__) > + UVERBS_ATTR_SIZE(sizeof(u32) + BUILD_BUG_ON_ZERO( \ > + !sizeof(_enum_type *)), \ > + sizeof(u64)), \ > + __VA_ARGS__) > + Thanks
Attachment:
signature.asc
Description: PGP signature