when traffic dump directory is specified, now prints error message and exits instead of crashing when traffic file cannot be written

Change-Id: I273e07aefd9faea13662f6699a6f3b074c8efe88
This commit is contained in:
wbokslag 2022-08-04 09:37:50 +02:00
parent f258b1d7d7
commit 16713cab01
1 changed files with 5 additions and 0 deletions

View File

@ -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 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, int blk_num, const uint8_t *bi
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);