Mesa (master): freedreno/rnn: split out helper to find files

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 29 14:50:08 UTC 2020


Module: Mesa
Branch: master
Commit: 3a910839bafbd07aeae67d682d70926dd6fa549e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a910839bafbd07aeae67d682d70926dd6fa549e

Author: Rob Clark <robdclark at chromium.org>
Date:   Tue Jul 28 08:30:13 2020 -0700

freedreno/rnn: split out helper to find files

So we can re-use it to locate the schema file.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6107>

---

 src/freedreno/rnn/rnn.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/freedreno/rnn/rnn.c b/src/freedreno/rnn/rnn.c
index d28f7a02ddc..8893827170e 100644
--- a/src/freedreno/rnn/rnn.c
+++ b/src/freedreno/rnn/rnn.c
@@ -878,10 +878,10 @@ static int trytop (struct rnndb *db, char *file, xmlNode *node) {
 	return 0;
 }
 
-void rnn_parsefile (struct rnndb *db, char *file_orig) {
-	int i;
-	char *fname;
+static char * find_file(const char *file_orig)
+{
 	const char *rnn_path = getenv("RNN_PATH");
+	char *fname;
 
 	if (!rnn_path)
 		rnn_path = RNN_DEF_PATH;
@@ -889,10 +889,22 @@ void rnn_parsefile (struct rnndb *db, char *file_orig) {
 	FILE *file = find_in_path(file_orig, rnn_path, &fname);
 	if (!file) {
 		fprintf (stderr, "%s: couldn't find database file. Please set the env var RNN_PATH.\n", file_orig);
+		return NULL;
+	}
+	fclose(file);
+
+	return fname;
+}
+
+void rnn_parsefile (struct rnndb *db, char *file_orig) {
+	int i;
+	char *fname;
+
+	fname = find_file(file_orig);
+	if (!fname) {
 		db->estatus = 1;
 		return;
 	}
-	fclose(file);
 
 	for (i = 0; i < db->filesnum; i++)
 		if (!strcmp(db->files[i], fname))



More information about the mesa-commit mailing list