Fix MSVC "value may be truncated" warnings. (by pkasting@)

git-svn-id: https://cld2.googlecode.com/svn/trunk@168 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
hajimehoshi@google.com
2014-09-17 07:11:37 +00:00
parent bb5c092e8c
commit c9f9d40322
5 changed files with 11 additions and 10 deletions

View File

@@ -599,7 +599,8 @@ int ReliabilityExpected(int actual_score_1kb, int expected_score_1kb) {
if (ratio <= kRatio100) {return 100;} if (ratio <= kRatio100) {return 100;}
if (ratio > kRatio0) {return 0;} if (ratio > kRatio0) {return 0;}
int percent_good = 100.0 * (kRatio0 - ratio) / (kRatio0 - kRatio100); int percent_good =
static_cast<int>(100.0 * (kRatio0 - ratio) / (kRatio0 - kRatio100));
return percent_good; return percent_good;
} }

View File

@@ -392,7 +392,7 @@ inline void OctaFPJustHash(uint64 longwordhash,
uint32* subscr, uint32* hashkey) { uint32* subscr, uint32* hashkey) {
uint32 temp = (longwordhash + (longwordhash >> 12)) & (bucketcount - 1); uint32 temp = (longwordhash + (longwordhash >> 12)) & (bucketcount - 1);
*subscr = temp; *subscr = temp;
temp = longwordhash >> 4; temp = static_cast<uint32>(longwordhash >> 4);
*hashkey = temp & keymask; *hashkey = temp & keymask;
} }

View File

@@ -253,13 +253,13 @@ int runetochar(char *str, const char32 *rune) {
// 1 char 00-7F // 1 char 00-7F
c = *rune; c = *rune;
if(c <= 0x7F) { if(c <= 0x7F) {
str[0] = c; str[0] = static_cast<char>(c);
return 1; return 1;
} }
// 2 char 0080-07FF // 2 char 0080-07FF
if(c <= 0x07FF) { if(c <= 0x07FF) {
str[0] = 0xC0 | (c >> 1*6); str[0] = 0xC0 | static_cast<char>(c >> 1*6);
str[1] = 0x80 | (c & 0x3F); str[1] = 0x80 | (c & 0x3F);
return 2; return 2;
} }
@@ -271,14 +271,14 @@ int runetochar(char *str, const char32 *rune) {
// 3 char 0800-FFFF // 3 char 0800-FFFF
if (c <= 0xFFFF) { if (c <= 0xFFFF) {
str[0] = 0xE0 | (c >> 2*6); str[0] = 0xE0 | static_cast<char>(c >> 2*6);
str[1] = 0x80 | ((c >> 1*6) & 0x3F); str[1] = 0x80 | ((c >> 1*6) & 0x3F);
str[2] = 0x80 | (c & 0x3F); str[2] = 0x80 | (c & 0x3F);
return 3; return 3;
} }
// 4 char 10000-1FFFFF // 4 char 10000-1FFFFF
str[0] = 0xF0 | (c >> 3*6); str[0] = 0xF0 | static_cast<char>(c >> 3*6);
str[1] = 0x80 | ((c >> 2*6) & 0x3F); str[1] = 0x80 | ((c >> 2*6) & 0x3F);
str[2] = 0x80 | ((c >> 1*6) & 0x3F); str[2] = 0x80 | ((c >> 1*6) & 0x3F);
str[3] = 0x80 | (c & 0x3F); str[3] = 0x80 | (c & 0x3F);

View File

@@ -184,7 +184,7 @@ void GetTextSpanOffsets(const ScoringHitBuffer* hitbuffer,
int DiffScore(const CLD2TableSummary* obj, int indirect, int DiffScore(const CLD2TableSummary* obj, int indirect,
uint16 lang1, uint16 lang2) { uint8 lang1, uint8 lang2) {
if (indirect < static_cast<int>(obj->kCLDTableSizeOne)) { if (indirect < static_cast<int>(obj->kCLDTableSizeOne)) {
// Up to three languages at indirect // Up to three languages at indirect
uint32 langprob = obj->kCLDTableInd[indirect]; uint32 langprob = obj->kCLDTableInd[indirect];
@@ -669,7 +669,7 @@ void DumpSummaryBuffer(FILE* df, const SummaryBuffer* summarybuffer) {
int BetterBoundary(const char* text, int BetterBoundary(const char* text,
ScoringHitBuffer* hitbuffer, ScoringHitBuffer* hitbuffer,
ScoringContext* scoringcontext, ScoringContext* scoringcontext,
uint16 pslang0, uint16 pslang1, uint8 pslang0, uint8 pslang1,
int linear0, int linear1, int linear2) { int linear0, int linear1, int linear2) {
// Degenerate case, no change // Degenerate case, no change
if ((linear2 - linear0) <= 8) {return linear1;} if ((linear2 - linear0) <= 8) {return linear1;}

View File

@@ -236,7 +236,7 @@ void DocTote::Sort(int n) {
value_[sub] = value_[sub2]; value_[sub] = value_[sub2];
value_[sub2] = tmpv; value_[sub2] = tmpv;
double tmps = score_[sub]; int tmps = score_[sub];
score_[sub] = score_[sub2]; score_[sub] = score_[sub2];
score_[sub2] = tmps; score_[sub2] = tmps;