Message ID | 20201104162427.2984742-11-lee.jones@linaro.org |
---|---|
State | New |
Headers | show |
Series | Rid W=1 issues from Input | expand |
Hi Lee, On Wed, Nov 04, 2020 at 04:24:17PM +0000, Lee Jones wrote: > Fixes the following W=1 kernel build warning(s): > > drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’: > drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> > Cc: Henrik Rydberg <rydberg@bitmath.org> > Cc: Peter Osterlund <petero2@telia.com> > Cc: Stefan Gmeiner <riddlebox@freesurf.ch> > Cc: "C. Scott Ananian" <cananian@alumni.priceton.edu> > Cc: Bruce Kalk <kall@compass.com> > Cc: this to <linux-input@vger.kernel.org> > Cc: linux-input@vger.kernel.org > Signed-off-by: Lee Jones <lee.jones@linaro.org> > --- > drivers/input/mouse/synaptics.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c > index 82577095e175e..07835939d83b9 100644 > --- a/drivers/input/mouse/synaptics.c > +++ b/drivers/input/mouse/synaptics.c > @@ -1106,8 +1106,9 @@ static void synaptics_process_packet(struct psmouse *psmouse) > num_fingers = hw.w + 2; > break; > case 2: > - if (SYN_MODEL_PEN(info->model_id)) > + if (SYN_MODEL_PEN(info->model_id)) { > ; /* Nothing, treat a pen as a single finger */ > + } This gives me: WARNING: braces {} are not necessary for single statement blocks from checkpatch. Thanks. -- Dmitry
On Thu, 05 Nov 2020, Dmitry Torokhov wrote: > Hi Lee, > > On Wed, Nov 04, 2020 at 04:24:17PM +0000, Lee Jones wrote: > > Fixes the following W=1 kernel build warning(s): > > > > drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’: > > drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] > > > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> > > Cc: Henrik Rydberg <rydberg@bitmath.org> > > Cc: Peter Osterlund <petero2@telia.com> > > Cc: Stefan Gmeiner <riddlebox@freesurf.ch> > > Cc: "C. Scott Ananian" <cananian@alumni.priceton.edu> > > Cc: Bruce Kalk <kall@compass.com> > > Cc: this to <linux-input@vger.kernel.org> > > Cc: linux-input@vger.kernel.org > > Signed-off-by: Lee Jones <lee.jones@linaro.org> > > --- > > drivers/input/mouse/synaptics.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c > > index 82577095e175e..07835939d83b9 100644 > > --- a/drivers/input/mouse/synaptics.c > > +++ b/drivers/input/mouse/synaptics.c > > @@ -1106,8 +1106,9 @@ static void synaptics_process_packet(struct psmouse *psmouse) > > num_fingers = hw.w + 2; > > break; > > case 2: > > - if (SYN_MODEL_PEN(info->model_id)) > > + if (SYN_MODEL_PEN(info->model_id)) { > > ; /* Nothing, treat a pen as a single finger */ > > + } > > This gives me: > > WARNING: braces {} are not necessary for single statement blocks > > from checkpatch. Yes, because checkpatch just sees it as a normal single statement, rather than an empty one. It complains about macros that can be compiled out too, which is even more dangerous. GCC wins this one though, as it *knows* it's an empty statement. -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
On Thu, 2020-11-05 at 23:26 -0800, Dmitry Torokhov wrote: > On Wed, Nov 04, 2020 at 04:24:17PM +0000, Lee Jones wrote: > > Fixes the following W=1 kernel build warning(s): > > > > drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’: > > drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] [] > > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c [] > > @@ -1106,8 +1106,9 @@ static void synaptics_process_packet(struct psmouse *psmouse) > > num_fingers = hw.w + 2; > > break; > > case 2: > > - if (SYN_MODEL_PEN(info->model_id)) > > + if (SYN_MODEL_PEN(info->model_id)) { > > ; /* Nothing, treat a pen as a single finger */ > > + } > > This gives me: > > WARNING: braces {} are not necessary for single statement blocks > > from checkpatch. As the entire case 2 is effectively a noop, why not just comment it better and remove the if (SYN_MODEL_PEN(...)) test altogether.
On Thu, 05 Nov 2020, Joe Perches wrote: > On Thu, 2020-11-05 at 23:26 -0800, Dmitry Torokhov wrote: > > On Wed, Nov 04, 2020 at 04:24:17PM +0000, Lee Jones wrote: > > > Fixes the following W=1 kernel build warning(s): > > > > > > drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’: > > > drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] > [] > > > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c > [] > > > @@ -1106,8 +1106,9 @@ static void synaptics_process_packet(struct psmouse *psmouse) > > > num_fingers = hw.w + 2; > > > break; > > > case 2: > > > - if (SYN_MODEL_PEN(info->model_id)) > > > + if (SYN_MODEL_PEN(info->model_id)) { > > > ; /* Nothing, treat a pen as a single finger */ > > > + } > > > > This gives me: > > > > WARNING: braces {} are not necessary for single statement blocks > > > > from checkpatch. > > As the entire case 2 is effectively a noop, why not just comment it better > and remove the if (SYN_MODEL_PEN(...)) test altogether. Happy to do that if that's okay with Dmitry. -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 82577095e175e..07835939d83b9 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1106,8 +1106,9 @@ static void synaptics_process_packet(struct psmouse *psmouse) num_fingers = hw.w + 2; break; case 2: - if (SYN_MODEL_PEN(info->model_id)) + if (SYN_MODEL_PEN(info->model_id)) { ; /* Nothing, treat a pen as a single finger */ + } break; case 4 ... 15: if (SYN_CAP_PALMDETECT(info->capabilities))
Fixes the following W=1 kernel build warning(s): drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’: drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Henrik Rydberg <rydberg@bitmath.org> Cc: Peter Osterlund <petero2@telia.com> Cc: Stefan Gmeiner <riddlebox@freesurf.ch> Cc: "C. Scott Ananian" <cananian@alumni.priceton.edu> Cc: Bruce Kalk <kall@compass.com> Cc: this to <linux-input@vger.kernel.org> Cc: linux-input@vger.kernel.org Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/input/mouse/synaptics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.25.1