Merge lp:~skinny.moey/drizzle/drizzle-warnings-conversion into lp:~drizzle-trunk/drizzle/development

Proposed by Joe Daly
Status: Superseded
Proposed branch: lp:~skinny.moey/drizzle/drizzle-warnings-conversion
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 476 lines
6 files modified
mystrings/ctype-bin.cc (+8/-7)
mystrings/ctype-mb.cc (+9/-7)
mystrings/ctype-simple.cc (+31/-28)
mystrings/ctype-uca.cc (+15/-12)
mysys/ptr_cmp.cc (+5/-5)
mysys/tree.cc (+10/-5)
To merge this branch: bzr merge lp:~skinny.moey/drizzle/drizzle-warnings-conversion
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+12398@code.launchpad.net

This proposal has been superseded by a proposal from 2009-10-02.

To post a comment you must log in.
Revision history for this message
Joe Daly (skinny.moey) wrote :

Changes to eventually enable -Wconversion to be turned on.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Well, Joe, you've picked some of the ugliest code to dig into! :)

I'm going to take some extra time and review this carefully. There are a couple things I'm concerned about and want to double-check with my C++ standards books to verify.

Namely:

1) There are a couple places where I see uint32_t being used where I believe ptr_diff_t is appropriate.

2) static_cast<short unsigned int>() should be static_cast<uint16_t>() ?

3) static_cast<unsigned long>() should be static_cast<uint32_t>() ?

Anyway, I just want to make sure, so there may be a bit of a delay on this, ok?

Thanks for your patience!

Jay

Revision history for this message
Stewart Smith (stewart) wrote :

What about enabling -Wconversion as we go through places that can be built with it? e.g. I guess after this patch we could do it for mysys/ ?

Revision history for this message
Joe Daly (skinny.moey) wrote :

> What about enabling -Wconversion as we go through places that can be built
> with it? e.g. I guess after this patch we could do it for mysys/ ?

Good idea! I should be able enable it for mystrings and mysys in my next commit.

1137. By Joe Daly

update with trunk

1138. By Joe Daly

style change

1139. By Joe Daly

change unsigned long to uint32_t

1140. By Joe Daly

change short unsigned int to uint16_t

Unmerged revisions

1140. By Joe Daly

change short unsigned int to uint16_t

1139. By Joe Daly

change unsigned long to uint32_t

1138. By Joe Daly

style change

1137. By Joe Daly

update with trunk

1136. By Joe Daly

Changes to allow compilation with -Wconversion turned on. Also change iteration type to uint16_t from uint32_t this was producing a conversion warning, there is no need for a conversion, rather change the index type.

1135. By Joe Daly

merge with trunk

1134. By Joe Daly

changes to allow -Wconversiion to be turned on

1133. By Joe Daly

changes to allow -Wconversiion to be turned on

1132. By Joe Daly

changes to allow -Wconversiion to be turned on

1131. By Joe Daly

changes to allow -Wconversiion to be turned on

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mystrings/ctype-bin.cc'
--- mystrings/ctype-bin.cc 2009-07-07 09:06:29 +0000
+++ mystrings/ctype-bin.cc 2009-10-02 12:21:10 +0000
@@ -284,8 +284,8 @@
284284
285 for (; pos < (unsigned char*) key ; pos++)285 for (; pos < (unsigned char*) key ; pos++)
286 {286 {
287 nr1[0]^=(ulong) ((((uint32_t) nr1[0] & 63)+nr2[0]) *287 nr1[0]^= ((nr1[0] & 63) + nr2[0]) * (static_cast<uint32_t>(*pos)) +
288 ((uint32_t)*pos)) + (nr1[0] << 8);288 (nr1[0] << 8);
289 nr2[0]+=3;289 nr2[0]+=3;
290 }290 }
291}291}
@@ -301,8 +301,8 @@
301301
302 for (; pos < (unsigned char*) key ; pos++)302 for (; pos < (unsigned char*) key ; pos++)
303 {303 {
304 nr1[0]^=(ulong) ((((uint32_t) nr1[0] & 63)+nr2[0]) *304 nr1[0]^= ((nr1[0] & 63) + nr2[0]) * (static_cast<uint32_t>(*pos)) +
305 ((uint32_t)*pos)) + (nr1[0] << 8);305 (nr1[0] << 8);
306 nr2[0]+=3;306 nr2[0]+=3;
307 }307 }
308}308}
@@ -405,7 +405,7 @@
405 if (dst != src)405 if (dst != src)
406 memcpy(dst, src, srclen);406 memcpy(dst, src, srclen);
407 return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen,407 return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen,
408 nweights - srclen, flags, 0);408 static_cast<uint32_t>(nweights - srclen), flags, 0);
409}409}
410410
411411
@@ -451,13 +451,14 @@
451 if (nmatch > 0)451 if (nmatch > 0)
452 {452 {
453 match[0].beg= 0;453 match[0].beg= 0;
454 match[0].end= (size_t) (str- (const unsigned char*)b-1);454 match[0].end= static_cast<uint32_t>((str -
455 reinterpret_cast<const unsigned char*>(b) - 1));
455 match[0].mb_len= match[0].end;456 match[0].mb_len= match[0].end;
456457
457 if (nmatch > 1)458 if (nmatch > 1)
458 {459 {
459 match[1].beg= match[0].end;460 match[1].beg= match[0].end;
460 match[1].end= match[0].end+s_length;461 match[1].end= static_cast<uint32_t>(match[0].end + s_length);
461 match[1].mb_len= match[1].end-match[1].beg;462 match[1].mb_len= match[1].end-match[1].beg;
462 }463 }
463 }464 }
464465
=== modified file 'mystrings/ctype-mb.cc'
--- mystrings/ctype-mb.cc 2009-07-09 00:04:44 +0000
+++ mystrings/ctype-mb.cc 2009-10-02 12:21:10 +0000
@@ -348,12 +348,12 @@
348 if (nmatch)348 if (nmatch)
349 {349 {
350 match[0].beg= 0;350 match[0].beg= 0;
351 match[0].end= (size_t) (b-b0);351 match[0].end= static_cast<uint32_t>(b - b0);
352 match[0].mb_len= res;352 match[0].mb_len= res;
353 if (nmatch > 1)353 if (nmatch > 1)
354 {354 {
355 match[1].beg= match[0].end;355 match[1].beg= match[0].end;
356 match[1].end= match[0].end+s_length;356 match[1].end= static_cast<uint32_t>(match[0].end + s_length);
357 match[1].mb_len= 0; /* Not computed */357 match[1].mb_len= 0; /* Not computed */
358 }358 }
359 }359 }
@@ -582,8 +582,8 @@
582582
583 for (; pos < (const unsigned char*) key ; pos++)583 for (; pos < (const unsigned char*) key ; pos++)
584 {584 {
585 nr1[0]^=(ulong) ((((uint32_t) nr1[0] & 63)+nr2[0]) *585 nr1[0]^= ((nr1[0] & 63) + nr2[0]) * (static_cast<uint32_t>(*pos)) +
586 ((uint32_t)*pos)) + (nr1[0] << 8);586 (nr1[0] << 8);
587 nr2[0]+=3;587 nr2[0]+=3;
588 }588 }
589}589}
@@ -616,8 +616,10 @@
616 return;616 return;
617 }617 }
618618
619 buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (unsigned char*) buf,619 buflen= static_cast<char>(cs->cset->wc_mb(cs, cs->max_sort_char,
620 (unsigned char*) buf + sizeof(buf));620 reinterpret_cast<unsigned char*>(buf),
621 reinterpret_cast<unsigned char*>(buf)
622 + sizeof(buf)));
621623
622 assert(buflen > 0);624 assert(buflen > 0);
623 do625 do
@@ -1126,7 +1128,7 @@
1126 continue;1128 continue;
1127 }1129 }
1128 b+= mb_len;1130 b+= mb_len;
1129 pg= (wc >> 8) & 0xFF;1131 pg= static_cast<uint32_t>((wc >> 8) & 0xFF);
1130 clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page;1132 clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page;
1131 clen++;1133 clen++;
1132 }1134 }
11331135
=== modified file 'mystrings/ctype-simple.cc'
--- mystrings/ctype-simple.cc 2009-06-24 22:50:51 +0000
+++ mystrings/ctype-simple.cc 2009-10-02 12:21:10 +0000
@@ -84,7 +84,7 @@
84 unsigned char *d0= dst;84 unsigned char *d0= dst;
85 uint32_t frmlen;85 uint32_t frmlen;
86 if ((frmlen= min((uint32_t)dstlen, nweights)) > srclen)86 if ((frmlen= min((uint32_t)dstlen, nweights)) > srclen)
87 frmlen= srclen;87 frmlen= static_cast<uint32_t>(srclen);
88 if (dst != src)88 if (dst != src)
89 {89 {
90 const unsigned char *end;90 const unsigned char *end;
@@ -318,8 +318,9 @@
318318
319 for (; key < end ; key++)319 for (; key < end ; key++)
320 {320 {
321 nr1[0]^=(ulong) ((((uint32_t) nr1[0] & 63)+nr2[0]) *321 nr1[0]^= ((nr1[0] & 63) + nr2[0]) *
322 ((uint32_t) sort_order[(uint32_t) *key])) + (nr1[0] << 8);322 (static_cast<uint32_t>(sort_order[static_cast<uint32_t>(*key)])) +
323 (nr1[0] << 8);
323 nr2[0]+=3;324 nr2[0]+=3;
324 }325 }
325}326}
@@ -400,11 +401,11 @@
400 for (c = *s; s != e; c = *++s)401 for (c = *s; s != e; c = *++s)
401 {402 {
402 if (c>='0' && c<='9')403 if (c>='0' && c<='9')
403 c -= '0';404 c= static_cast<unsigned char>(c - '0');
404 else if (c>='A' && c<='Z')405 else if (c>='A' && c<='Z')
405 c = c - 'A' + 10;406 c= static_cast<unsigned char>(c - 'A' + 10);
406 else if (c>='a' && c<='z')407 else if (c>='a' && c<='z')
407 c = c - 'a' + 10;408 c= static_cast<unsigned char>(c - 'a' + 10);
408 else409 else
409 break;410 break;
410 if (c >= base)411 if (c >= base)
@@ -522,11 +523,11 @@
522 for (c = *s; s != e; c = *++s)523 for (c = *s; s != e; c = *++s)
523 {524 {
524 if (c>='0' && c<='9')525 if (c>='0' && c<='9')
525 c -= '0';526 c= static_cast<unsigned char>(c - '0');
526 else if (c>='A' && c<='Z')527 else if (c>='A' && c<='Z')
527 c = c - 'A' + 10;528 c= static_cast<unsigned char>(c - 'A' + 10);
528 else if (c>='a' && c<='z')529 else if (c>='a' && c<='z')
529 c = c - 'a' + 10;530 c= static_cast<unsigned char>(c - 'a' + 10);
530 else531 else
531 break;532 break;
532 if (c >= base)533 if (c >= base)
@@ -637,11 +638,11 @@
637 {638 {
638 register unsigned char c= *s;639 register unsigned char c= *s;
639 if (c>='0' && c<='9')640 if (c>='0' && c<='9')
640 c -= '0';641 c= static_cast<unsigned char>(c - '0');
641 else if (c>='A' && c<='Z')642 else if (c>='A' && c<='Z')
642 c = c - 'A' + 10;643 c= static_cast<unsigned char>(c - 'A' + 10);
643 else if (c>='a' && c<='z')644 else if (c>='a' && c<='z')
644 c = c - 'a' + 10;645 c= static_cast<unsigned char>(c - 'a' + 10);
645 else646 else
646 break;647 break;
647 if (c >= base)648 if (c >= base)
@@ -761,11 +762,11 @@
761 register unsigned char c= *s;762 register unsigned char c= *s;
762763
763 if (c>='0' && c<='9')764 if (c>='0' && c<='9')
764 c -= '0';765 c= static_cast<unsigned char>(c - '0');
765 else if (c>='A' && c<='Z')766 else if (c>='A' && c<='Z')
766 c = c - 'A' + 10;767 c= static_cast<unsigned char>(c - 'A' + 10);
767 else if (c>='a' && c<='z')768 else if (c>='a' && c<='z')
768 c = c - 'a' + 10;769 c= static_cast<unsigned char>(c - 'a' + 10);
769 else770 else
770 break;771 break;
771 if (c >= base)772 if (c >= base)
@@ -866,13 +867,14 @@
866 }867 }
867868
868 new_val = (long) (uval / 10);869 new_val = (long) (uval / 10);
869 *--p = '0'+ (char) (uval - (unsigned long) new_val * 10);870 *--p= static_cast<char>('0'+ static_cast<char>(uval -
871 static_cast<uint32_t>(new_val) * 10));
870 val = new_val;872 val = new_val;
871873
872 while (val != 0)874 while (val != 0)
873 {875 {
874 new_val=val/10;876 new_val=val/10;
875 *--p = '0' + (char) (val-new_val*10);877 *--p= static_cast<char>('0' + static_cast<char>(val-new_val*10));
876 val= new_val;878 val= new_val;
877 }879 }
878880
@@ -918,7 +920,7 @@
918 {920 {
919 uint64_t quo= uval/(uint32_t) 10;921 uint64_t quo= uval/(uint32_t) 10;
920 uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);922 uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);
921 *--p = '0' + rem;923 *--p= static_cast<char>('0' + rem);
922 uval= quo;924 uval= quo;
923 }925 }
924926
@@ -1215,13 +1217,14 @@
1215 if (nmatch > 0)1217 if (nmatch > 0)
1216 {1218 {
1217 match[0].beg= 0;1219 match[0].beg= 0;
1218 match[0].end= (size_t) (str- (const unsigned char*)b-1);1220 match[0].end= static_cast<uint32_t>(str -
1221 reinterpret_cast<const unsigned char*>(b) - 1);
1219 match[0].mb_len= match[0].end;1222 match[0].mb_len= match[0].end;
12201223
1221 if (nmatch > 1)1224 if (nmatch > 1)
1222 {1225 {
1223 match[1].beg= match[0].end;1226 match[1].beg= match[0].end;
1224 match[1].end= match[0].end+s_length;1227 match[1].end= match[0].end + static_cast<uint32_t>(s_length);
1225 match[1].mb_len= match[1].end-match[1].beg;1228 match[1].mb_len= match[1].end-match[1].beg;
1226 }1229 }
1227 }1230 }
@@ -1315,7 +1318,7 @@
1315 if (wc >= idx[i].uidx.from && wc <= idx[i].uidx.to && wc)1318 if (wc >= idx[i].uidx.from && wc <= idx[i].uidx.to && wc)
1316 {1319 {
1317 int ofs= wc - idx[i].uidx.from;1320 int ofs= wc - idx[i].uidx.from;
1318 idx[i].uidx.tab[ofs]= ch;1321 idx[i].uidx.tab[ofs]= static_cast<unsigned char>(ch);
1319 }1322 }
1320 }1323 }
1321 }1324 }
@@ -1344,7 +1347,7 @@
1344static void set_max_sort_char(CHARSET_INFO *cs)1347static void set_max_sort_char(CHARSET_INFO *cs)
1345{1348{
1346 unsigned char max_char;1349 unsigned char max_char;
1347 uint32_t i;1350 uint16_t i;
13481351
1349 if (!cs->sort_order)1352 if (!cs->sort_order)
1350 return;1353 return;
@@ -1529,7 +1532,7 @@
1529 }1532 }
1530 }1533 }
15311534
1532 digits= str - beg;1535 digits= static_cast<int>(str - beg);
15331536
1534 /* Continue to accumulate into uint64_t */1537 /* Continue to accumulate into uint64_t */
1535 for (dot= NULL, ull= ul; str < end; str++)1538 for (dot= NULL, ull= ul; str < end; str++)
@@ -1566,7 +1569,7 @@
1566 }1569 }
1567 else1570 else
1568 {1571 {
1569 shift= dot - str;1572 shift= static_cast<int>(dot - str);
1570 for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) {}1573 for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) {}
1571 }1574 }
1572 goto exp;1575 goto exp;
@@ -1590,7 +1593,7 @@
1590 /* Unknown character, exit the loop */1593 /* Unknown character, exit the loop */
1591 break;1594 break;
1592 }1595 }
1593 shift= dot ? dot - str : 0; /* Right shift */1596 shift= dot ? static_cast<int>(dot - str) : 0; /* Right shift */
1594 addon= 0;1597 addon= 0;
15951598
1596exp: /* [ E [ <sign> ] <unsigned integer> ] */1599exp: /* [ E [ <sign> ] <unsigned integer> ] */
@@ -1865,14 +1868,14 @@
1865 for (strend--; str <= strend;)1868 for (strend--; str <= strend;)
1866 {1869 {
1867 unsigned char tmp= *str;1870 unsigned char tmp= *str;
1868 *str++= ~*strend;1871 *str++= static_cast<unsigned char>(~*strend);
1869 *strend--= ~tmp;1872 *strend--= static_cast<unsigned char>(~tmp);
1870 }1873 }
1871 }1874 }
1872 else1875 else
1873 {1876 {
1874 for (; str < strend; str++)1877 for (; str < strend; str++)
1875 *str= ~*str;1878 *str= static_cast<unsigned char>(~*str);
1876 }1879 }
1877 }1880 }
1878 else if (flags & (MY_STRXFRM_REVERSE_LEVEL1 << level))1881 else if (flags & (MY_STRXFRM_REVERSE_LEVEL1 << level))
18791882
=== modified file 'mystrings/ctype-uca.cc'
--- mystrings/ctype-uca.cc 2009-07-09 00:46:46 +0000
+++ mystrings/ctype-uca.cc 2009-10-02 12:21:10 +0000
@@ -6828,8 +6828,8 @@
6828 }6828 }
6829 else6829 else
6830 {6830 {
6831 scanner->page= wc >> 8;6831 scanner->page= static_cast<int>(wc >> 8);
6832 scanner->code= wc & 0xFF;6832 scanner->code= static_cast<int>(wc & 0xFF);
6833 }6833 }
68346834
6835 if (scanner->contractions && !scanner->page &&6835 if (scanner->contractions && !scanner->page &&
@@ -6840,8 +6840,8 @@
6840 if (((mb_len= scanner->cs->cset->mb_wc(scanner->cs, &wc,6840 if (((mb_len= scanner->cs->cset->mb_wc(scanner->cs, &wc,
6841 scanner->sbeg,6841 scanner->sbeg,
6842 scanner->send)) >=0) &&6842 scanner->send)) >=0) &&
6843 (!(page1= (wc >> 8))) &&6843 (!(page1= static_cast<uint32_t>(wc >> 8))) &&
6844 ((code1= (wc & 0xFF)) > 0x40) &&6844 ((code1= static_cast<uint32_t>(wc & 0xFF)) > 0x40) &&
6845 (code1 < 0x80) &&6845 (code1 < 0x80) &&
6846 (cweight= scanner->contractions[(scanner->code-0x40)*0x40 + code1-0x40]))6846 (cweight= scanner->contractions[(scanner->code-0x40)*0x40 + code1-0x40]))
6847 {6847 {
@@ -6862,7 +6862,7 @@
6862implicit:6862implicit:
68636863
6864 scanner->code= (scanner->page << 8) + scanner->code;6864 scanner->code= (scanner->page << 8) + scanner->code;
6865 scanner->implicit[0]= (scanner->code & 0x7FFF) | 0x8000;6865 scanner->implicit[0]= static_cast<uint16_t>((scanner->code & 0x7FFF) | 0x8000);
6866 scanner->implicit[1]= 0;6866 scanner->implicit[1]= 0;
6867 scanner->wbeg= scanner->implicit;6867 scanner->wbeg= scanner->implicit;
68686868
@@ -7141,8 +7141,8 @@
7141 for (; dst < de && nweights &&7141 for (; dst < de && nweights &&
7142 (s_res= scanner_handler->next(&scanner)) > 0 ; nweights--)7142 (s_res= scanner_handler->next(&scanner)) > 0 ; nweights--)
7143 {7143 {
7144 *dst++= s_res >> 8;7144 *dst++= static_cast<unsigned char>(s_res >> 8);
7145 *dst++= s_res & 0xFF;7145 *dst++= static_cast<unsigned char>(s_res & 0xFF);
7146 }7146 }
71477147
7148 if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))7148 if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
@@ -7151,8 +7151,8 @@
7151 s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];7151 s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
7152 for (; space_count ; space_count--)7152 for (; space_count ; space_count--)
7153 {7153 {
7154 *dst++= s_res >> 8;7154 *dst++= static_cast<unsigned char>(s_res >> 8);
7155 *dst++= s_res & 0xFF;7155 *dst++= static_cast<unsigned char>(s_res & 0xFF);
7156 }7156 }
7157 }7157 }
7158 my_strxfrm_desc_and_reverse(d0, dst, flags, 0);7158 my_strxfrm_desc_and_reverse(d0, dst, flags, 0);
@@ -7769,7 +7769,8 @@
7769 if (!newweights[pagec])7769 if (!newweights[pagec])
7770 {7770 {
7771 /* Alloc new page and copy the default UCA weights */7771 /* Alloc new page and copy the default UCA weights */
7772 uint32_t size= 256*newlengths[pagec]*sizeof(uint16_t);7772 uint32_t size= static_cast<uint32_t>(256 * newlengths[pagec] *
7773 sizeof(uint16_t));
77737774
7774 if (!(newweights[pagec]= (uint16_t*) (*alloc)(size)))7775 if (!(newweights[pagec]= (uint16_t*) (*alloc)(size)))
7775 return 1;7776 return 1;
@@ -7793,7 +7794,8 @@
7793 defweights[pageb] + chb*deflengths[pageb],7794 defweights[pageb] + chb*deflengths[pageb],
7794 deflengths[pageb]*sizeof(uint16_t));7795 deflengths[pageb]*sizeof(uint16_t));
7795 /* Apply primary difference */7796 /* Apply primary difference */
7796 newweights[pagec][chc*newlengths[pagec]]+= rule[i].diff[0];7797 newweights[pagec][chc*newlengths[pagec]]= static_cast<uint16_t>(
7798 newweights[pagec][chc*newlengths[pagec]] + rule[i].diff[0]);
7797 }7799 }
77987800
7799 /* Copy non-overwritten pages from the default UCA weights */7801 /* Copy non-overwritten pages from the default UCA weights */
@@ -7844,7 +7846,8 @@
7844 offsc= (rule[i].curr[0]-0x40)*0x40+(rule[i].curr[1]-0x40);7846 offsc= (rule[i].curr[0]-0x40)*0x40+(rule[i].curr[1]-0x40);
78457847
7846 /* Copy base weight applying primary difference */7848 /* Copy base weight applying primary difference */
7847 cs->contractions[offsc]= offsb[0] + rule[i].diff[0];7849 cs->contractions[offsc]= static_cast<uint16_t>(
7850 offsb[0] + rule[i].diff[0]);
7848 /* Mark both letters as "is contraction part */7851 /* Mark both letters as "is contraction part */
7849 contraction_flags[rule[i].curr[0]]= 1;7852 contraction_flags[rule[i].curr[0]]= 1;
7850 contraction_flags[rule[i].curr[1]]= 1;7853 contraction_flags[rule[i].curr[1]]= 1;
78517854
=== modified file 'mysys/ptr_cmp.cc'
--- mysys/ptr_cmp.cc 2009-04-26 16:53:32 +0000
+++ mysys/ptr_cmp.cc 2009-10-02 12:21:10 +0000
@@ -53,7 +53,7 @@
5353
54static int ptr_compare(size_t *compare_length, unsigned char **a, unsigned char **b)54static int ptr_compare(size_t *compare_length, unsigned char **a, unsigned char **b)
55{55{
56 register int length= *compare_length;56 register int length= static_cast<int>(*compare_length);
57 register unsigned char *first,*last;57 register unsigned char *first,*last;
5858
59 first= *a; last= *b;59 first= *a; last= *b;
@@ -68,7 +68,7 @@
6868
69static int ptr_compare_0(size_t *compare_length,unsigned char **a, unsigned char **b)69static int ptr_compare_0(size_t *compare_length,unsigned char **a, unsigned char **b)
70{70{
71 register int length= *compare_length;71 register int length= static_cast<int>(*compare_length);
72 register unsigned char *first,*last;72 register unsigned char *first,*last;
7373
74 first= *a; last= *b;74 first= *a; last= *b;
@@ -89,7 +89,7 @@
8989
90static int ptr_compare_1(size_t *compare_length,unsigned char **a, unsigned char **b)90static int ptr_compare_1(size_t *compare_length,unsigned char **a, unsigned char **b)
91{91{
92 register int length= *compare_length-1;92 register int length= static_cast<int>(*compare_length-1);
93 register unsigned char *first,*last;93 register unsigned char *first,*last;
9494
95 first= *a+1; last= *b+1;95 first= *a+1; last= *b+1;
@@ -110,7 +110,7 @@
110110
111static int ptr_compare_2(size_t *compare_length,unsigned char **a, unsigned char **b)111static int ptr_compare_2(size_t *compare_length,unsigned char **a, unsigned char **b)
112{112{
113 register int length= *compare_length-2;113 register int length= static_cast<int>(*compare_length-2);
114 register unsigned char *first,*last;114 register unsigned char *first,*last;
115115
116 first= *a +2 ; last= *b +2;116 first= *a +2 ; last= *b +2;
@@ -132,7 +132,7 @@
132132
133static int ptr_compare_3(size_t *compare_length,unsigned char **a, unsigned char **b)133static int ptr_compare_3(size_t *compare_length,unsigned char **a, unsigned char **b)
134{134{
135 register int length= *compare_length-3;135 register int length= static_cast<int>(*compare_length-3);
136 register unsigned char *first,*last;136 register unsigned char *first,*last;
137137
138 first= *a +3 ; last= *b +3;138 first= *a +3 ; last= *b +3;
139139
=== modified file 'mysys/tree.cc'
--- mysys/tree.cc 2009-04-17 21:01:47 +0000
+++ mysys/tree.cc 2009-10-02 12:21:10 +0000
@@ -103,15 +103,18 @@
103 */103 */
104 tree->offset_to_key=sizeof(TREE_ELEMENT); /* Put key after element */104 tree->offset_to_key=sizeof(TREE_ELEMENT); /* Put key after element */
105 /* Fix allocation size so that we don't lose any memory */105 /* Fix allocation size so that we don't lose any memory */
106 default_alloc_size/=(sizeof(TREE_ELEMENT)+size);106 default_alloc_size= static_cast<uint32_t>(
107 default_alloc_size / (sizeof(TREE_ELEMENT)+size));
107 if (!default_alloc_size)108 if (!default_alloc_size)
108 default_alloc_size=1;109 default_alloc_size=1;
109 default_alloc_size*=(sizeof(TREE_ELEMENT)+size);110 default_alloc_size= static_cast<uint32_t>(
111 default_alloc_size * (sizeof(TREE_ELEMENT)+size));
110 }112 }
111 else113 else
112 {114 {
113 tree->offset_to_key=0; /* use key through pointer */115 tree->offset_to_key=0; /* use key through pointer */
114 tree->size_of_element+=sizeof(void*);116 tree->size_of_element= static_cast<uint32_t>(
117 tree->size_of_element + sizeof(void*));
115 }118 }
116 if (!(tree->with_delete=with_delete))119 if (!(tree->with_delete=with_delete))
117 {120 {
@@ -206,7 +209,8 @@
206 }209 }
207 if (element == &tree->null_element)210 if (element == &tree->null_element)
208 {211 {
209 uint32_t alloc_size=sizeof(TREE_ELEMENT)+key_size+tree->size_of_element;212 uint32_t alloc_size= static_cast<uint32_t>(
213 sizeof(TREE_ELEMENT) + key_size + tree->size_of_element);
210 tree->allocated+=alloc_size;214 tree->allocated+=alloc_size;
211215
212 if (tree->memory_limit && tree->elements_in_tree216 if (tree->memory_limit && tree->elements_in_tree
@@ -308,7 +312,8 @@
308 rb_delete_fixup(tree,parent);312 rb_delete_fixup(tree,parent);
309 if (tree->free)313 if (tree->free)
310 (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);314 (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
311 tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size;315 tree->allocated= static_cast<uint32_t>(
316 tree->allocated - sizeof(TREE_ELEMENT) + tree->size_of_element + key_size);
312 free((unsigned char*) element);317 free((unsigned char*) element);
313 tree->elements_in_tree--;318 tree->elements_in_tree--;
314 return 0;319 return 0;