8000 ‘value’may be used uninitialized in this function `kbd_io` · Issue #3 · kvmtool/kvmtool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

‘value’may be used uninitialized in this function kbd_io #3

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

Open
hburaylee opened this issue Oct 23, 2021 · 6 comments
Open

‘value’may be used uninitialized in this function kbd_io #3

hburaylee opened this issue Oct 23, 2021 · 6 comments

Comments

@hburaylee
Copy link

When build with gcc (GCC) 8.4.1, i got a error

hw/i8042.c: In function ‘kbd_io’:
hw/i8042.c:153:19: error: ‘value’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   state.write_cmd = val;
   ~~~~~~~~~~~~~~~~^~~~~
hw/i8042.c:298:5: note: ‘value’ was declared here
  u8 value;
     ^~~~~
cc1: all warnings being treated as errors

@xinying2
Copy link
xinying2 commented Feb 8, 2022

I meet the same error as you, Have you address it ?

@chennbnbnb
Copy link

in function kbd_io(), when is_write is false, value won't be initialized,
so set a default value when define it, then every thing will be ok

static void kbd_io(struct kvm_cpu *vcpu, u64 addr, u8 *data, u32 len,
		   u8 is_write, void *ptr)
{
	u8 value = 0 ;  //set default value
	if (is_write)
		value = ioport__read8(data);

	switch (addr) {
	case I8042_COMMAND_REG:
		if (is_write)
			kbd_write_command(vcpu->kvm, value);
		else
			value = kbd_read_status();
		break;
    ....

@xinying2
Copy link

@chennbnbnb Thank you, it works.

@yunkunrao
Copy link

@xinying2 This info is helpful, thanks.

@leitao
Copy link
leitao commented Dec 2, 2022

@chennbnbnb please, create a pull request.

@yunkunrao
Copy link

Hi @leitao , I found this issue was not updated for a few days, and maybe other guys will encounter the issue when they try to use kvmtools for their developing or studying. Could you please review the above pr when convenient. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0