summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
Diffstat (limited to 'binding')
-rw-r--r--binding/convenience/convenience.c13
-rw-r--r--binding/radio-binding.c2
-rw-r--r--binding/radio_impl_kingfisher.c2
-rw-r--r--binding/radio_impl_rtlsdr.c7
-rw-r--r--binding/radio_output.h2
-rw-r--r--binding/radio_output_gstreamer.c4
-rw-r--r--binding/radio_output_pulse.c9
-rw-r--r--binding/rtl_fm.c48
-rw-r--r--binding/rtl_fm_helper.c3
9 files changed, 49 insertions, 41 deletions
diff --git a/binding/convenience/convenience.c b/binding/convenience/convenience.c
index 517dc4e..ae1e24b 100644
--- a/binding/convenience/convenience.c
+++ b/binding/convenience/convenience.c
@@ -40,7 +40,7 @@ double atofs(char *s)
/* standard suffixes */
{
char last;
- int len;
+ size_t len;
double suff = 1.0;
len = strlen(s);
last = s[len-1];
@@ -49,9 +49,11 @@ double atofs(char *s)
case 'g':
case 'G':
suff *= 1e3;
+ /*@fallthrough@*/
case 'm':
case 'M':
suff *= 1e3;
+ /*@fallthrough@*/
case 'k':
case 'K':
suff *= 1e3;
@@ -67,7 +69,7 @@ double atoft(char *s)
/* time suffixes, returns seconds */
{
char last;
- int len;
+ size_t len;
double suff = 1.0;
len = strlen(s);
last = s[len-1];
@@ -76,9 +78,11 @@ double atoft(char *s)
case 'h':
case 'H':
suff *= 60;
+ /*@fallthrough@*/
case 'm':
case 'M':
suff *= 60;
+ /*@fallthrough@*/
case 's':
case 'S':
suff *= atof(s);
@@ -93,7 +97,7 @@ double atofp(char *s)
/* percent suffixes */
{
char last;
- int len;
+ size_t len;
double suff = 1.0;
len = strlen(s);
last = s[len-1];
@@ -243,7 +247,8 @@ int verbose_reset_buffer(rtlsdr_dev_t *dev)
int verbose_device_search(char *s)
{
- int i, device_count, device, offset;
+ int i, device_count, device;
+ ssize_t offset;
char *s2;
char vendor[256], product[256], serial[256];
device_count = rtlsdr_get_device_count();
diff --git a/binding/radio-binding.c b/binding/radio-binding.c
index 4db34db..e1e1763 100644
--- a/binding/radio-binding.c
+++ b/binding/radio-binding.c
@@ -72,7 +72,7 @@ static void frequency(struct afb_req request)
if(value) {
char *p;
- frequency = strtoul(value, &p, 10);
+ frequency = (uint32_t) strtoul(value, &p, 10);
if(frequency && *p == '\0') {
radio_impl_ops->set_frequency(frequency);
} else {
diff --git a/binding/radio_impl_kingfisher.c b/binding/radio_impl_kingfisher.c
index b6c0d11..177ad88 100644
--- a/binding/radio_impl_kingfisher.c
+++ b/binding/radio_impl_kingfisher.c
@@ -297,8 +297,6 @@ static uint32_t kf_get_frequency_step(radio_band_t band)
static void kf_start(void)
{
- int rc;
-
if(!present)
return;
diff --git a/binding/radio_impl_rtlsdr.c b/binding/radio_impl_rtlsdr.c
index b8b2454..9a1c492 100644
--- a/binding/radio_impl_rtlsdr.c
+++ b/binding/radio_impl_rtlsdr.c
@@ -218,7 +218,7 @@ static void rtlsdr_set_frequency(uint32_t frequency)
char cmd[64];
char output[128];
bool found = false;
- int rc;
+ ssize_t rc;
uint32_t n;
if(!present)
@@ -315,7 +315,7 @@ static void rtlsdr_start(void)
return;
if(!active) {
- int rc;
+ ssize_t rc;
char cmd[64];
sprintf(cmd, "START\n");
@@ -334,7 +334,6 @@ static void rtlsdr_stop(void)
return;
if(active) {
- int rc;
char cmd[64];
active = false;
@@ -349,7 +348,7 @@ static void rtlsdr_scan_start(radio_scan_direction_t direction,
radio_scan_callback_t callback,
void *data)
{
- int rc;
+ ssize_t rc;
char cmd[64];
char output[128];
bool found = false;
diff --git a/binding/radio_output.h b/binding/radio_output.h
index 2192811..bfa13cd 100644
--- a/binding/radio_output.h
+++ b/binding/radio_output.h
@@ -25,7 +25,7 @@ void radio_output_stop(void);
void radio_output_close(void);
-int radio_output_write(void *buf, int len);
+ssize_t radio_output_write(void *buf, int len);
#endif /* _RADIO_OUTPUT_H */
diff --git a/binding/radio_output_gstreamer.c b/binding/radio_output_gstreamer.c
index 698b81b..f492bb5 100644
--- a/binding/radio_output_gstreamer.c
+++ b/binding/radio_output_gstreamer.c
@@ -160,9 +160,9 @@ void radio_output_close(void)
output_buf = NULL;
}
-int radio_output_write(void *buf, int len)
+ssize_t radio_output_write(void *buf, int len)
{
- int rc = -EINVAL;
+ ssize_t rc = -EINVAL;
size_t n = len;
int samples = len / 2;
unsigned char *p;
diff --git a/binding/radio_output_pulse.c b/binding/radio_output_pulse.c
index a49687b..8b2957e 100644
--- a/binding/radio_output_pulse.c
+++ b/binding/radio_output_pulse.c
@@ -32,7 +32,6 @@ static int16_t extra_buf[1];
static unsigned char *output_buf;
static void pa_context_state_cb(pa_context *c, void *data) {
- pa_operation *o;
assert(c);
switch (pa_context_get_state(c)) {
@@ -220,10 +219,10 @@ void radio_output_close(void)
output_buf = NULL;
}
-int radio_output_write(void *buf, int len)
+ssize_t radio_output_write(void *buf, int len)
{
- int rc = -EINVAL;
- int error;
+ ssize_t rc = -EINVAL;
+
size_t n = len;
size_t avail;
int samples = len / 2;
@@ -284,7 +283,7 @@ int radio_output_write(void *buf, int len)
}
if ((rc = pa_stream_write(stream, p, n, NULL, 0, PA_SEEK_RELATIVE)) < 0) {
- fprintf(stderr, "Error writing %d bytes to PulseAudio : %s\n",
+ fprintf(stderr, "Error writing %zu bytes to PulseAudio : %s\n",
n, pa_strerror(pa_context_errno(context)));
}
exit:
diff --git a/binding/rtl_fm.c b/binding/rtl_fm.c
index 5b00482..cfbd487 100644
--- a/binding/rtl_fm.c
+++ b/binding/rtl_fm.c
@@ -226,17 +226,18 @@ void rotate_90(unsigned char *buf, uint32_t len)
or [0, 1, -3, 2, -4, -5, 7, -6] */
{
uint32_t i;
- unsigned char tmp;
+ uint8_t tmp;
+
for (i=0; i<len; i+=8) {
/* uint8_t negation = 255 - x */
- tmp = 255 - buf[i+3];
+ tmp = (uint8_t)(255 - buf[i+3]);
buf[i+3] = buf[i+2];
buf[i+2] = tmp;
- buf[i+4] = 255 - buf[i+4];
- buf[i+5] = 255 - buf[i+5];
+ buf[i+4] = (uint8_t)(255 - buf[i+4]);
+ buf[i+5] = (uint8_t)(255 - buf[i+5]);
- tmp = 255 - buf[i+6];
+ tmp = (uint8_t)(255 - buf[i+6]);
buf[i+6] = buf[i+7];
buf[i+7] = tmp;
}
@@ -254,8 +255,8 @@ void low_pass(struct demod_state *d)
if (d->prev_index < d->downsample) {
continue;
}
- d->lowpassed[i2] = d->now_r; // * d->output_scale;
- d->lowpassed[i2+1] = d->now_j; // * d->output_scale;
+ d->lowpassed[i2] = (int16_t)d->now_r; // * d->output_scale;
+ d->lowpassed[i2+1] = (int16_t)d->now_j; // * d->output_scale;
d->prev_index = 0;
d->now_r = 0;
d->now_j = 0;
@@ -314,7 +315,7 @@ void fifth_order(int16_t *data, int length, int16_t *hist)
e = hist[5];
f = data[0];
/* a downsample should improve resolution, so don't fully shift */
- data[0] = (a + (b+e)*5 + (c+d)*10 + f) >> 4;
+ data[0] = (int16_t) ((a + (b+e)*5 + (c+d)*10 + f) >> 4);
for (i=4; i<length; i+=4) {
a = c;
b = d;
@@ -322,7 +323,7 @@ void fifth_order(int16_t *data, int length, int16_t *hist)
d = f;
e = data[i-2];
f = data[i];
- data[i/2] = (a + (b+e)*5 + (c+d)*10 + f) >> 4;
+ data[i/2] = (int16_t) ((a + (b+e)*5 + (c+d)*10 + f) >> 4);
}
/* archive */
hist[0] = a;
@@ -336,7 +337,9 @@ void fifth_order(int16_t *data, int length, int16_t *hist)
void generic_fir(int16_t *data, int length, int *fir, int16_t *hist)
/* Okay, not at all generic. Assumes length 9, fix that eventually. */
{
- int d, temp, sum;
+ int16_t temp;
+ int sum;
+ int d;
for (d=0; d<length; d+=2) {
temp = data[d];
sum = 0;
@@ -345,7 +348,7 @@ void generic_fir(int16_t *data, int length, int *fir, int16_t *hist)
sum += (hist[2] + hist[6]) * fir[3];
sum += (hist[3] + hist[5]) * fir[4];
sum += hist[4] * fir[5];
- data[d] = sum >> 15 ;
+ data[d] = (int16_t) (sum >> 15);
hist[0] = hist[1];
hist[1] = hist[2];
hist[2] = hist[3];
@@ -445,7 +448,8 @@ int polar_disc_lut(int ar, int aj, int br, int bj)
if (x_abs >= atan_lut_size) {
/* we can use linear range, but it is not necessary */
- return (cj > 0) ? 1<<13 : -1<<13;
+ const int ret = 1<<13;
+ return (cj > 0) ? ret : -ret;
}
if (x > 0) {
@@ -497,7 +501,7 @@ void am_demod(struct demod_state *fm)
//r[i/2] = (int16_t)hypot(lp[i], lp[i+1]);
pcm = lp[i] * lp[i];
pcm += lp[i+1] * lp[i+1];
- r[i/2] = (int16_t)sqrt(pcm) * fm->output_scale;
+ r[i/2] = (int16_t) ((int16_t)sqrt(pcm) * fm->output_scale);
}
fm->result_len = fm->lp_len/2;
// lowpass? (3khz) highpass? (dc)
@@ -510,7 +514,7 @@ void usb_demod(struct demod_state *fm)
int16_t *r = fm->result;
for (i = 0; i < fm->lp_len; i += 2) {
pcm = lp[i] + lp[i+1];
- r[i/2] = (int16_t)pcm * fm->output_scale;
+ r[i/2] = (int16_t)((int16_t)pcm * fm->output_scale);
}
fm->result_len = fm->lp_len/2;
}
@@ -522,7 +526,7 @@ void lsb_demod(struct demod_state *fm)
int16_t *r = fm->result;
for (i = 0; i < fm->lp_len; i += 2) {
pcm = lp[i] - lp[i+1];
- r[i/2] = (int16_t)pcm * fm->output_scale;
+ r[i/2] = (int16_t)((int16_t)pcm * fm->output_scale);
}
fm->result_len = fm->lp_len/2;
}
@@ -560,10 +564,10 @@ void dc_block_filter(struct demod_state *fm)
for (i=0; i < fm->result_len; i++) {
sum += fm->result[i];
}
- avg = sum / fm->result_len;
+ avg = (int)(sum / fm->result_len);
avg = (avg + fm->dc_avg * 9) / 10;
for (i=0; i < fm->result_len; i++) {
- fm->result[i] -= avg;
+ fm->result[i] = (int16_t)(fm->result[i] - avg);
}
fm->dc_avg = avg;
}
@@ -589,7 +593,7 @@ int rms(int16_t *samples, int len, int step)
/* largely lifted from rtl_power */
{
int i;
- long p, t, s;
+ double p, t, s;
double dc, err;
p = t = 0L;
@@ -641,7 +645,7 @@ void arbitrary_downsample(int16_t *buf1, int16_t *buf2, int len1, int len2)
frac = 1.0;
if ((tick + len2) > len1) {
frac = (double)(len1 - tick) / (double)len2;}
- buf2[j] += (int16_t)((double)buf1[i] * frac + remainder);
+ buf2[j] = (int16_t)(buf2[j] + (double)buf1[i] * frac + remainder);
remainder = (double)buf1[i] * (1.0-frac);
tick += len2;
i++;
@@ -656,7 +660,8 @@ void arbitrary_downsample(int16_t *buf1, int16_t *buf2, int len1, int len2)
}
}
for (j=0; j<len2; j++) {
- buf2[j] = buf2[j] * len2 / len1;}
+ buf2[j] = (int16_t) (buf2[j] * len2 / len1);
+ }
}
void arbitrary_resample(int16_t *buf1, int16_t *buf2, int len1, int len2)
@@ -739,7 +744,8 @@ static void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx)
if (!s->offset_tuning) {
rotate_90(buf, len);}
for (i=0; i<(int)len; i++) {
- s->buf16[i] = (int16_t)buf[i] - 127;}
+ s->buf16[i] = (int16_t)(buf[i] - 127);
+ }
pthread_rwlock_wrlock(&d->rw);
memcpy(d->lowpassed, s->buf16, 2*len);
d->lp_len = len;
diff --git a/binding/rtl_fm_helper.c b/binding/rtl_fm_helper.c
index 9405ae2..c7df4b9 100644
--- a/binding/rtl_fm_helper.c
+++ b/binding/rtl_fm_helper.c
@@ -175,7 +175,8 @@ int main(int argc, char *argv[])
while(!done) {
LOG("Reading command\n");
- fgets(line, sizeof(line), stdin);
+ if (fgets(line, sizeof(line), stdin) == NULL)
+ break;
if(line[0] == '\0' || line[0] == '\n')
continue;
if(strcmp(line, "START\n") == 0) {