From d406c5eb9fbebefc0a496d6522aeb8de1eff05b1 Mon Sep 17 00:00:00 2001 From: Lionel Gauthier <lionel.gauthier@eurecom.fr> Date: Fri, 24 Apr 2015 06:02:47 +0000 Subject: [PATCH] check file descriptor git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7261 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- common/utils/msc/msc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/utils/msc/msc.c b/common/utils/msc/msc.c index 8847501824..83ff1eb93b 100644 --- a/common/utils/msc/msc.c +++ b/common/utils/msc/msc.c @@ -295,14 +295,16 @@ void msc_log_declare_proto( uint64_t local_msc_event_counter = msc_event_counter; msc_event_counter++; if ((protoP >= MIN_MSC_PROTOS) && (protoP < MAX_MSC_PROTOS)) { + if (msc_fd[protoP] != NULL) { rv = fprintf(msc_fd[protoP], "%"PRIu64" [PROTO] %d %s\n", local_msc_event_counter, protoP, &msc_proto2str[protoP][0]); if (rv < 0) { - fprintf(stderr, "Error while declaring new protocol in MSC log file: %s", strerror(errno)); + fprintf(stderr, "Error while declaring new protocol in MSC log file: %s", strerror(errno)); } - rv = fflush(msc_fd[protoP]); - if (rv != 0) { - fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno)); - } + rv = fflush(msc_fd[protoP]); + if (rv != 0) { + fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno)); + } + } } } //------------------------------------------------------------------------------ @@ -320,7 +322,7 @@ void msc_log_event( if ((protoP < MIN_MSC_PROTOS) || (protoP >= MAX_MSC_PROTOS)) { return; } - if (msc_fd != NULL) { + if (msc_fd[protoP] != NULL) { rv = fprintf(msc_fd[protoP], "%"PRIu64" [EVENT] %d ", local_msc_event_counter, protoP); if (rv < 0) { fprintf(stderr, "Error while logging MSC event : %s", &msc_proto2str[protoP][0]); -- GitLab