On 09/27/2013 11:52 PM, Vinson Lee wrote:
The block size for all formats is currently at least 1 byte. Add an
assertion for this.

This should silence several Coverity "Division or modulo by zero"
defects.

Signed-off-by: Vinson Lee <v...@freedesktop.org>
---
  src/gallium/auxiliary/util/u_format.h | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_format.h 
b/src/gallium/auxiliary/util/u_format.h
index 28527f5..84f16d5 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -716,10 +716,15 @@ static INLINE uint
  util_format_get_blocksize(enum pipe_format format)
  {
     uint bits = util_format_get_blocksizebits(format);
+   uint bytes = bits / 8;

     assert(bits % 8 == 0);
+   assert(bytes > 0);
+   if (bytes == 0) {
+      bytes = 1;
+   }

-   return bits / 8;
+   return bytes;
  }

  static INLINE uint


Reviewed-by: Brian Paul <bri...@vmware.com>

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to