Skip to content

Commit

Permalink
fix uninitialized variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sergforce committed Feb 6, 2019
1 parent 2443a10 commit 13dddc1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
36 changes: 35 additions & 1 deletion xtrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ static int _debug_param_io(void* obj, unsigned param, unsigned chno, uint64_t va
}
return res;
}
default:
XTRXLLS_LOG("XTRX", XTRXLL_WARNING, "%s: Unknown CMDIDX:%x\n",
_devname(&dev[devno]), param);
}


Expand Down Expand Up @@ -579,8 +582,11 @@ int xtrx_set_ref_clk(struct xtrx_dev* dev, unsigned refclkhz, xtrx_clock_source_
int osc;
res = xtrxll_get_sensor(dev[devnum].lldev, XTRXLL_REFCLK_CLK, &osc);
if (res) {
XTRXLLS_LOG("XTRX", XTRXLL_ERROR, "%s: Unable to get OSC VAL (%d)\n",
_devname(&dev[devnum]), res);
return res;
}

if (abs((int)dev->refclock - osc) * (int64_t)(1000000/PPM_LIMIT) / dev->refclock > 1) {
XTRXLLS_LOG("XTRX", XTRXLL_ERROR, "%s: RefClk %d doesn't look like %d on master!\n",
_devname(&dev[devnum]), osc, (int)dev->refclock);
Expand Down Expand Up @@ -699,6 +705,9 @@ int xtrx_tune_ex(struct xtrx_dev* dev, xtrx_tune_t type, xtrx_channel_t ch,

for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
unsigned fe_ch = (ch >> (2 * devnum)) & XTRX_CH_AB;
if (fe_ch == 0)
continue;

res = dev[devnum].fe->ops->fe_set_freq(dev[devnum].fe, fe_ch, type, freq, actualfreq);
if (res)
return res;
Expand All @@ -709,6 +718,9 @@ int xtrx_tune_ex(struct xtrx_dev* dev, xtrx_tune_t type, xtrx_channel_t ch,
case XTRX_TUNE_BB_TX:
for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
unsigned fe_ch = (ch >> (2 * devnum)) & XTRX_CH_AB;
if (fe_ch == 0)
continue;

res = dev[devnum].fe->ops->bb_set_freq(dev[devnum].fe, fe_ch, type, freq, actualfreq);
if (res)
return res;
Expand All @@ -726,6 +738,9 @@ static int xtrx_tune_bandwidth(struct xtrx_dev* dev, xtrx_channel_t xch,
unsigned type = (rbb) ? XTRX_TUNE_BB_RX : XTRX_TUNE_BB_TX;
for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
unsigned fe_ch = (xch >> (2 * devnum)) & XTRX_CH_AB;
if (fe_ch == 0)
continue;

res = dev[devnum].fe->ops->bb_set_badwidth(dev[devnum].fe, fe_ch, type, bw, actualbw);
if (res)
return res;
Expand Down Expand Up @@ -761,6 +776,9 @@ int xtrx_set_gain(struct xtrx_dev* dev, xtrx_channel_t xch, xtrx_gain_type_t gt,
int res;
for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
unsigned fe_ch = (xch >> (2 * devnum)) & XTRX_CH_AB;
if (fe_ch == 0)
continue;

res = dev[devnum].fe->ops->bb_set_gain(dev[devnum].fe, fe_ch, gt, gain, actualgain);
if (res)
return res;
Expand All @@ -779,6 +797,9 @@ int xtrx_set_antenna_ex(struct xtrx_dev* dev, xtrx_channel_t ch, xtrx_antenna_t
int res;
for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
unsigned fe_ch = (ch >> (2 * devnum)) & XTRX_CH_AB;
if (fe_ch == 0)
continue;

res = dev[devnum].fe->ops->fe_set_lna(dev[devnum].fe, fe_ch, 0, antenna);
if (res)
return res;
Expand Down Expand Up @@ -952,6 +973,11 @@ int xtrx_run_ex(struct xtrx_dev* dev, const xtrx_run_params_t* params)
for (unsigned devnum = 0; devnum < dev->dev_max; devnum++) {
fe_params.rx.chs = (params->rx.chs >> (2 * devnum)) & XTRX_CH_AB;
fe_params.tx.chs = (params->tx.chs >> (2 * devnum)) & XTRX_CH_AB;
if (fe_params.rx.chs == 0 && fe_params.tx.chs == 0) {
XTRXLLS_LOG("XTRX", XTRXLL_INFO, "%s: Skipping RX/TX configuration\n",
_devname(&dev[devnum]));
continue;
}

res = dev[devnum].fe->ops->dd_set_modes(dev[devnum].fe, XTRX_FEDD_CONFIGURE, &fe_params);
if (res)
Expand Down Expand Up @@ -1304,6 +1330,7 @@ int xtrx_send_sync_ex(struct xtrx_dev* mdev, xtrx_send_ex_info_t *info)
abort();
case -EIO:
case -EBUSY:
case -ETIMEDOUT:
return res;
case 0:
dev->txbuf = wire_buffer_ptr;
Expand Down Expand Up @@ -1861,7 +1888,14 @@ static int _xtrx_val_get_int(struct xtrx_dev* dev, xtrx_direction_t dir,
*oval = val;
}
return res;

case XTRX_REF_REFCLK:
if (!dev->refclock_checked) {
res = xtrx_set_ref_clk(dev, 0, dev->clock_source);
if (res)
return res;
}
*oval = dev->refclock;
return 0;
case XTRX_LMS7_DATA_RATE:
case XTRX_LMS7_RSSI:
return dev->fe->ops->get_reg(dev->fe, chan, dir, type, oval);
Expand Down
13 changes: 7 additions & 6 deletions xtrx_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ int xtrx_debug_process_cmd(xtrx_debug_ctx_t* ctx, char *cmd, unsigned len,
unsigned device = 0;
int res = -EINVAL;
int j;
char *pptr[2];
char *str1, *saveptr1, *token;
char *pptr[4] = {NULL,};
char *str1 = NULL, *saveptr1 = NULL, *token = NULL;
enum dubug_cmd dcmd;
enum cmdvtype vt = CMD_VT_NONE;

XTRXLLS_LOG("DBGP", XTRXLL_DEBUG, "got cmd: %s\n", cmd);

for (j = 1, str1 = cmd; ; j++, str1 = NULL) {
for (j = 0, str1 = cmd; j < 4; j++, str1 = NULL) {
token = strtok_r(str1, ",", &saveptr1);
if (token == NULL)
break;

pptr[j - 1] = token;
pptr[j] = token;
}

if (strcmp(cmd, "LMS") == 0) {
if (j < 3)
if (j < 3) {
goto incorrect_format;

}
param = strtol(pptr[2], NULL, 16);
dcmd = (param & 0x80000000) ? DEBUG_RFIC_SPI_WR : DEBUG_RFIC_SPI_RD;
} else if (strcmp(cmd, "TMP") == 0) {
Expand Down Expand Up @@ -119,6 +119,7 @@ int xtrx_debug_process_cmd(xtrx_debug_ctx_t* ctx, char *cmd, unsigned len,
param = UINT_MAX;
} else {
XTRXLLS_LOG("DBGP", XTRXLL_ERROR, "unrecognized command! %s\n", cmd);
goto incorrect_format;
}

if (j > 1) {
Expand Down

0 comments on commit 13dddc1

Please sign in to comment.