Variable cleanup and corrections.

Remove unused variables.
Use proper type specifier.
Explicitly cast to correct type to suppress MSVC warnings.
pull/12/head
Kacper Michajłow 2014-11-01 14:27:48 +01:00 zatwierdzone przez Kyle Keen
rodzic a2d23c590f
commit 6aa5f17589
6 zmienionych plików z 29 dodań i 32 usunięć

Wyświetl plik

@ -705,7 +705,7 @@ int rtlsdr_set_if_freq(rtlsdr_dev_t *dev, uint32_t freq)
if (rtlsdr_get_xtal_freq(dev, &rtl_xtal, NULL))
return -2;
if_freq = ((freq * TWO_POW(22)) / rtl_xtal) * (-1);
if_freq = (int32_t)(((freq * TWO_POW(22)) / rtl_xtal) * -1);
tmp = (if_freq >> 16) & 0x3f;
r = rtlsdr_demod_write_reg(dev, 1, 0x19, tmp, 1);
@ -728,7 +728,7 @@ int rtlsdr_set_sample_freq_correction(rtlsdr_dev_t *dev, int ppm)
{
int r = 0;
uint8_t tmp;
int16_t offs = ppm * (-1) * TWO_POW(24) / 1000000;
int16_t offs = (int16_t)(ppm * -1 * TWO_POW(24) / 1000000);
rtlsdr_set_i2c_repeater(dev, 0);
tmp = offs & 0xff;
@ -1103,7 +1103,7 @@ int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate)
return -EINVAL;
}
rsamp_ratio = (dev->rtl_xtal * TWO_POW(22)) / samp_rate;
rsamp_ratio = (uint32_t)((dev->rtl_xtal * TWO_POW(22)) / samp_rate);
rsamp_ratio &= 0x0ffffffc;
real_rsamp_ratio = rsamp_ratio | ((rsamp_ratio & 0x08000000) << 1);
@ -1853,7 +1853,7 @@ int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx,
r = libusb_submit_transfer(dev->xfer[i]);
if (r < 0) {
fprintf(stderr, "Failed to submit transfer %i!\n", i);
fprintf(stderr, "Failed to submit transfer %u!\n", i);
dev->async_status = RTLSDR_CANCELING;
break;
}

Wyświetl plik

@ -755,7 +755,7 @@ void dc_block_filter(struct demod_state *fm)
for (i=0; i < fm->lp_len; i++) {
sum += lp[i];
}
avg = sum / fm->lp_len;
avg = (int)(sum / fm->lp_len);
avg = (avg + fm->dc_avg * 9) / 10;
for (i=0; i < fm->lp_len; i++) {
lp[i] -= avg;
@ -1403,7 +1403,6 @@ void sanity_checks(void)
int agc_init(struct demod_state *s)
{
int i;
struct agc_state *agc;
agc = malloc(sizeof(struct agc_state));

Wyświetl plik

@ -830,7 +830,7 @@ int64_t real_conj(int16_t real, int16_t imag)
void scanner(void)
{
int i, j, j2, f, g, n_read, offset, bin_e, bin_len, buf_len, ds, ds_p;
int i, j, j2, n_read, offset, bin_e, bin_len, buf_len, ds, ds_p;
int32_t w;
struct tuning_state *ts;
int16_t *fft_buf;
@ -912,12 +912,11 @@ void scanner(void)
void csv_dbm(struct tuning_state *ts)
{
int i, len, ds;
int i, len;
int64_t tmp;
double dbm;
char *sep = ", ";
len = 1 << ts->bin_e;
ds = ts->downsample;
/* fix FFT stuff quirks */
if (ts->bin_e > 0) {
/* nuke DC component (not effective for all windows) */
@ -972,7 +971,7 @@ int main(int argc, char **argv)
struct sigaction sigact;
#endif
char *filename = NULL;
int i, r, opt, wb_mode = 0;
int i, r, opt;
int f_set = 0;
int dev_index = 0;
int dev_given = 0;

Wyświetl plik

@ -303,23 +303,23 @@ static void *command_worker(void *arg)
}
switch(cmd.cmd) {
case 0x01:
printf("set freq %d\n", ntohl(cmd.param));
printf("set freq %u\n", ntohl(cmd.param));
rtlsdr_set_center_freq(dev,ntohl(cmd.param));
break;
case 0x02:
printf("set sample rate %d\n", ntohl(cmd.param));
printf("set sample rate %u\n", ntohl(cmd.param));
rtlsdr_set_sample_rate(dev, ntohl(cmd.param));
break;
case 0x03:
printf("set gain mode %d\n", ntohl(cmd.param));
printf("set gain mode %u\n", ntohl(cmd.param));
rtlsdr_set_tuner_gain_mode(dev, ntohl(cmd.param));
break;
case 0x04:
printf("set gain %d\n", ntohl(cmd.param));
printf("set gain %u\n", ntohl(cmd.param));
rtlsdr_set_tuner_gain(dev, ntohl(cmd.param));
break;
case 0x05:
printf("set freq correction %d\n", ntohl(cmd.param));
printf("set freq correction %u\n", ntohl(cmd.param));
rtlsdr_set_freq_correction(dev, ntohl(cmd.param));
break;
case 0x06:
@ -328,31 +328,31 @@ static void *command_worker(void *arg)
rtlsdr_set_tuner_if_gain(dev, tmp >> 16, (short)(tmp & 0xffff));
break;
case 0x07:
printf("set test mode %d\n", ntohl(cmd.param));
printf("set test mode %u\n", ntohl(cmd.param));
rtlsdr_set_testmode(dev, ntohl(cmd.param));
break;
case 0x08:
printf("set agc mode %d\n", ntohl(cmd.param));
printf("set agc mode %u\n", ntohl(cmd.param));
rtlsdr_set_agc_mode(dev, ntohl(cmd.param));
break;
case 0x09:
printf("set direct sampling %d\n", ntohl(cmd.param));
printf("set direct sampling %u\n", ntohl(cmd.param));
rtlsdr_set_direct_sampling(dev, ntohl(cmd.param));
break;
case 0x0a:
printf("set offset tuning %d\n", ntohl(cmd.param));
printf("set offset tuning %u\n", ntohl(cmd.param));
rtlsdr_set_offset_tuning(dev, ntohl(cmd.param));
break;
case 0x0b:
printf("set rtl xtal %d\n", ntohl(cmd.param));
printf("set rtl xtal %u\n", ntohl(cmd.param));
rtlsdr_set_xtal_freq(dev, ntohl(cmd.param), 0);
break;
case 0x0c:
printf("set tuner xtal %d\n", ntohl(cmd.param));
printf("set tuner xtal %u\n", ntohl(cmd.param));
rtlsdr_set_xtal_freq(dev, 0, ntohl(cmd.param));
break;
case 0x0d:
printf("set tuner gain by index %d\n", ntohl(cmd.param));
printf("set tuner gain by index %u\n", ntohl(cmd.param));
set_gain_by_index(dev, ntohl(cmd.param));
break;
default:

Wyświetl plik

@ -443,7 +443,7 @@ static uint32_t compute_flo(uint32_t f_osc, uint8_t z, uint16_t x, uint8_t r)
if (fvco == 0)
return -EINVAL;
return fvco / r;
return (uint32_t)(fvco / r);
}
static int e4k_band_set(struct e4k_state *e4k, enum e4k_band band)
@ -483,10 +483,10 @@ uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint
uint32_t i;
uint8_t r = 2;
uint64_t intended_fvco, remainder;
uint64_t z = 0;
uint8_t z = 0;
uint32_t x;
int flo;
int three_phase_mixing = 0;
uint32_t flo;
uint8_t three_phase_mixing = 0;
oscp->r_idx = 0;
if (!is_fosc_valid(fosc))
@ -507,13 +507,13 @@ uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint
intended_fvco = (uint64_t)intended_flo * r;
/* compute integral component of multiplier */
z = intended_fvco / fosc;
z = (uint8_t)(intended_fvco / fosc);
/* compute fractional part. this will not overflow,
* as fosc(max) = 30MHz and z(max) = 255 */
remainder = intended_fvco - (fosc * z);
/* remainder(max) = 30MHz, E4K_PLL_Y = 65536 -> 64bit! */
x = (remainder * E4K_PLL_Y) / fosc;
x = (uint32_t)((remainder * E4K_PLL_Y) / fosc);
/* x(max) as result of this computation is 65536 */
flo = compute_flo(fosc, z, x, r);

Wyświetl plik

@ -542,7 +542,7 @@ static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq)
* vco_div = 65536*(nint + sdm/65536) = int( 0.5 + 65536 * vco_freq / (2 * pll_ref) )
* vco_div = 65536*nint + sdm = int( (pll_ref + 65536 * vco_freq) / (2 * pll_ref) )
*/
vco_div = (pll_ref + 65536 * vco_freq) / (2 * pll_ref);
nint = (uint32_t) (vco_div / 65536);
sdm = (uint32_t) (vco_div % 65536);
@ -826,9 +826,8 @@ static int r82xx_init_tv_standard(struct r82xx_priv *priv,
{
/* everything that was previously done in r82xx_set_tv_standard
* and doesn't need to be changed when filter settings change */
int rc, i;
int rc;
uint32_t if_khz, filt_cal_lo;
uint8_t data[5], val;
uint8_t filt_gain, img_r, ext_enable, loop_through;
uint8_t lt_att, flt_ext_widest, polyfil_cur;
@ -907,7 +906,7 @@ static int r82xx_init_tv_standard(struct r82xx_priv *priv,
}
static int r82xx_set_if_filter(struct r82xx_priv *priv, int hpf, int lpf) {
int rc, i;
int rc;
uint8_t filt_q, hp_cor;
int cal;
filt_q = 0x10; /* r10[4]:low q(1'b1) */