[PATCH] speakup: genmap: initialization the variable

bajing posted 1 patch 1 year, 5 months ago
drivers/accessibility/speakup/genmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] speakup: genmap: initialization the variable
Posted by bajing 1 year, 5 months ago
The variable lc is not initialized before use, so the initialization operation on it is added.

Signed-off-by: bajing <bajing@cmss.chinamobile.com>
---
 drivers/accessibility/speakup/genmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accessibility/speakup/genmap.c b/drivers/accessibility/speakup/genmap.c
index 0882bab10fb8..a1ea0ce45c20 100644
--- a/drivers/accessibility/speakup/genmap.c
+++ b/drivers/accessibility/speakup/genmap.c
@@ -48,7 +48,7 @@ static int get_shift_value(int state)
 int
 main(int argc, char *argv[])
 {
-	int value, shift_state, i, spk_val = 0, lock_val = 0;
+	int value, shift_state, i, lc, spk_val = 0, lock_val = 0;
 	int max_key_used = 0, num_keys_used = 0;
 	struct st_key *this;
 	struct st_key_init *p_init;
-- 
2.33.0
Re: [PATCH] speakup: genmap: initialization the variable
Posted by kernel test robot 1 year, 5 months ago
Hi bajing,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.11-rc3 next-20240814]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/bajing/speakup-genmap-initialization-the-variable/20240815-000631
base:   linus/master
patch link:    https://lore.kernel.org/r/20240814030243.2138-1-bajing%40cmss.chinamobile.com
patch subject: [PATCH] speakup: genmap: initialization the variable
config: x86_64-randconfig-005-20240815 (https://download.01.org/0day-ci/archive/20240815/202408151133.RcP4kFGW-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240815/202408151133.RcP4kFGW-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408151133.RcP4kFGW-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/accessibility/speakup/genmap.c:75:3: warning: variable 'lc' is uninitialized when used here [-Wuninitialized]
      75 |                 lc++;
         |                 ^~
   drivers/accessibility/speakup/genmap.c:52:31: note: initialize the variable 'lc' to silence this warning
      52 |         int value, shift_state, i, lc, spk_val = 0, lock_val = 0;
         |                                      ^
         |                                       = 0
   1 warning generated.


vim +/lc +75 drivers/accessibility/speakup/genmap.c

6a5c94d92699b7 Samuel Thibault 2022-06-12  48  
6a5c94d92699b7 Samuel Thibault 2022-06-12  49  int
6a5c94d92699b7 Samuel Thibault 2022-06-12  50  main(int argc, char *argv[])
6a5c94d92699b7 Samuel Thibault 2022-06-12  51  {
1cb16586b0aba7 bajing          2024-08-14  52  	int value, shift_state, i, lc, spk_val = 0, lock_val = 0;
6a5c94d92699b7 Samuel Thibault 2022-06-12  53  	int max_key_used = 0, num_keys_used = 0;
6a5c94d92699b7 Samuel Thibault 2022-06-12  54  	struct st_key *this;
6a5c94d92699b7 Samuel Thibault 2022-06-12  55  	struct st_key_init *p_init;
6a5c94d92699b7 Samuel Thibault 2022-06-12  56  	char buffer[256];
6a5c94d92699b7 Samuel Thibault 2022-06-12  57  
6a5c94d92699b7 Samuel Thibault 2022-06-12  58  	bzero(key_table, sizeof(key_table));
6a5c94d92699b7 Samuel Thibault 2022-06-12  59  	bzero(key_data, sizeof(key_data));
6a5c94d92699b7 Samuel Thibault 2022-06-12  60  
6a5c94d92699b7 Samuel Thibault 2022-06-12  61  	shift_table[0] = 0;
6a5c94d92699b7 Samuel Thibault 2022-06-12  62  	for (i = 1; i <= 16; i++)
6a5c94d92699b7 Samuel Thibault 2022-06-12  63  		shift_table[i] = -1;
6a5c94d92699b7 Samuel Thibault 2022-06-12  64  
6a5c94d92699b7 Samuel Thibault 2022-06-12  65  	if (argc < 2) {
6a5c94d92699b7 Samuel Thibault 2022-06-12  66  		fputs("usage: genmap filename\n", stderr);
6a5c94d92699b7 Samuel Thibault 2022-06-12  67  		exit(1);
6a5c94d92699b7 Samuel Thibault 2022-06-12  68  	}
6a5c94d92699b7 Samuel Thibault 2022-06-12  69  
6a5c94d92699b7 Samuel Thibault 2022-06-12  70  	for (p_init = init_key_data; p_init->name[0] != '.'; p_init++)
6a5c94d92699b7 Samuel Thibault 2022-06-12  71  		add_key(p_init->name, p_init->value, p_init->shift);
6a5c94d92699b7 Samuel Thibault 2022-06-12  72  
6a5c94d92699b7 Samuel Thibault 2022-06-12  73  	open_input(NULL, argv[1]);
6a5c94d92699b7 Samuel Thibault 2022-06-12  74  	while (fgets(buffer, sizeof(buffer), infile)) {
6a5c94d92699b7 Samuel Thibault 2022-06-12 @75  		lc++;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] speakup: genmap: initialization the variable
Posted by Samuel Thibault 1 year, 5 months ago
bajing, le mer. 14 août 2024 11:02:43 +0800, a ecrit:
> The variable lc is not initialized before use, so the initialization operation on it is added.
> 
> Signed-off-by: bajing <bajing@cmss.chinamobile.com>
> ---
>  drivers/accessibility/speakup/genmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/accessibility/speakup/genmap.c b/drivers/accessibility/speakup/genmap.c
> index 0882bab10fb8..a1ea0ce45c20 100644
> --- a/drivers/accessibility/speakup/genmap.c
> +++ b/drivers/accessibility/speakup/genmap.c
> @@ -48,7 +48,7 @@ static int get_shift_value(int state)
>  int
>  main(int argc, char *argv[])
>  {
> -	int value, shift_state, i, spk_val = 0, lock_val = 0;
> +	int value, shift_state, i, lc, spk_val = 0, lock_val = 0;

You have already sent a patch that does drop the use before
initialization.

Samuel

>  	int max_key_used = 0, num_keys_used = 0;
>  	struct st_key *this;
>  	struct st_key_init *p_init;
> -- 
> 2.33.0
> 
> 
> 

-- 
Samuel
 Cliquez sur le lien qui suit dans ce mail...vous n'avez plus qu'a vous
 inscrire pour gagner de l'argent en restant connecte....et puis faites
 passer le message et vous gagnerez encore plus d'argent ...
 -+- AC in NPC : Neuneu a rencontré le Pere Noël -+-