laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-tetra/+/28926 )
Change subject: when traffic dump directory is specified, now prints error message and exits instead of crashing when traffic file cannot be written ......................................................................
when traffic dump directory is specified, now prints error message and exits instead of crashing when traffic file cannot be written
Change-Id: I273e07aefd9faea13662f6699a6f3b074c8efe88 --- M src/lower_mac/tetra_lower_mac.c 1 file changed, 5 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified daniel: Looks good to me, but someone else must approve laforge: Looks good to me, approved
diff --git a/src/lower_mac/tetra_lower_mac.c b/src/lower_mac/tetra_lower_mac.c index ca1b72e..f6a893a 100644 --- a/src/lower_mac/tetra_lower_mac.c +++ b/src/lower_mac/tetra_lower_mac.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include <linux/limits.h>
#include <osmocom/core/utils.h> @@ -196,6 +197,10 @@ snprintf(fname, sizeof(fname), "%s/traffic_%d_%d.out", tms->dumpdir, tms->cur_burst.is_traffic, tms->tsn); f = fopen(fname, "ab"); + if (!f) { + fprintf(stderr, "Could not open dump file %s for writing: %s\n", fname, strerror(errno)); + exit(1); + }
/* Generate a block */ memset(block, 0x00, sizeof(int16_t) * 690);