diff options
author | Thomas Jarosch <tomj@simonv.com> | 2015-01-13 21:40:19 +0100 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2015-01-13 21:40:19 +0100 |
commit | 1212edd352e924111bb3db6330755b33f13fbe71 (patch) | |
tree | f399abf9b83b33ac4046cfdc3f74ac2d74a95f71 | |
parent | a71603b4d17b1f7da06c77176a795a7464dc859a (diff) | |
download | rockbox-1212edd352e924111bb3db6330755b33f13fbe71.tar.gz rockbox-1212edd352e924111bb3db6330755b33f13fbe71.zip |
Don't return pointer to array allocated on the stack
It will be out of scope once the function is left.
cppcheck reported:
[firmware/drivers/rtc/rtc_zenvisionm.c:31]: (error) Pointer to local array variable returned.
[firmware/drivers/rtc/rtc_zenvisionm.c:38]: (error) Pointer to local array variable returned.
Change-Id: Ibf28ba9b3d20cadcaff22398e143488c86746660
-rw-r--r-- | firmware/drivers/rtc/rtc_zenvisionm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/firmware/drivers/rtc/rtc_zenvisionm.c b/firmware/drivers/rtc/rtc_zenvisionm.c index 77bf99088c..244d7557f0 100644 --- a/firmware/drivers/rtc/rtc_zenvisionm.c +++ b/firmware/drivers/rtc/rtc_zenvisionm.c | |||
@@ -25,15 +25,15 @@ | |||
25 | 25 | ||
26 | unsigned char* rtc_send_command(short unk1, short unk2) | 26 | unsigned char* rtc_send_command(short unk1, short unk2) |
27 | { | 27 | { |
28 | unsigned char ret[12]; | 28 | static unsigned char ret[12]; |
29 | i2c_write(I2C_ADDRESS, (unk2 & 0xFF) | (unk << 8), 1); | 29 | i2c_write(I2C_ADDRESS, (unk2 & 0xFF) | (unk << 8), 1); |
30 | i2c_read(I2C_ADDRESS, ret, 12); | 30 | i2c_read(I2C_ADDRESS, ret, 12); |
31 | return ret; | 31 | return ret; |
32 | } | 32 | } |
33 | 33 | ||
34 | unsigned char* rtc_read(void) | 34 | unsigned char* rtc_read(void) |
35 | { | 35 | { |
36 | unsigned char ret[12]; | 36 | static unsigned char ret[12]; |
37 | i2c_read(I2C_ADDRESS, ret, 12); | 37 | i2c_read(I2C_ADDRESS, ret, 12); |
38 | return ret; | 38 | return ret; |
39 | } \ No newline at end of file | 39 | } |