Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wuninitialized in drivers/input/keyboard/mcs_touchkey.c #1893

Closed
nathanchance opened this issue Jul 25, 2023 · 2 comments
Closed

-Wuninitialized in drivers/input/keyboard/mcs_touchkey.c #1893

nathanchance opened this issue Jul 25, 2023 · 2 comments
Assignees
Labels
-Wuninitialized [BUG] linux-next This is an issue only seen in linux-next [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle

Comments

@nathanchance
Copy link
Member

drivers/input/keyboard/mcs_touchkey.c:149:49: error: variable 'error' is uninitialized when used here [-Werror,-Wuninitialized]
  149 |                 dev_err(&client->dev, "i2c read error[%d]\n", error);
      |                                                               ^~~~~
include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
  144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                                                                        ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
  110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
      |                                     ^~~~~~~~~~~
drivers/input/keyboard/mcs_touchkey.c:110:11: note: initialize the variable 'error' to silence this warning
  110 |         int error;
      |                  ^
      |                   = 0
1 error generated.

Patch sent: https://lore.kernel.org/20230725-mcs_touchkey-fix-wuninitialized-v1-1-615db39af51c@kernel.org/

@nathanchance nathanchance added [PATCH] Submitted A patch has been submitted for review -Wuninitialized [BUG] linux-next This is an issue only seen in linux-next labels Jul 25, 2023
@nathanchance nathanchance self-assigned this Jul 25, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Jul 25, 2023
…probe()

Clang warns (or errors with CONFIG_WERROR=y):

  drivers/input/keyboard/mcs_touchkey.c:149:49: error: variable 'error' is uninitialized when used here [-Werror,-Wuninitialized]
    149 |                 dev_err(&client->dev, "i2c read error[%d]\n", error);
        |                                                               ^~~~~
  include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
    144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
        |                                                                        ^~~~~~~~~~~
  include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
    110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
        |                                     ^~~~~~~~~~~
  drivers/input/keyboard/mcs_touchkey.c:110:11: note: initialize the variable 'error' to silence this warning
    110 |         int error;
        |                  ^
        |                   = 0
  1 error generated.

A refactoring updated the error handling in this block but did not
update the dev_err() call to use fw_ver instead of error. Do so now to
fix the warning and avoid printing uninitialized memory.

Closes: ClangBuiltLinux#1893
Fixes: e175eae ("Input: mcs-touchkey - convert to use devm_* api")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Jul 25, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Jul 26, 2023
…probe()

Clang warns (or errors with CONFIG_WERROR=y):

  drivers/input/keyboard/mcs_touchkey.c:149:49: error: variable 'error' is uninitialized when used here [-Werror,-Wuninitialized]
    149 |                 dev_err(&client->dev, "i2c read error[%d]\n", error);
        |                                                               ^~~~~
  include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
    144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
        |                                                                        ^~~~~~~~~~~
  include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
    110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
        |                                     ^~~~~~~~~~~
  drivers/input/keyboard/mcs_touchkey.c:110:11: note: initialize the variable 'error' to silence this warning
    110 |         int error;
        |                  ^
        |                   = 0
  1 error generated.

A refactoring updated the error handling in this block but did not
update the dev_err() call to use fw_ver instead of error. Do so now to
fix the warning and avoid printing uninitialized memory.

Closes: ClangBuiltLinux#1893
Fixes: e175eae ("Input: mcs-touchkey - convert to use devm_* api")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20230725-mcs_touchkey-fix-wuninitialized-v1-1-615db39af51c@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wuninitialized [BUG] linux-next This is an issue only seen in linux-next [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle
Projects
None yet
Development

No branches or pull requests

1 participant