osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/42866?usp=email )


Change subject: utils/gsmtap-logsend: close infile before exit
......................................................................

utils/gsmtap-logsend: close infile before exit

Related: SYS#8093
Change-Id: I259cf951c52f7d859475f5f79c803692c29fbec3
---
M utils/gsmtap-logsend.c
1 file changed, 10 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/42866/1

diff --git a/utils/gsmtap-logsend.c b/utils/gsmtap-logsend.c
index 67114e7..9365362 100644
--- a/utils/gsmtap-logsend.c
+++ b/utils/gsmtap-logsend.c
@@ -50,6 +50,7 @@
        FILE *infile;
        char *line;
        int rc;
+       int ret = 0;

        while (1) {
                static const struct option long_options[] = {
@@ -102,7 +103,8 @@
        gsmtap_fd = gsmtap_source_init_fd(dest_host, dest_port);
        if (gsmtap_fd < 0) {
                fprintf(stderr, "Unable to create GSMTAP socket: %s\n", 
strerror(errno));
-               exit(2);
+               ret = 2;
+               goto exit_close;
        }

        /* prepare all the data structures that don't change for each line */
@@ -133,7 +135,13 @@
                rc = writev(gsmtap_fd, iov, ARRAY_SIZE(iov));
                if (rc <= 0) {
                        fprintf(stderr, "Short write on GSMTAP socket: %d 
(%s)\n", rc, strerror(errno));
-                       exit(1);
+                       ret = 1;
+                       goto exit_close;
                }
        }
+
+exit_close:
+       if (infile != stdin)
+               fclose(infile);
+       exit(ret);
 }

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/42866?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I259cf951c52f7d859475f5f79c803692c29fbec3
Gerrit-Change-Number: 42866
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to