summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorVinson Lee <vlee@freedesktop.org>2013-09-27 22:42:58 -0700
committerVinson Lee <vlee@freedesktop.org>2013-09-30 21:53:04 -0700
commitac82495d6d562091d819b0109adf43fd89e49537 (patch)
treef969aced9fbdbb483dbc6f97812eb164cb8bdfaf /src/gallium/auxiliary/util
parent505a6de7fc5e281d0faf7950cc97fbe88cd9bbf4 (diff)
downloadexternal_mesa3d-ac82495d6d562091d819b0109adf43fd89e49537.zip
external_mesa3d-ac82495d6d562091d819b0109adf43fd89e49537.tar.gz
external_mesa3d-ac82495d6d562091d819b0109adf43fd89e49537.tar.bz2
util/u_format: Assert that format block size is at least 1 byte.
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 <vlee@freedesktop.org> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_format.h7
1 files changed, 6 insertions, 1 deletions
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