diff mbox

[23/46] hotkey: reduce scope of variables

Message ID 1421175905-17035-24-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Jan. 13, 2015, 7:04 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

cppcheck is picking up some minor style issues which can
be easily fixed:

[src/hotkey/hotkey/hotkey.c:41]:
	(style) The scope of the variable 'item' can be reduced.
[src/hotkey/hotkey/hotkey.c:42]:
	(style) The scope of the variable 'found' can be reduced.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/hotkey/hotkey/hotkey.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ivan Hu Jan. 15, 2015, 7:34 a.m. UTC | #1
On 01/14/2015 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/hotkey/hotkey/hotkey.c:41]:
> 	(style) The scope of the variable 'item' can be reduced.
> [src/hotkey/hotkey/hotkey.c:42]:
> 	(style) The scope of the variable 'found' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/hotkey/hotkey/hotkey.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c
> index d3f8b7d..f540130 100644
> --- a/src/hotkey/hotkey/hotkey.c
> +++ b/src/hotkey/hotkey/hotkey.c
> @@ -38,8 +38,6 @@ static int hotkey_check_key(fwts_framework *fw,
>   	struct input_event *ev, fwts_list *hotkeys)
>   {
>   	static int scancode = 0;
> -	fwts_list_link *item;
> -	int found = 0;
>
>   	if ((ev->code == MSC_SCAN) &&
>   	    (ev->type == EV_MSC))
> @@ -47,6 +45,9 @@ static int hotkey_check_key(fwts_framework *fw,
>
>   	if ((ev->type == EV_KEY) &&
>   	    (ev->value != 0)) {
> +		fwts_list_link *item;
> +		int found = 0;
> +
>   		fwts_list_foreach(item, hotkeys) {
>   			fwts_keycode *keycode =
>   				fwts_list_data(fwts_keycode*, item);
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:58 a.m. UTC | #2
On Wed, Jan 14, 2015 at 3:04 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/hotkey/hotkey/hotkey.c:41]:
>         (style) The scope of the variable 'item' can be reduced.
> [src/hotkey/hotkey/hotkey.c:42]:
>         (style) The scope of the variable 'found' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/hotkey/hotkey/hotkey.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c
> index d3f8b7d..f540130 100644
> --- a/src/hotkey/hotkey/hotkey.c
> +++ b/src/hotkey/hotkey/hotkey.c
> @@ -38,8 +38,6 @@ static int hotkey_check_key(fwts_framework *fw,
>         struct input_event *ev, fwts_list *hotkeys)
>  {
>         static int scancode = 0;
> -       fwts_list_link *item;
> -       int found = 0;
>
>         if ((ev->code == MSC_SCAN) &&
>             (ev->type == EV_MSC))
> @@ -47,6 +45,9 @@ static int hotkey_check_key(fwts_framework *fw,
>
>         if ((ev->type == EV_KEY) &&
>             (ev->value != 0)) {
> +               fwts_list_link *item;
> +               int found = 0;
> +
>                 fwts_list_foreach(item, hotkeys) {
>                         fwts_keycode *keycode =
>                                 fwts_list_data(fwts_keycode*, item);
> --
> 2.1.4
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c
index d3f8b7d..f540130 100644
--- a/src/hotkey/hotkey/hotkey.c
+++ b/src/hotkey/hotkey/hotkey.c
@@ -38,8 +38,6 @@  static int hotkey_check_key(fwts_framework *fw,
 	struct input_event *ev, fwts_list *hotkeys)
 {
 	static int scancode = 0;
-	fwts_list_link *item;
-	int found = 0;
 
 	if ((ev->code == MSC_SCAN) &&
 	    (ev->type == EV_MSC))
@@ -47,6 +45,9 @@  static int hotkey_check_key(fwts_framework *fw,
 
 	if ((ev->type == EV_KEY) &&
 	    (ev->value != 0)) {
+		fwts_list_link *item;
+		int found = 0;
+
 		fwts_list_foreach(item, hotkeys) {
 			fwts_keycode *keycode =
 				fwts_list_data(fwts_keycode*, item);