This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: dvbv5-zap: improve program exit code Author: Mauro Carvalho Chehab <[email protected]> Date: Sun Mar 17 07:18:27 2019 -0300 While testing the program with Valgrind, it would keep reporting about non-freed data. The main reason is that, when called in non-record and non-monitor mode, the while() loop doesn't check for the timeout indication. Solve that and be sure that all strdup() vars will be freed too. On my tests, on normal mode, on monitor mode and on record mode, it now shows no memory leaks with Valgrind. Having zero leaks in Valgrind is important mostly because we don't want the libraries to leak. Having all memory allocated internally at the program freed means that, if Valgrind will report any memory leaks in the future, it would belong to the library code. Signed-off-by: Mauro Carvalho Chehab <[email protected]> utils/dvb/dvbv5-zap.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=5d653fcf0b04ec2d7fbd0d1347a15cf016fe0935 diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c index 95d8d35bb3cb..06b31a3b52e1 100644 --- a/utils/dvb/dvbv5-zap.c +++ b/utils/dvb/dvbv5-zap.c @@ -373,6 +373,7 @@ static void do_timeout(int x) signal(SIGALRM, do_timeout); } else { /* something has gone wrong ... exit */ + fprintf(stderr, "Forcing program stop due to timeout or terminate signal\n"); exit(1); } } @@ -1016,6 +1017,8 @@ static void set_signals(struct arguments *args) } } +const static char *default_dvr_pipe = "/tmp/dvr-pipe"; + int main(int argc, char **argv) { struct arguments args = {}; @@ -1046,11 +1049,10 @@ int main(int argc, char **argv) textdomain (PACKAGE); #endif - memset(&args, 0, sizeof(args)); args.sat_number = -1; args.lna = LNA_AUTO; args.input_format = FILE_DVBV5; - args.dvr_pipe = "/tmp/dvr-pipe"; + args.dvr_pipe = default_dvr_pipe; args.low_traffic = 1; if (argp_parse(&argp, argc, argv, ARGP_NO_HELP | ARGP_NO_EXIT, &idx, &args)) { @@ -1365,7 +1367,7 @@ int main(int argc, char **argv) get_show_stats(stderr, &args, parms, 0); } else { /* Wait until timeout or being killed */ - while (1) { + while (!timeout_flag) { get_show_stats(stderr, &args, parms, 1); usleep(1000000); } @@ -1373,9 +1375,25 @@ int main(int argc, char **argv) err = 0; err: + dvb_dev_free(dvb); + + /* + * Just to make Valgrind happier. It should be noticed + * That, if an error happens or if the program exits via + * timeout code at forced mode, it may not free those. + */ if (args.confname) free(args.confname); - dvb_dev_free(dvb); + if (args.filename) + free(args.filename); + if (args.lnb_name) + free(args.lnb_name); + if (args.search) + free(args.search); + if (args.server) + free(args.search); + if (args.dvr_pipe != default_dvr_pipe) + free(args.dvr_pipe); return err; } _______________________________________________ linuxtv-commits mailing list [email protected] https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
