From 227c9b5896fc7d0d9038ef2c2290041f3eca59f0 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 24 Nov 2017 10:48:35 +0100 Subject: Remove calls to 'exit' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check now return a status instead of exiting the process. Change-Id: I70bdeb4e4b3848a0c5e743a13aecec3ed8f98600 Signed-off-by: José Bollo --- binding/rtl_fm.c | 14 ++++++++------ 1 file 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; -- cgit 1.2.3-korg