[PATCH] drm/amdgpu: fix compare_const_fl.cocci warnings

Julia Lawall julia.lawall at lip6.fr
Fri Apr 15 14:20:58 UTC 2016



On Fri, 15 Apr 2016, Christian König wrote:

> Am 15.04.2016 um 09:15 schrieb Julia Lawall:
> > Move constants to the right of binary operators.
> >
> > Generated by: scripts/coccinelle/misc/compare_const_fl.cocci
> >
> > Signed-off-by: Fengguang Wu <fengguang.wu at intel.com>
> > Signed-off-by: Julia Lawall <julia.lawall at lip6.fr>
>
> In general the patch looks ok, but do we have a documented preference where to
> place constants in the coding style docs?
>
> While it's not so much of a problem any more with modern compilers, some
> people still prefer to have it on the left side to catch accidental value
> assignments.

I don't know if it is documented.  Joe Perches suggested that on the right
was better in general - maybe he knows if this is written somewhere.

There are 504 occurrences of NULL == in the kernel, and 19524 occurrences
of == NULL.

julia

>
> Regards,
> Christian.
>
> > ---
> >
> > Could be nice to put the thing being tested first.
> >
> >   amdgpu_grph_object_id_helpers.c |    4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_grph_object_id_helpers.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_grph_object_id_helpers.c
> > @@ -169,11 +169,11 @@ struct graphics_object_id amdgpu_object_
> >   	struct graphics_object_id go_id = { 0 };
> >     	type = object_type_from_bios_object_id(bios_object_id);
> > -	if (OBJECT_TYPE_UNKNOWN == type)
> > +	if (type == OBJECT_TYPE_UNKNOWN)
> >   		return go_id;
> >     	enum_id = enum_id_from_bios_object_id(bios_object_id);
> > -	if (ENUM_ID_UNKNOWN == enum_id)
> > +	if (enum_id == ENUM_ID_UNKNOWN)
> >   		return go_id;
> >     	go_id = display_graphics_object_id_init(
>
>


More information about the dri-devel mailing list