Skip to content

Commit

Permalink
libbladeRF: Fixed potentially uninitialized status variable
Browse files Browse the repository at this point in the history
Updated parameter types to a more appropriate unsigned type, and
defaulted status to "success" if 0 length is provided.

This is intended to address build issues (reported on OSX 10.6.8) caused
by status being potentially uninitialized and the associated warnings
being used to generate errors.
  • Loading branch information
jynik committed Apr 7, 2014
1 parent 5cd4140 commit 8cc3de0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions host/libraries/libbladeRF/src/backend/libusb.c
Expand Up @@ -560,7 +560,8 @@ static int access_peripheral(struct bladerf_lusb *lusb, int per, int dir,
return access_peripheral_v(lusb, per, dir, cmd, 1);
}

static int _read_bytes(struct bladerf *dev, int addr, int len, uint32_t *val) {
static int _read_bytes(struct bladerf *dev, int addr,
size_t len, uint32_t *val) {
int i = 0;
int status = 0;
struct uart_cmd cmd;
Expand Down Expand Up @@ -592,12 +593,13 @@ static int _read_bytes(struct bladerf *dev, int addr, int len, uint32_t *val) {
return status;
}

static int _write_bytes(struct bladerf *dev, int addr, int len, uint32_t val) {
int status;
static int _write_bytes(struct bladerf *dev, int addr,
size_t len, uint32_t val) {
int status = 0;
struct uart_cmd cmd;
struct bladerf_lusb *lusb = dev->backend;

int i;
size_t i;
for (i = 0; i < len; i++) {
cmd.addr = addr + i;
cmd.data = (val >> (i * 8)) & 0xff ;
Expand Down

0 comments on commit 8cc3de0

Please sign in to comment.