Mesa (master): freedreno/rnn: also look for .xml.gz

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 3 20:04:24 UTC 2020


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Sun Aug  2 10:00:02 2020 -0700

freedreno/rnn: also look for .xml.gz

libxml2 can load gzip compressed files, so lets look for these too.
This will be useful for installing the register database so that an
installed cffdump/crashdec can use them.  But it isn't too useful
to be able to edit the installed register database, so we can gzip
them to use less disk space.

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

---

 src/freedreno/rnn/path.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/freedreno/rnn/path.c b/src/freedreno/rnn/path.c
index 7b89a042095..f8ef885d891 100644
--- a/src/freedreno/rnn/path.c
+++ b/src/freedreno/rnn/path.c
@@ -38,20 +38,25 @@ FILE *find_in_path(const char *name, const char *path, char **pfullname) {
 			plen = strlen(path);
 		}
 		if (plen) {
-			char *fullname = malloc(strlen(name) + plen + 2);
-			strncpy(fullname, path, plen);
-			fullname[plen] = '/';
-			fullname[plen+1] = 0;
-			strcat(fullname, name);
-			FILE *file = fopen(fullname, "r");
-			if (file) {
-				if (pfullname)
-					*pfullname = fullname;
-				else
-					free(fullname);
-				return file;
+			/* also look for .gz compressed xml: */
+			const char *exts[] = { "", ".gz" };
+			for (int i = 0; i < ARRAY_SIZE(exts); i++) {
+				char *fullname;
+
+				int ret = asprintf(&fullname, "%.*s/%s%s", (int)plen, path, name, exts[i]);
+				if (ret < 0)
+					return NULL;
+
+				FILE *file = fopen(fullname, "r");
+				if (file) {
+					if (pfullname)
+						*pfullname = fullname;
+					else
+						free(fullname);
+					return file;
+				}
+				free(fullname);
 			}
-			free(fullname);
 		}
 		path = npath;
 	}



More information about the mesa-commit mailing list