Mesa (master): glx: lets compare drawing command sizes using MIN3

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 14 17:14:06 UTC 2020


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

Author: Andrii Simiklit <andrii.simiklit at globallogic.com>
Date:   Mon Dec  7 12:50:28 2020 +0200

glx: lets compare drawing command sizes using MIN3

It has to fix coverity issue CID1470555:
```
481        if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
482           bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
483        }
484        if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
>>>     CID 1470555:  Control flow issues  (DEADCODE)
>>>     Execution cannot reach this statement: "bufSize = 64000;".
485           bufSize = __GLX_MAX_RENDER_CMD_SIZE;
486        }
```

Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7965>

---

 src/glx/indirect_glx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c
index 5c8e71beb39..3f3e1c82265 100644
--- a/src/glx/indirect_glx.c
+++ b/src/glx/indirect_glx.c
@@ -478,14 +478,9 @@ indirect_create_context_attribs(struct glx_screen *psc,
     ** constrain by a software limit, then constrain by the protocl
     ** limit.
     */
-   if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
-      bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
-   }
-   if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
-      bufSize = __GLX_MAX_RENDER_CMD_SIZE;
-   }
-   gc->maxSmallRenderCommandSize = bufSize;
-   
+   gc->maxSmallRenderCommandSize = MIN3(bufSize, __GLX_RENDER_CMD_SIZE_LIMIT,
+                                        __GLX_MAX_RENDER_CMD_SIZE);
+
 
    return gc;
 }



More information about the mesa-commit mailing list