summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-11-24 10:48:35 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-11-24 10:48:35 +0100
commit227c9b5896fc7d0d9038ef2c2290041f3eca59f0 (patch)
tree27009b4b0b1207d9bbf47a329c1982373faf88de
parent18f5940ce349f2eb9bf6532b7e07311c52691a2d (diff)
Remove calls to 'exit'
The check now return a status instead of exiting the process. Change-Id: I70bdeb4e4b3848a0c5e743a13aecec3ed8f98600 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--binding/rtl_fm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/binding/rtl_fm.c b/binding/rtl_fm.c
index 1c6a6b2..5b00482 100644
--- a/binding/rtl_fm.c
+++ b/binding/rtl_fm.c
@@ -966,23 +966,24 @@ void controller_cleanup(struct controller_state *s)
pthread_mutex_destroy(&s->hop_m);
}
-void sanity_checks(void)
+int sanity_checks(void)
{
+ int r = 1;
if (controller.freq_len == 0) {
fprintf(stderr, "Please specify a frequency.\n");
- exit(1);
+ r = 0;
}
if (controller.freq_len >= FREQUENCIES_LIMIT) {
fprintf(stderr, "Too many channels, maximum %i.\n", FREQUENCIES_LIMIT);
- exit(1);
+ r = 0;
}
if (controller.freq_len > 1 && demod.squelch_level == 0) {
fprintf(stderr, "Please specify a squelch level. Required for scanning multiple frequencies.\n");
- exit(1);
+ r = 0;
}
-
+ return r;
}
int rtl_fm_init(uint32_t freq,
@@ -1045,7 +1046,8 @@ int rtl_fm_init(uint32_t freq,
output.rate = demod.rate_out;
}
- sanity_checks();
+ if (!sanity_checks())
+ return -1;
if (controller.freq_len > 1) {
demod.terminate_on_squelch = 0;