From 8f766d37ebf0b44504cacd1cd8d017037e734e7d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 27 Oct 2020 16:21:11 -0700 Subject: [PATCH] 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 Reviewed-by: Adam Jackson Part-of: (cherry picked from commit b2a21febe0416d7d5506fdc9592b7b4c10431077) --- .pick_status.json | 2 +- src/gallium/auxiliary/os/os_process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3c751cd2db5..0658ea95f3e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5539,7 +5539,7 @@ "description": "os: Fix open result check.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "13fa0513569d0145487e12f3bc3aa10bc51088f7" }, 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);