Mesa (master): freedreno/tools: Fix compiler warnings about using sz in the error paths.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 20 22:28:44 UTC 2020


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Oct 19 11:46:43 2020 -0700

freedreno/tools: Fix compiler warnings about using sz in the error paths.

If we don't check for a NULL str, then sz might be undefined (as was
happening in the match_compatible path, and returning 0 makes us not match
as we should).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7224>

---

 src/freedreno/afuc/disasm.c      | 4 +++-
 src/freedreno/perfcntrs/fdperf.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/freedreno/afuc/disasm.c b/src/freedreno/afuc/disasm.c
index 0e013f59a3a..0bd1e1a9516 100644
--- a/src/freedreno/afuc/disasm.c
+++ b/src/freedreno/afuc/disasm.c
@@ -781,8 +781,10 @@ static char * readfile(const char *path, int *sz)
 	int fd, ret, n = 0;
 
 	fd = open(path, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		*sz = 0;
 		return NULL;
+	}
 
 	while (1) {
 		buf = realloc(buf, n + CHUNKSIZE);
diff --git a/src/freedreno/perfcntrs/fdperf.c b/src/freedreno/perfcntrs/fdperf.c
index d53828dc0b6..44d9d837035 100644
--- a/src/freedreno/perfcntrs/fdperf.c
+++ b/src/freedreno/perfcntrs/fdperf.c
@@ -115,8 +115,10 @@ readfile(const char *path, int *sz)
 	int fd, ret, n = 0;
 
 	fd = open(path, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		*sz = 0;
 		return NULL;
+	}
 
 	while (1) {
 		buf = realloc(buf, n + CHUNKSIZE);



More information about the mesa-commit mailing list