Hi Wolfram,

Thanks for the feedback.

> Subject: Re: [PATCH] phy: renesas: phy-rcar-gen2: Fix the array off by one
> warning
> 
> >             error = of_property_read_u32(np, "reg", &channel_num);
> > -           if (error || channel_num > 2) {
> > +           if (error || channel_num > data->last_channel) {
> 
> Just an idea, I haven't tested it: Couldn't we use
> ARRAY_SIZE(data->select_value) to avoid the extra member in the struct?

I checked this now. It is giving the below build errors

In file included from ./include/linux/kernel.h:16:0,
                 from ./include/linux/clk.h:16,
                 from drivers/phy/renesas/phy-rcar-gen2.c:10:
drivers/phy/renesas/phy-rcar-gen2.c: In function 'rcar_gen2_phy_probe':
./include/linux/build_bug.h:16:45: error: negative width in bit-field 
'<anonymous>'
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                             ^
./include/linux/compiler.h:351:28: note: in expansion of macro 
'BUILD_BUG_ON_ZERO'
 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                            ^
./include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                           ^
drivers/phy/renesas/phy-rcar-gen2.c:398:30: note: in expansion of macro 
'ARRAY_SIZE'
   if (error || channel_num > ARRAY_SIZE(data->select_value)) {
                              ^
scripts/Makefile.build:278: recipe for target 
'drivers/phy/renesas/phy-rcar-gen2.o' failed

regards,
Biju


Reply via email to