[PATCH 01/20] fwts_log_scan: add lib/src/fwts_log_scan.c
Marcello Sylvester Bauer
info at marcellobauer.com
Tue Jun 26 13:10:51 UTC 2018
Add a new library for generic logfile scan functions, to make them
globally available.
TODO: Move fwts_klog functions to fwts_log_scan as interface
Signed-off-by: Marcello Sylvester Bauer <info at marcellobauer.com>
---
src/lib/include/fwts.h | 1 +
src/lib/include/fwts_klog.h | 17 -----------------
src/lib/include/fwts_log_scan.h | 41 +++++++++++++++++++++++++++++++++++++++++
src/lib/src/fwts_klog.c | 6 +++---
src/lib/src/fwts_olog.c | 4 ++--
5 files changed, 47 insertions(+), 22 deletions(-)
create mode 100644 src/lib/include/fwts_log_scan.h
diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
index 9428814b..9f992ef2 100644
--- a/src/lib/include/fwts.h
+++ b/src/lib/include/fwts.h
@@ -78,6 +78,7 @@
#include "fwts_binpaths.h"
#include "fwts_framework.h"
#include "fwts_log.h"
+#include "fwts_log_scan.h"
#include "fwts_list.h"
#include "fwts_text_list.h"
#include "fwts_set.h"
diff --git a/src/lib/include/fwts_klog.h b/src/lib/include/fwts_klog.h
index 627bc61e..0c077b71 100644
--- a/src/lib/include/fwts_klog.h
+++ b/src/lib/include/fwts_klog.h
@@ -32,23 +32,6 @@
#define KERN_ERROR 0x00000002
-typedef enum {
- FWTS_COMPARE_REGEX = 'r',
- FWTS_COMPARE_STRING = 's',
- FWTS_COMPARE_UNKNOWN = 'u'
-} fwts_compare_mode;
-
-typedef struct {
- fwts_compare_mode compare_mode;
- fwts_log_level level;
- const char *pattern;
- const char *advice;
- char *label;
- regex_t compiled;
- bool compiled_ok;
-} fwts_klog_pattern;
-
-
typedef void (*fwts_klog_progress_func)(fwts_framework *fw, int percent);
typedef void (*fwts_klog_scan_func)(fwts_framework *fw, char *line, int repeated, char *prevline, void *private, int *errors);
diff --git a/src/lib/include/fwts_log_scan.h b/src/lib/include/fwts_log_scan.h
new file mode 100644
index 00000000..ccb712ec
--- /dev/null
+++ b/src/lib/include/fwts_log_scan.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2018 Canonical
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __FWTS_LOG_SCAN_H__
+#define __FWTS_LOG_SCAN_H__
+
+#include <regex.h>
+
+typedef enum {
+ FWTS_COMPARE_REGEX = 'r',
+ FWTS_COMPARE_STRING = 's',
+ FWTS_COMPARE_UNKNOWN = 'u'
+} fwts_compare_mode;
+
+typedef struct {
+ fwts_compare_mode compare_mode;
+ fwts_log_level level;
+ const char *pattern;
+ const char *advice;
+ char *label;
+ regex_t compiled;
+ bool compiled_ok;
+} fwts_log_pattern;
+
+#endif
diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
index 136cf238..c7fc4cb1 100644
--- a/src/lib/src/fwts_klog.c
+++ b/src/lib/src/fwts_klog.c
@@ -269,7 +269,7 @@ void fwts_klog_scan_patterns(fwts_framework *fw,
void *private,
int *errors)
{
- fwts_klog_pattern *pattern = (fwts_klog_pattern *)private;
+ fwts_log_pattern *pattern = (fwts_log_pattern *)private;
static char *advice =
"This is a bug picked up by the kernel, but as yet, the "
"firmware test suite has no diagnostic advice for this particular problem.";
@@ -381,7 +381,7 @@ static int fwts_klog_check(fwts_framework *fw,
int fd;
json_object *klog_objs;
json_object *klog_table;
- fwts_klog_pattern *patterns;
+ fwts_log_pattern *patterns;
char json_data_path[PATH_MAX];
if (fw->json_data_file) {
@@ -423,7 +423,7 @@ static int fwts_klog_check(fwts_framework *fw,
n = json_object_array_length(klog_table);
/* Last entry is null to indicate end, so alloc n+1 items */
- if ((patterns = calloc(n+1, sizeof(fwts_klog_pattern))) == NULL) {
+ if ((patterns = calloc(n+1, sizeof(fwts_log_pattern))) == NULL) {
fwts_log_error(fw, "Cannot allocate pattern table.");
goto fail_put;
}
diff --git a/src/lib/src/fwts_olog.c b/src/lib/src/fwts_olog.c
index fdc2d5ed..e350ac47 100644
--- a/src/lib/src/fwts_olog.c
+++ b/src/lib/src/fwts_olog.c
@@ -191,7 +191,7 @@ static int fwts_olog_check(fwts_framework *fw,
{
int n, i, fd, ret = FWTS_ERROR;
json_object *olog_objs, *olog_table;
- fwts_klog_pattern *patterns;
+ fwts_log_pattern *patterns;
char json_data_path[PATH_MAX];
if (fw->json_data_file) {
@@ -239,7 +239,7 @@ static int fwts_olog_check(fwts_framework *fw,
n = json_object_array_length(olog_table);
/* Last entry is null to indicate end, so alloc n+1 items */
- if ((patterns = calloc(n+1, sizeof(fwts_klog_pattern))) == NULL) {
+ if ((patterns = calloc(n+1, sizeof(fwts_log_pattern))) == NULL) {
fwts_log_error(fw, "Cannot allocate pattern table.");
goto fail_put;
}
--
2.16.4
More information about the fwts-devel
mailing list