Code repeated 3 times; move to common function.
Signed-off-by: Jemma Denson <[email protected]>
---
utils/dvb/dvbv5-zap.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 2d71307..ef17be9 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -737,6 +737,16 @@ int do_traffic_monitor(struct arguments *args,
return 0;
}
+static void set_signals(struct arguments *args)
+{
+ signal(SIGTERM, do_timeout);
+ signal(SIGINT, do_timeout);
+ if (args->timeout > 0) {
+ signal(SIGALRM, do_timeout);
+ alarm(args->timeout);
+ }
+}
+
int main(int argc, char **argv)
{
struct arguments args;
@@ -855,26 +865,14 @@ int main(int argc, char **argv)
goto err;
if (args.exit_after_tuning) {
- signal(SIGTERM, do_timeout);
- signal(SIGINT, do_timeout);
- if (args.timeout > 0) {
- signal(SIGALRM, do_timeout);
- alarm(args.timeout);
- }
-
+ set_signals(&args);
err = 0;
check_frontend(&args, parms);
goto err;
}
if (args.traffic_monitor) {
- signal(SIGTERM, do_timeout);
- signal(SIGINT, do_timeout);
- if (args.timeout > 0) {
- signal(SIGALRM, do_timeout);
- alarm(args.timeout);
- }
-
+ set_signals(&args);
err = do_traffic_monitor(&args, parms);
goto err;
}
@@ -966,12 +964,7 @@ int main(int argc, char **argv)
goto err;
}
- signal(SIGTERM, do_timeout);
- signal(SIGINT, do_timeout);
- if (args.timeout > 0) {
- signal(SIGALRM, do_timeout);
- alarm(args.timeout);
- }
+ set_signals(&args);
if (!check_frontend(&args, parms)) {
err = 1;
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html