glsl: fix bounds check in blob_overwrite_bytes
authorRob Herring <robh@kernel.org>
Thu, 1 Jun 2017 00:07:40 +0000 (19:07 -0500)
committerRob Herring <robh@kernel.org>
Thu, 8 Jun 2017 01:44:26 +0000 (20:44 -0500)
commit18348a383dae41567fd333db6f848fbc8ff7d99b
treecc018cacfd7de3350a127df1ea8f88f7da387cab
parent4453fbb02447288e21206a676a24ff70b64857b1
glsl: fix bounds check in blob_overwrite_bytes

clang gives a warning in blob_overwrite_bytes because offset type is
size_t which is unsigned:

src/compiler/glsl/blob.c:110:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
   if (offset < 0 || blob->size - offset < to_write)
       ~~~~~~ ^ ~

Remove the less than 0 check to fix this.

Additionally, if offset is greater than blob->size, the 2nd check would
be false due to unsigned math. Rewrite the check to avoid subtraction.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Rob Herring <robh@kernel.org>
src/compiler/glsl/blob.c