2019-06-01 03:43:36 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//
|
|
|
|
// Copyright(c) 2018 Intel Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Author: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
|
|
|
|
// Artur Kloniecki <arturx.kloniecki@linux.intel.com>
|
|
|
|
|
2016-09-28 00:29:55 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
2021-03-21 09:46:56 +08:00
|
|
|
#include <limits.h>
|
2016-09-28 00:29:55 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2017-09-04 23:35:01 +08:00
|
|
|
#include <ctype.h>
|
2019-01-09 18:03:57 +08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <termios.h>
|
2018-10-02 15:36:44 +08:00
|
|
|
#include "convert.h"
|
2020-05-29 20:29:40 +08:00
|
|
|
#include "misc.h"
|
2018-06-25 12:59:07 +08:00
|
|
|
|
2018-10-12 20:56:41 +08:00
|
|
|
#define APP_NAME "sof-logger"
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2019-07-10 19:25:08 +08:00
|
|
|
#ifndef ARRAY_SIZE
|
2016-09-28 00:29:55 +08:00
|
|
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
2019-07-10 19:25:08 +08:00
|
|
|
#endif
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2017-02-28 19:51:55 +08:00
|
|
|
static const char *debugfs[] = {
|
2018-03-06 22:11:13 +08:00
|
|
|
"dmac0", "dmac1", "ssp0", "ssp1",
|
|
|
|
"ssp2", "iram", "dram", "shim",
|
|
|
|
"mbox", "etrace",
|
2019-06-07 17:53:16 +08:00
|
|
|
"hda", "pp", "dsp",
|
2016-09-28 00:29:55 +08:00
|
|
|
};
|
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
static void usage(void)
|
|
|
|
{
|
|
|
|
fprintf(stdout, "Usage %s <option(s)> <file(s)>\n", APP_NAME);
|
|
|
|
fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", APP_NAME);
|
2019-10-31 18:22:30 +08:00
|
|
|
fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents "
|
|
|
|
"to outfile\n", APP_NAME);
|
2020-04-02 19:57:38 +08:00
|
|
|
fprintf(stdout, "%s:\t -l *.ldc_file\t\t*.ldc files generated by smex\n",
|
|
|
|
APP_NAME);
|
2018-10-15 17:08:06 +08:00
|
|
|
fprintf(stdout, "%s:\t -p \t\t\tInput from stdin\n", APP_NAME);
|
2019-10-31 18:22:30 +08:00
|
|
|
fprintf(stdout, "%s:\t -v ver_file\t\tEnable checking firmware version "
|
|
|
|
"with ver_file file\n", APP_NAME);
|
2020-08-19 19:25:30 +08:00
|
|
|
fprintf(stdout, "%s:\t -n\t\t\tDisable checking firmware version\n",
|
|
|
|
APP_NAME);
|
2020-03-25 21:39:39 +08:00
|
|
|
fprintf(stdout, "%s:\t -c clock\t\tSet timestamp clock in MHz\n",
|
|
|
|
APP_NAME);
|
2019-10-31 18:22:30 +08:00
|
|
|
fprintf(stdout, "%s:\t -s state_name\t\tTake a snapshot of state\n",
|
|
|
|
APP_NAME);
|
2018-10-02 15:36:44 +08:00
|
|
|
fprintf(stdout, "%s:\t -t\t\t\tDisplay trace data\n", APP_NAME);
|
2019-01-09 18:03:57 +08:00
|
|
|
fprintf(stdout, "%s:\t -u baud\t\tInput data from a UART\n", APP_NAME);
|
2019-10-31 18:22:30 +08:00
|
|
|
fprintf(stdout, "%s:\t -r\t\t\tLess formatted output for "
|
|
|
|
"chained log processors\n",
|
|
|
|
APP_NAME);
|
2020-05-04 21:23:34 +08:00
|
|
|
fprintf(stdout, "%s:\t -L\t\t\tHide log location in source code\n",
|
|
|
|
APP_NAME);
|
2021-03-21 09:46:56 +08:00
|
|
|
fprintf(stdout,
|
|
|
|
"%s:\t -e 0/1\t\t\tTimestamps relative to first entry seen. Defaults to\n",
|
|
|
|
APP_NAME);
|
|
|
|
fprintf(stdout, "%s:\t\t\t\tabsolute when -r(aw), relative otherwise.\n",
|
|
|
|
APP_NAME);
|
2020-05-27 14:50:43 +08:00
|
|
|
fprintf(stdout, "%s:\t -f precision\t\tSet timestamp precision\n",
|
2020-05-04 22:09:36 +08:00
|
|
|
APP_NAME);
|
2020-07-31 15:57:21 +08:00
|
|
|
fprintf(stdout, "%s:\t -g\t\t\tHide timestamp\n",
|
2020-06-22 16:19:04 +08:00
|
|
|
APP_NAME);
|
2020-05-27 15:02:46 +08:00
|
|
|
fprintf(stdout, "%s:\t -d *.ldc_file \t\tDump ldc_file information\n",
|
|
|
|
APP_NAME);
|
2020-10-19 21:40:54 +08:00
|
|
|
fprintf(stdout, "%s:\t -F filter\t\tUpdate trace filter, format: "
|
|
|
|
"<level>=<comp1>[, <comp2>]\n",
|
2020-05-29 20:29:40 +08:00
|
|
|
APP_NAME);
|
2018-10-02 15:36:44 +08:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2016-09-28 00:29:55 +08:00
|
|
|
static int snapshot(const char *name)
|
|
|
|
{
|
2017-10-13 23:41:29 +08:00
|
|
|
const char *path = "/sys/kernel/debug/sof";
|
2016-09-28 00:29:55 +08:00
|
|
|
uint32_t val, addr;
|
|
|
|
char pinname[64], poutname[64], buffer[128];
|
|
|
|
FILE *in_fd, *out_fd;
|
|
|
|
int i, count;
|
|
|
|
|
2020-03-23 20:58:16 +08:00
|
|
|
if (!name) {
|
2017-02-28 19:51:55 +08:00
|
|
|
fprintf(stderr, "error: need snapshot name\n");
|
2016-09-28 00:29:55 +08:00
|
|
|
return -EINVAL;
|
2017-02-28 19:51:55 +08:00
|
|
|
}
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2017-02-28 19:51:55 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(debugfs); i++) {
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2017-02-28 19:51:55 +08:00
|
|
|
sprintf(pinname, "%s/%s", path, debugfs[i]);
|
|
|
|
sprintf(poutname, "%s.%s.txt", name, debugfs[i]);
|
2016-09-28 00:29:55 +08:00
|
|
|
|
|
|
|
/* open debugfs for reading */
|
2019-01-31 18:11:57 +08:00
|
|
|
in_fd = fopen(pinname, "rb");
|
2020-03-23 20:58:16 +08:00
|
|
|
if (!in_fd) {
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr, "error: unable to open %s for reading: %s\n",
|
|
|
|
pinname, strerror(errno));
|
2016-09-28 00:29:55 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-10-31 18:22:30 +08:00
|
|
|
/* open outfile for writing */
|
2019-01-31 18:11:57 +08:00
|
|
|
out_fd = fopen(poutname, "wb");
|
2020-03-23 20:58:16 +08:00
|
|
|
if (!out_fd) {
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr, "error: unable to open %s for writing: %s\n",
|
|
|
|
poutname, strerror(errno));
|
2016-09-28 00:29:55 +08:00
|
|
|
fclose(in_fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stdout, "processing %s...\n", pinname);
|
|
|
|
addr = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
count = fread(&val, 1, 4, in_fd);
|
|
|
|
if (count != 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
sprintf(buffer, "0x%6.6x: 0x%8.8x\n", addr, val);
|
|
|
|
|
|
|
|
count = fwrite(buffer, 1, strlen(buffer), out_fd);
|
|
|
|
|
|
|
|
addr += 4;
|
|
|
|
}
|
|
|
|
|
2017-06-15 21:36:24 +08:00
|
|
|
fclose(in_fd);
|
|
|
|
fclose(out_fd);
|
2016-09-28 00:29:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-09 18:03:57 +08:00
|
|
|
static int configure_uart(const char *file, unsigned int baud)
|
|
|
|
{
|
|
|
|
struct termios tio = {};
|
|
|
|
int ret, fd = open(file, O_RDWR | O_NOCTTY);
|
|
|
|
if (fd < 0)
|
|
|
|
return -errno;
|
|
|
|
|
|
|
|
cfsetspeed(&tio, 115200);
|
|
|
|
cfmakeraw(&tio);
|
|
|
|
|
|
|
|
tio.c_iflag |= IGNBRK;
|
|
|
|
|
|
|
|
tio.c_cflag |= CLOCAL | CREAD | HUPCL;
|
|
|
|
|
|
|
|
tio.c_cc[VTIME] = 1;
|
|
|
|
tio.c_cc[VMIN] = 1;
|
|
|
|
|
|
|
|
ret = tcsetattr(fd, TCSANOW, &tio);
|
|
|
|
return ret < 0 ? -errno : fd;
|
|
|
|
}
|
|
|
|
|
2020-05-29 20:29:40 +08:00
|
|
|
/* Concantenate `config->filter_config` with `input` + `\n` */
|
|
|
|
static int append_filter_config(struct convert_config *config, const char *input)
|
|
|
|
{
|
|
|
|
char *old_config = config->filter_config;
|
|
|
|
|
|
|
|
/* filer_config can't be NULL for following steps */
|
|
|
|
if (!old_config)
|
2020-09-15 14:30:56 +08:00
|
|
|
old_config = asprintf("%s", "");
|
2020-05-29 20:29:40 +08:00
|
|
|
|
2020-09-15 14:30:56 +08:00
|
|
|
config->filter_config = asprintf("%s%s\n", old_config, input);
|
2020-05-29 20:29:40 +08:00
|
|
|
free(old_config);
|
|
|
|
if (!config->filter_config)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-28 00:29:55 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2021-03-21 09:46:56 +08:00
|
|
|
static const char optstring[] = "ho:i:l:ps:c:u:tv:rd:Le:f:gF:n";
|
2018-10-02 15:36:44 +08:00
|
|
|
struct convert_config config;
|
2019-01-09 18:03:57 +08:00
|
|
|
unsigned int baud = 0;
|
2019-04-15 15:49:28 +08:00
|
|
|
const char *snapshot_file = 0;
|
2018-11-10 00:38:59 +08:00
|
|
|
int opt, ret = 0;
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
config.trace = 0;
|
|
|
|
config.clock = 19.2;
|
|
|
|
config.in_file = NULL;
|
|
|
|
config.out_file = NULL;
|
|
|
|
config.out_fd = NULL;
|
|
|
|
config.in_fd = NULL;
|
|
|
|
config.ldc_file = NULL;
|
2018-10-24 21:17:33 +08:00
|
|
|
config.ldc_fd = NULL;
|
2018-10-08 20:18:08 +08:00
|
|
|
config.input_std = 0;
|
2018-10-24 21:17:33 +08:00
|
|
|
/* checking fw version is disabled by default */
|
2020-08-19 19:18:03 +08:00
|
|
|
config.version_file = "/sys/kernel/debug/sof/fw_version";
|
2018-10-24 21:17:33 +08:00
|
|
|
config.version_fd = NULL;
|
2020-08-19 19:18:03 +08:00
|
|
|
config.version_fw = 1;
|
2018-12-04 00:45:42 +08:00
|
|
|
config.use_colors = 1;
|
2019-01-09 18:03:57 +08:00
|
|
|
config.serial_fd = -EINVAL;
|
2019-03-29 23:15:04 +08:00
|
|
|
config.raw_output = 0;
|
2020-03-24 21:54:25 +08:00
|
|
|
config.dump_ldc = 0;
|
2020-05-04 21:23:34 +08:00
|
|
|
config.hide_location = 0;
|
2020-06-23 19:34:59 +08:00
|
|
|
config.time_precision = 6;
|
2021-03-21 09:46:56 +08:00
|
|
|
config.relative_timestamps = INT_MAX; /* unspecified */
|
2020-05-29 20:29:40 +08:00
|
|
|
config.filter_config = NULL;
|
2018-10-02 15:36:44 +08:00
|
|
|
|
2020-05-22 16:33:34 +08:00
|
|
|
while ((opt = getopt(argc, argv, optstring)) != -1) {
|
2016-09-28 00:29:55 +08:00
|
|
|
switch (opt) {
|
|
|
|
case 'o':
|
2018-10-02 15:36:44 +08:00
|
|
|
config.out_file = optarg;
|
2016-09-28 00:29:55 +08:00
|
|
|
break;
|
|
|
|
case 'i':
|
2018-10-02 15:36:44 +08:00
|
|
|
config.in_file = optarg;
|
2016-09-28 00:29:55 +08:00
|
|
|
break;
|
2017-10-12 21:17:09 +08:00
|
|
|
case 't':
|
2018-10-02 15:36:44 +08:00
|
|
|
config.trace = 1;
|
2017-10-12 21:17:09 +08:00
|
|
|
break;
|
2017-06-09 21:55:36 +08:00
|
|
|
case 'c':
|
2018-10-02 15:36:44 +08:00
|
|
|
config.clock = atof(optarg);
|
2017-06-09 21:55:36 +08:00
|
|
|
break;
|
2016-09-28 00:29:55 +08:00
|
|
|
case 's':
|
2019-04-15 15:49:28 +08:00
|
|
|
snapshot_file = optarg;
|
2019-01-09 18:03:57 +08:00
|
|
|
break;
|
2018-10-02 15:36:44 +08:00
|
|
|
case 'l':
|
2020-05-27 15:02:46 +08:00
|
|
|
if (config.ldc_file) {
|
|
|
|
fprintf(stderr, "error: Multiple ldc files\n");
|
|
|
|
usage();
|
|
|
|
}
|
2018-10-02 15:36:44 +08:00
|
|
|
config.ldc_file = optarg;
|
|
|
|
break;
|
2018-10-08 20:18:08 +08:00
|
|
|
case 'p':
|
|
|
|
config.input_std = 1;
|
|
|
|
break;
|
2019-01-09 18:03:57 +08:00
|
|
|
case 'u':
|
|
|
|
baud = atoi(optarg);
|
|
|
|
break;
|
2019-03-29 23:15:04 +08:00
|
|
|
case 'r':
|
|
|
|
config.raw_output = 1;
|
|
|
|
break;
|
2018-10-24 21:17:33 +08:00
|
|
|
case 'v':
|
|
|
|
/* enabling checking fw version with ver_file file */
|
|
|
|
config.version_file = optarg;
|
|
|
|
break;
|
2020-08-19 19:25:30 +08:00
|
|
|
case 'n':
|
|
|
|
config.version_fw = 0;
|
|
|
|
break;
|
2020-05-04 21:23:34 +08:00
|
|
|
case 'L':
|
|
|
|
config.hide_location = 1;
|
|
|
|
break;
|
2021-03-21 09:46:56 +08:00
|
|
|
case 'e': {
|
|
|
|
int i = atoi(optarg);
|
|
|
|
|
|
|
|
if (i < 0 || 1 < i) {
|
|
|
|
fprintf(stderr, "%s: invalid option: -e %s\n",
|
|
|
|
APP_NAME, optarg);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
config.relative_timestamps = i;
|
|
|
|
}
|
2020-05-04 22:09:36 +08:00
|
|
|
case 'f':
|
2020-06-23 19:34:59 +08:00
|
|
|
config.time_precision = atoi(optarg);
|
|
|
|
if (config.time_precision < 0) {
|
2020-05-04 22:09:36 +08:00
|
|
|
usage();
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
2020-06-22 16:19:04 +08:00
|
|
|
case 'g':
|
2020-06-23 19:34:59 +08:00
|
|
|
config.time_precision = -1;
|
2020-06-22 16:19:04 +08:00
|
|
|
break;
|
2020-03-24 21:54:25 +08:00
|
|
|
case 'd':
|
2020-05-27 15:02:46 +08:00
|
|
|
if (config.ldc_file) {
|
|
|
|
fprintf(stderr, "error: Multiple ldc files\n");
|
|
|
|
usage();
|
|
|
|
}
|
2020-03-24 21:54:25 +08:00
|
|
|
config.dump_ldc = 1;
|
2020-09-30 16:28:24 +08:00
|
|
|
config.version_fw = 0;
|
2020-05-27 15:02:46 +08:00
|
|
|
config.ldc_file = optarg;
|
2020-03-24 21:54:25 +08:00
|
|
|
break;
|
2020-05-29 20:29:40 +08:00
|
|
|
case 'F':
|
|
|
|
ret = append_filter_config(&config, optarg);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
break;
|
2016-09-28 00:29:55 +08:00
|
|
|
case 'h':
|
|
|
|
default: /* '?' */
|
2018-10-02 15:36:44 +08:00
|
|
|
usage();
|
2016-09-28 00:29:55 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-09 18:03:57 +08:00
|
|
|
|
2020-10-20 16:09:01 +08:00
|
|
|
if (argc != optind) {
|
|
|
|
fprintf(stderr, "error: Unused parameter '%s'\n", argv[optind]);
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
2019-04-15 15:49:28 +08:00
|
|
|
if (snapshot_file)
|
|
|
|
return baud ? EINVAL : -snapshot(snapshot_file);
|
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
if (!config.ldc_file) {
|
2018-10-24 21:17:33 +08:00
|
|
|
fprintf(stderr, "error: Missing ldc file\n");
|
2018-10-02 15:36:44 +08:00
|
|
|
usage();
|
2018-03-06 22:11:13 +08:00
|
|
|
}
|
2017-10-13 23:41:29 +08:00
|
|
|
|
2019-01-31 18:11:57 +08:00
|
|
|
config.ldc_fd = fopen(config.ldc_file, "rb");
|
2018-10-02 15:36:44 +08:00
|
|
|
if (!config.ldc_fd) {
|
2019-01-09 17:44:41 +08:00
|
|
|
ret = errno;
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr, "error: Unable to open ldc file %s: %s\n",
|
|
|
|
config.ldc_file, strerror(ret));
|
2018-10-02 15:36:44 +08:00
|
|
|
goto out;
|
2016-09-28 00:29:55 +08:00
|
|
|
}
|
2018-10-24 21:17:33 +08:00
|
|
|
|
|
|
|
if (config.version_fw) {
|
2019-01-31 18:11:57 +08:00
|
|
|
config.version_fd = fopen(config.version_file, "rb");
|
2018-10-24 21:17:33 +08:00
|
|
|
if (!config.version_fd) {
|
2019-01-09 17:44:41 +08:00
|
|
|
ret = errno;
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
"error: Unable to open version file %s: %s\n",
|
|
|
|
config.version_file, strerror(ret));
|
2018-10-24 21:17:33 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
2018-10-02 15:36:44 +08:00
|
|
|
|
|
|
|
if (config.out_file) {
|
|
|
|
config.out_fd = fopen(config.out_file, "w");
|
|
|
|
if (!config.out_fd) {
|
2019-01-09 17:44:41 +08:00
|
|
|
ret = errno;
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr, "error: Unable to open out file %s: %s\n",
|
|
|
|
config.out_file, strerror(ret));
|
2018-10-02 15:36:44 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
config.out_fd = stdout;
|
2016-09-28 00:29:55 +08:00
|
|
|
}
|
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
/* trace requested ? */
|
|
|
|
if (config.trace)
|
|
|
|
config.in_file = "/sys/kernel/debug/sof/trace";
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2021-03-21 09:46:56 +08:00
|
|
|
/* Default value when -e is not specified */
|
|
|
|
if (config.relative_timestamps == INT_MAX)
|
|
|
|
config.relative_timestamps = config.raw_output ? 0 : 1;
|
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
/* default option with no infile is to dump errors/debug data */
|
2020-05-20 21:46:21 +08:00
|
|
|
if (!config.in_file && !config.dump_ldc)
|
2018-10-02 15:36:44 +08:00
|
|
|
config.in_file = "/sys/kernel/debug/sof/etrace";
|
|
|
|
|
2018-10-08 20:18:08 +08:00
|
|
|
if (config.input_std) {
|
|
|
|
config.in_fd = stdin;
|
2019-01-09 18:03:57 +08:00
|
|
|
} else if (baud) {
|
|
|
|
config.serial_fd = configure_uart(config.in_file, baud);
|
|
|
|
if (config.serial_fd < 0) {
|
|
|
|
ret = -config.serial_fd;
|
|
|
|
goto out;
|
|
|
|
}
|
2020-05-20 21:46:21 +08:00
|
|
|
} else if (config.in_file) {
|
2019-01-31 18:11:57 +08:00
|
|
|
config.in_fd = fopen(config.in_file, "rb");
|
2018-10-02 15:36:44 +08:00
|
|
|
if (!config.in_fd) {
|
2019-01-09 17:44:41 +08:00
|
|
|
ret = errno;
|
2021-03-22 09:18:36 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
"error: Unable to open in file %s: %s\n",
|
|
|
|
config.in_file, strerror(ret));
|
2018-10-02 15:36:44 +08:00
|
|
|
goto out;
|
2017-10-12 21:17:09 +08:00
|
|
|
}
|
2018-10-02 15:36:44 +08:00
|
|
|
}
|
2018-12-04 00:45:42 +08:00
|
|
|
if (isatty(fileno(config.out_fd)) != 1)
|
|
|
|
config.use_colors = 0;
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2019-01-09 17:44:41 +08:00
|
|
|
ret = -convert(&config);
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
out:
|
2020-05-29 20:29:40 +08:00
|
|
|
/* free memory */
|
|
|
|
if (config.filter_config)
|
|
|
|
free(config.filter_config);
|
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
/* close files */
|
2018-10-11 17:34:14 +08:00
|
|
|
if (config.out_fd)
|
2018-10-02 15:36:44 +08:00
|
|
|
fclose(config.out_fd);
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
if (config.in_fd)
|
|
|
|
fclose(config.in_fd);
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
if (config.ldc_fd)
|
|
|
|
fclose(config.ldc_fd);
|
2018-11-19 18:40:05 +08:00
|
|
|
|
2018-10-24 21:17:33 +08:00
|
|
|
if (config.version_fd)
|
|
|
|
fclose(config.version_fd);
|
2016-09-28 00:29:55 +08:00
|
|
|
|
2018-10-02 15:36:44 +08:00
|
|
|
return ret;
|
2016-09-28 00:29:55 +08:00
|
|
|
}
|