Commit 8dcce86d by Alexis Hetu Committed by Alexis Hétu

More warnings fixed

Fixed warnings related to type conversions leading to potential loss of precision. BUG=18368388 Change-Id: I71a7941df4bcf991f04818060780d4d395e335a9 Reviewed-on: https://swiftshader-review.googlesource.com/1393Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 0c4c3e74
......@@ -92,17 +92,14 @@ reflect(unsigned long data, unsigned char nBits)
*
*********************************************************************/
crc
crcSlow(unsigned char const message[], int nBytes)
crcSlow(unsigned char const message[], size_t nBytes)
{
crc remainder = INITIAL_REMAINDER;
int byte;
unsigned char bit;
/*
* Perform modulo-2 division, a byte at a time.
*/
for (byte = 0; byte < nBytes; ++byte)
for (size_t byte = 0; byte < nBytes; ++byte)
{
/*
* Bring the next byte into the remainder.
......@@ -112,7 +109,7 @@ crcSlow(unsigned char const message[], int nBytes)
/*
* Perform modulo-2 division, a bit at a time.
*/
for (bit = 8; bit > 0; --bit)
for (unsigned char bit = 8; bit > 0; --bit)
{
/*
* Try to divide the current data bit.
......@@ -155,25 +152,20 @@ crc crcTable[256];
void
crcInit(void)
{
crc remainder;
int dividend;
unsigned char bit;
/*
* Compute the remainder of each possible dividend.
*/
for (dividend = 0; dividend < 256; ++dividend)
for (int dividend = 0; dividend < 256; ++dividend)
{
/*
* Start with the dividend followed by zeros.
*/
remainder = dividend << (WIDTH - 8);
crc remainder = dividend << (WIDTH - 8);
/*
* Perform modulo-2 division, a bit at a time.
*/
for (bit = 8; bit > 0; --bit)
for (unsigned char bit = 8; bit > 0; --bit)
{
/*
* Try to divide the current data bit.
......@@ -209,19 +201,16 @@ crcInit(void)
*
*********************************************************************/
crc
crcFast(unsigned char const message[], int nBytes)
crcFast(unsigned char const message[], size_t nBytes)
{
crc remainder = INITIAL_REMAINDER;
unsigned char data;
int byte;
/*
* Divide the message by the polynomial, a byte at a time.
*/
for (byte = 0; byte < nBytes; ++byte)
for (size_t byte = 0; byte < nBytes; ++byte)
{
data = REFLECT_DATA(message[byte]) ^ (remainder >> (WIDTH - 8));
unsigned char data = REFLECT_DATA(message[byte]) ^ (remainder >> (WIDTH - 8));
remainder = crcTable[data] ^ (remainder << 8);
}
......
......@@ -16,6 +16,8 @@
#ifndef _crc_h
#define _crc_h
#include <stddef.h>
/*
* Select the CRC standard from the list that follows.
*/
......@@ -68,8 +70,8 @@ typedef unsigned long crc;
extern "C" {
#endif
void crcInit(void);
crc crcSlow(unsigned char const message[], int nBytes);
crc crcFast(unsigned char const message[], int nBytes);
crc crcSlow(unsigned char const message[], size_t nBytes);
crc crcFast(unsigned char const message[], size_t nBytes);
#ifdef __cplusplus
}
#endif
......
......@@ -2038,7 +2038,7 @@ void Context::applyTextures(sw::SamplerType samplerType)
GLenum wrapT = texture->getWrapT();
GLenum texFilter = texture->getMinFilter();
GLenum magFilter = texture->getMagFilter();
GLenum maxAnisotropy = texture->getMaxAnisotropy();
GLfloat maxAnisotropy = texture->getMaxAnisotropy();
device->setAddressingModeU(samplerType, samplerIndex, rad2sw::ConvertTextureWrap(wrapS));
device->setAddressingModeV(samplerType, samplerIndex, rad2sw::ConvertTextureWrap(wrapT));
......
......@@ -1903,7 +1903,7 @@ namespace sw
{
if(!vertexShader) return;
int count = vertexShader->getLength();
size_t count = vertexShader->getLength();
for(int i = 0; i < count; i++)
{
......@@ -1947,7 +1947,7 @@ namespace sw
{
if(!pixelShader) return;
int count = pixelShader->getLength();
size_t count = pixelShader->getLength();
for(int i = 0; i < count; i++)
{
......
......@@ -1327,7 +1327,7 @@ namespace sw
return serialID;
}
int Shader::getLength() const
size_t Shader::getLength() const
{
return instruction.size();
}
......
......@@ -477,7 +477,7 @@ namespace sw
~Shader();
int getSerialID() const;
int getLength() const;
size_t getLength() const;
ShaderType getShaderType() const;
unsigned short getVersion() const;
......
......@@ -311,6 +311,7 @@
<ClCompile Include="..\Common\Socket.cpp" />
<ClCompile Include="..\Common\Thread.cpp" />
<ClCompile Include="..\Main\Config.cpp" />
<ClCompile Include="..\Main\crc.cpp" />
<ClCompile Include="..\Main\FrameBufferWin.cpp" />
<ClCompile Include="..\Main\Register.cpp" />
<ClCompile Include="..\Shader\Constants.cpp" />
......@@ -360,7 +361,6 @@
<ClCompile Include="..\Renderer\TextureStage.cpp" />
<ClCompile Include="..\Renderer\Vector.cpp" />
<ClCompile Include="..\Renderer\VertexProcessor.cpp" />
<ClCompile Include="..\Main\crc.c" />
<ClCompile Include="..\Main\FrameBuffer.cpp" />
<ClCompile Include="..\Main\FrameBufferDD.cpp" />
<ClCompile Include="..\Main\FrameBufferGDI.cpp" />
......
......@@ -119,9 +119,6 @@
<ClCompile Include="..\Renderer\VertexProcessor.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="..\Main\crc.c">
<Filter>Source Files\Main</Filter>
</ClCompile>
<ClCompile Include="..\Main\FrameBuffer.cpp">
<Filter>Source Files\Main</Filter>
</ClCompile>
......@@ -179,6 +176,9 @@
<ClCompile Include="..\Main\FrameBufferWin.cpp">
<Filter>Source Files\Main</Filter>
</ClCompile>
<ClCompile Include="..\Main\crc.cpp">
<Filter>Source Files\Main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MemoryManager.hpp">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment