diff options
| author | Thomas Jarosch <tomj@simonv.com> | 2015-01-04 18:10:42 +0100 |
|---|---|---|
| committer | Thomas Jarosch <tomj@simonv.com> | 2015-01-04 18:16:44 +0100 |
| commit | c907e127f8b1d267e91e82d28cdb210288852b82 (patch) | |
| tree | a188d22f5092055f423b95dfef3eb08a14fa6abf | |
| parent | b43fcbdab227b5bc29daf64d6660edc6cd5dc534 (diff) | |
| download | rockbox-c907e127f8b1d267e91e82d28cdb210288852b82.zip rockbox-c907e127f8b1d267e91e82d28cdb210288852b82.tar.gz rockbox-c907e127f8b1d267e91e82d28cdb210288852b82.tar.bz2 rockbox-c907e127f8b1d267e91e82d28cdb210288852b82.tar.xz | |
jz4740 usbtool: Fix undefined behavior in set_reg()
The variable 'i' should actually be 'size'.
See the read_reg() function above it.
Confirmed via private email from Maurus Cuelenaere. Thanks!
(who also remembered having trouble reading/setting
registers over USB back then ;))
cppcheck reported:
[rockbox/utils/jz4740_tools/jz4740_usbtool.c:281]: (error) Uninitialized variable: i
Change-Id: I0f34834335e89d2504e7597e8db22cf69b5ca7e7
| -rw-r--r-- | utils/jz4740_tools/jz4740_usbtool.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/utils/jz4740_tools/jz4740_usbtool.c b/utils/jz4740_tools/jz4740_usbtool.c index 42d3160..e76c038 100644 --- a/utils/jz4740_tools/jz4740_usbtool.c +++ b/utils/jz4740_tools/jz4740_usbtool.c @@ -255,9 +255,9 @@ int read_data(usb_dev_handle* dh, int address, unsigned char *p, int len) unsigned int read_reg(usb_dev_handle* dh, int address, int size) { - int err; + int err; /* set by SEND_COMMAND macro */ unsigned char buf[4]; - + SEND_COMMAND(VR_SET_DATA_ADDRESS, address); SEND_COMMAND(VR_SET_DATA_LENGTH, size); GET_DATA(buf, size); @@ -274,20 +274,20 @@ unsigned int read_reg(usb_dev_handle* dh, int address, int size) int set_reg(usb_dev_handle* dh, int address, unsigned int val, int size) { - int err, i; + int err; /* set by SEND_COMMAND macro */ unsigned char buf[4]; - + buf[0] = val & 0xff; - if(i > 1) + if(size > 1) { buf[1] = (val >> 8) & 0xff; - if(i > 2) + if(size > 2) { buf[2] = (val >> 16) & 0xff; buf[3] = (val >> 24) & 0xff; } } - + SEND_COMMAND(VR_SET_DATA_ADDRESS, address); SEND_DATA(buf, size); |