Skip to content

Commit 888aedb

Browse files
committed
fix string read
1 parent 029f11c commit 888aedb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

util/comm-mec_lpc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,25 +181,25 @@ static int ec_command_lpc_mec_3(int command, int version, const void *outdata,
181181

182182
static int ec_readmem_lpc_mec(int offset, int bytes, void *dest)
183183
{
184-
int xfer_offset = MEC_EC_MEMMAP_START + offset;
184+
int i = offset;
185185
int cnt = 0;
186186
char* s = dest;
187187

188188
if (offset >= EC_MEMMAP_SIZE - bytes)
189189
return -1;
190190

191191
if (bytes) {
192-
ec_mec_xfer(EC_MEC_READ, xfer_offset, dest, bytes);
192+
ec_mec_xfer(EC_MEC_READ, MEC_EC_MEMMAP_START + i, dest, bytes);
193193
cnt = bytes;
194194
} else {
195195
/* Somewhat brute-force to set up a bunch of
196196
* individual transfers, but clearer than copying the xfer code
197197
* to add a stop condition.
198198
*/
199-
do {
200-
ec_mec_xfer(EC_MEC_READ, xfer_offset++, s++, 1);
199+
for(; i < EC_MEMMAP_SIZE; ++i, ++s) {
200+
ec_mec_xfer(EC_MEC_READ, MEC_EC_MEMMAP_START + i, s, 1);
201201
cnt++;
202-
} while(*s != '\0' && xfer_offset < EC_MEMMAP_SIZE);
202+
}
203203
}
204204
return cnt;
205205
}

0 commit comments

Comments
 (0)