RE: [PATCH v1 2/3] iommu/vt-d: Change dmar_ats_supported() to return boolean
From: Wang, Wei W
Date: Fri May 09 2025 - 07:23:22 EST
On Friday, May 9, 2025 5:27 PM, Liu, Yi L wrote:
/5/9 22:00, Wei Wang wrote:
> > According to "Function return values and names" in coding-style.rst,
> > the
> > dmar_ats_supported() function should return a boolean instead of an
> > integer. Also, rename "ret" to "supported" to be more straightforward.
> >
>
> seems just a recommendation since this is just internal helper. The function
> was indeed not well written anyhow. :) not sure if Baolu wants take it or not.
> Taking it may make history tracking harder. Patch itself looks good to me.
>
> Reviewed-by: Yi Liu <yi.l.liu@xxxxxxxxx>
It seems mandatory to me from coding-style.rst:
"
Mixing up these two sorts of representations is a fertile source of
difficult-to-find bugs. If the C language included a strong distinction
between integers and booleans then the compiler would find these mistakes
for us... but it doesn't. To help prevent such bugs, always follow this
convention::
If the name of a function is an action or an imperative command,
the function should return an error-code integer. If the name
is a predicate, the function should return a "succeeded" boolean.
"
Another reason for making this change is that when we try to add more checks
inside this function (e.g., integrated_device_ats_supported() in patch 3), the added
new function needs to continue following the incorrect style. So, I thought, why
not change it from the foundation 😊