Mesa (master): util/os_file: avoid shadowing read() with a local variable

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 9 13:22:50 UTC 2019


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

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Thu May 16 15:02:45 2019 +0100

util/os_file: avoid shadowing read() with a local variable

Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/util/os_file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/os_file.c b/src/util/os_file.c
index da17d12b50e..400a2a12c4d 100644
--- a/src/util/os_file.c
+++ b/src/util/os_file.c
@@ -70,9 +70,9 @@ os_read_file(const char *filename)
       return NULL;
    }
 
-   ssize_t read;
+   ssize_t actually_read;
    size_t offset = 0, remaining = len - 1;
-   while ((read = readN(fd, buf + offset, remaining)) == remaining) {
+   while ((actually_read = readN(fd, buf + offset, remaining)) == remaining) {
       char *newbuf = realloc(buf, 2 * len);
       if (!newbuf) {
          free(buf);
@@ -83,14 +83,14 @@ os_read_file(const char *filename)
 
       buf = newbuf;
       len *= 2;
-      offset += read;
+      offset += actually_read;
       remaining = len - offset - 1;
    }
 
    close(fd);
 
-   if (read > 0)
-      offset += read;
+   if (actually_read > 0)
+      offset += actually_read;
 
    buf[offset] = '\0';
 




More information about the mesa-commit mailing list