asix-sigma: Avoid use of variable length arrays

This was only done once in sigma_write_register().
This commit is contained in:
Alexandru Gagniuc 2015-04-28 13:03:58 -07:00 committed by Uwe Hermann
parent 682fb08c88
commit e8686e3ae3
1 changed files with 11 additions and 1 deletions

View File

@ -130,13 +130,23 @@ static int sigma_write(void *buf, size_t size, struct dev_context *devc)
return ret;
}
/*
* NOTE: We chose the buffer size to be large enough to hold any write to the
* device. We still print a message just in case.
*/
static int sigma_write_register(uint8_t reg, uint8_t *data, size_t len,
struct dev_context *devc)
{
size_t i;
uint8_t buf[len + 2];
uint8_t buf[80];
int idx = 0;
if ((len + 2) > sizeof(buf)) {
sr_err("Attempted to write %zu bytes, but buffer is too small.",
len + 2);
return SR_ERR_BUG;
}
buf[idx++] = REG_ADDR_LOW | (reg & 0xf);
buf[idx++] = REG_ADDR_HIGH | (reg >> 4);