Message ID | 20191022132522.GA12072@embeddedor (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: i2c: adv748x: Fix unsafe macros | expand |
Hi Gustavo, On 22/10/2019 14:25, Gustavo A. R. Silva wrote: > Enclose multiple macro parameters in parentheses in order to > make such macros safer and fix the Clang warning below: > > drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' > has lower precedence than '|'; '|' will be evaluated first > [-Wbitwise-conditional-parentheses] > > ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable > ? ctrl->val - 1 : 0); > > Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") > Reported-by: Dmitry Vyukov <dvyukov@google.com> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Thanks, You beat me to posting - but that looks incredibly close (identical I think) to the one I had prepared. Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/i2c/adv748x/adv748x.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h > index 5042f9e94aee..fccb388ce179 100644 > --- a/drivers/media/i2c/adv748x/adv748x.h > +++ b/drivers/media/i2c/adv748x/adv748x.h > @@ -394,10 +394,10 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, > > #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) > #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) > -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v) > +#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) > > #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) > -#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, r+1)) & m) > +#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m)) > #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) > > #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) > @@ -405,11 +405,11 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, > > #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) > #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) > -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v) > +#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v)) > > #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) > #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) > -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v) > +#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) > > #define tx_read(t, r) adv748x_read(t->state, t->page, r) > #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v) >
On Tue, Oct 22, 2019 at 08:25:22AM -0500, Gustavo A. R. Silva wrote: > Enclose multiple macro parameters in parentheses in order to > make such macros safer and fix the Clang warning below: > > drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' > has lower precedence than '|'; '|' will be evaluated first > [-Wbitwise-conditional-parentheses] > > ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable > ? ctrl->val - 1 : 0); > > Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") > Reported-by: Dmitry Vyukov <dvyukov@google.com> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com It doesn't look like this was picked up? I still see this warning on 5.5-rc6 and next-20200113. If it helps: Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> > --- > drivers/media/i2c/adv748x/adv748x.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h > index 5042f9e94aee..fccb388ce179 100644 > --- a/drivers/media/i2c/adv748x/adv748x.h > +++ b/drivers/media/i2c/adv748x/adv748x.h > @@ -394,10 +394,10 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, > > #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) > #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) > -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v) > +#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) > > #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) > -#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, r+1)) & m) > +#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m)) > #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) > > #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) > @@ -405,11 +405,11 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, > > #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) > #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) > -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v) > +#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v)) > > #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) > #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) > -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v) > +#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) > > #define tx_read(t, r) adv748x_read(t->state, t->page, r) > #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v) > -- > 2.23.0 >
Hi! Quoting Nathan Chancellor <natechancellor@gmail.com>: > On Tue, Oct 22, 2019 at 08:25:22AM -0500, Gustavo A. R. Silva wrote: >> Enclose multiple macro parameters in parentheses in order to >> make such macros safer and fix the Clang warning below: >> >> drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' >> has lower precedence than '|'; '|' will be evaluated first >> [-Wbitwise-conditional-parentheses] >> >> ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable >> ? ctrl->val - 1 : 0); >> >> Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") >> Reported-by: Dmitry Vyukov <dvyukov@google.com> >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com > > It doesn't look like this was picked up? I still see this warning on > 5.5-rc6 and next-20200113. > > If it helps: > > Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> > Thank you, Nathan! :) Friendly ping: Who can take this? It's been almost three months now since I first sent this patch out. Thanks! -- Gustavo >> --- >> drivers/media/i2c/adv748x/adv748x.h | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/i2c/adv748x/adv748x.h >> b/drivers/media/i2c/adv748x/adv748x.h >> index 5042f9e94aee..fccb388ce179 100644 >> --- a/drivers/media/i2c/adv748x/adv748x.h >> +++ b/drivers/media/i2c/adv748x/adv748x.h >> @@ -394,10 +394,10 @@ int adv748x_write_block(struct adv748x_state >> *state, int client_page, >> >> #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) >> #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) >> -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v) >> +#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) >> >> #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) >> -#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | >> hdmi_read(s, r+1)) & m) >> +#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | >> hdmi_read(s, (r)+1)) & (m)) >> #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) >> >> #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) >> @@ -405,11 +405,11 @@ int adv748x_write_block(struct adv748x_state >> *state, int client_page, >> >> #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) >> #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) >> -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v) >> +#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & >> ~(m)) | (v)) >> >> #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) >> #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) >> -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v) >> +#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) >> >> #define tx_read(t, r) adv748x_read(t->state, t->page, r) >> #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v) >> -- >> 2.23.0 >>
On Thu, Jan 16, 2020 at 1:45 PM Gustavo A. R. Silva <gustavo@embeddedor.com> wrote: > > Hi! > Friendly ping: > > Who can take this? > > It's been almost three months now since I first sent this patch out. Kieran is listed as maintainer of: 998 F: drivers/media/i2c/adv748x/* but I'm guessing the tree would be Mauro's. It would be good if Kieran can review, then Mauro can pick up?
Hi Nick On 16/01/2020 21:51, Nick Desaulniers wrote: > On Thu, Jan 16, 2020 at 1:45 PM Gustavo A. R. Silva > <gustavo@embeddedor.com> wrote: >> >> Hi! >> Friendly ping: >> >> Who can take this? >> >> It's been almost three months now since I first sent this patch out. > > Kieran is listed as maintainer of: > 998 F: drivers/media/i2c/adv748x/* > > but I'm guessing the tree would be Mauro's. It would be good if > Kieran can review, then Mauro can pick up? Already done on the 22nd October 2019: https://lore.kernel.org/linux-media/22780ef3-514e-d013-1da8-9576780fde1c@ideasonboard.com/ Hans, Should this go through you? Or are we just waiting for Mauro to pick it up?
On 1/14/20 12:14 AM, Nathan Chancellor wrote: > On Tue, Oct 22, 2019 at 08:25:22AM -0500, Gustavo A. R. Silva wrote: >> Enclose multiple macro parameters in parentheses in order to >> make such macros safer and fix the Clang warning below: >> >> drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' >> has lower precedence than '|'; '|' will be evaluated first >> [-Wbitwise-conditional-parentheses] >> >> ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable >> ? ctrl->val - 1 : 0); >> >> Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") >> Reported-by: Dmitry Vyukov <dvyukov@google.com> >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com > > It doesn't look like this was picked up? I still see this warning on > 5.5-rc6 and next-20200113. It's been picked up some time ago and will appear in 5.6. Regards, Hans > > If it helps: > > Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> > >> --- >> drivers/media/i2c/adv748x/adv748x.h | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h >> index 5042f9e94aee..fccb388ce179 100644 >> --- a/drivers/media/i2c/adv748x/adv748x.h >> +++ b/drivers/media/i2c/adv748x/adv748x.h >> @@ -394,10 +394,10 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, >> >> #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) >> #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) >> -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v) >> +#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) >> >> #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) >> -#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, r+1)) & m) >> +#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m)) >> #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) >> >> #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) >> @@ -405,11 +405,11 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, >> >> #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) >> #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) >> -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v) >> +#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v)) >> >> #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) >> #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) >> -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v) >> +#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) >> >> #define tx_read(t, r) adv748x_read(t->state, t->page, r) >> #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v) >> -- >> 2.23.0 >>
On Thu, Jan 16, 2020 at 11:25 PM Hans Verkuil <hverkuil@xs4all.nl> wrote: > > On 1/14/20 12:14 AM, Nathan Chancellor wrote: > > On Tue, Oct 22, 2019 at 08:25:22AM -0500, Gustavo A. R. Silva wrote: > >> Enclose multiple macro parameters in parentheses in order to > >> make such macros safer and fix the Clang warning below: > >> > >> drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' > >> has lower precedence than '|'; '|' will be evaluated first > >> [-Wbitwise-conditional-parentheses] > >> > >> ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable > >> ? ctrl->val - 1 : 0); > >> > >> Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") > >> Reported-by: Dmitry Vyukov <dvyukov@google.com> > >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com > > > > It doesn't look like this was picked up? I still see this warning on > > 5.5-rc6 and next-20200113. > > It's been picked up some time ago and will appear in 5.6. https://git.linuxtv.org/media_tree.git/commit/?id=0d962e061abcf1b9105f88fb850158b5887fbca3
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h index 5042f9e94aee..fccb388ce179 100644 --- a/drivers/media/i2c/adv748x/adv748x.h +++ b/drivers/media/i2c/adv748x/adv748x.h @@ -394,10 +394,10 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v) +#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) -#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, r+1)) & m) +#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m)) #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) @@ -405,11 +405,11 @@ int adv748x_write_block(struct adv748x_state *state, int client_page, #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v) +#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v)) #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v) +#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) #define tx_read(t, r) adv748x_read(t->state, t->page, r) #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v)
Enclose multiple macro parameters in parentheses in order to make such macros safer and fix the Clang warning below: drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses] ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable ? ctrl->val - 1 : 0); Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver") Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> --- drivers/media/i2c/adv748x/adv748x.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)