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>
This commit is contained in:
Eric Anholt 2020-10-19 11:46:43 -07:00 committed by Marge Bot
parent 91c5bbc128
commit a512e9eecd
2 changed files with 6 additions and 2 deletions

View file

@ -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);

View file

@ -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);