Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the spirit of (incrementally) reducing the verbosity of drgn, I noticed that the bitops APIs could use a bit of improvement.
First, the documentation indicated that they take an
unsigned long *
, so I assumed I needed to cast my array to a pointer, which is a pretty verbose operation. But reading the code, I could see that it worked perfectly fine on arrays, and also on pointers/arrays to any unsigned integer type. (And later, I noticed even the tests use an arrray rather than pointer). So this PR updates that documentation and explicitly tests a wider range of integer types (just to be sure). That way future users would know they can provide the bitfield directly without the casting.Second, it seems like sized array types are relatively common in the kernel for bit fields (e.g.
cpuinfo_x86.x86_capability
link), and for these, we can infer the size parameter. So this PR makes it optional to provide that parameter.Now with the clearer documentation and optional parameter, it's a lot easier: