Mesa (master): os: Fix open result check.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 2 19:29:55 UTC 2020


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

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Tue Oct 27 16:21:11 2020 -0700

os: Fix open result check.

Fix defect reported by Coverity Scan.

Argument cannot be negative (NEGATIVE_RETURNS)
negative_returns: f is passed to a parameter that cannot be negative.

CID: 1364709
Fixes: 13fa0513569d ("auxiliary/os: add new os_get_command_line() function")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7344>

---

 src/gallium/auxiliary/os/os_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c
index f2721a0fb52..b00ff2b0d23 100644
--- a/src/gallium/auxiliary/os/os_process.c
+++ b/src/gallium/auxiliary/os/os_process.c
@@ -122,7 +122,7 @@ os_get_command_line(char *cmdline, size_t size)
    }
 #elif defined(PIPE_OS_LINUX)
    int f = open("/proc/self/cmdline", O_RDONLY);
-   if (f) {
+   if (f != -1) {
       const int n = read(f, cmdline, size - 1);
       int i;
       assert(n < size);



More information about the mesa-commit mailing list