Skip to content

Commit 0c1fc55

Browse files
author
Your Name
committed
fix compilation warnings produced by -Wold-style-cast
1 parent e6caeae commit 0c1fc55

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

xmltest.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ int main( int argc, const char ** argv )
324324

325325
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
326326
if ( !errorID ) {
327-
printf( "Load time=%u\n", (unsigned)(loadTime - startTime) );
328-
printf( "Delete time=%u\n", (unsigned)(deleteTime - loadTime) );
329-
printf( "Total time=%u\n", (unsigned)(deleteTime - startTime) );
327+
printf( "Load time=%u\n", static_cast<unsigned>(loadTime - startTime) );
328+
printf( "Delete time=%u\n", static_cast<unsigned>(deleteTime - loadTime) );
329+
printf( "Total time=%u\n", static_cast<unsigned>(deleteTime - startTime) );
330330
}
331331
exit(0);
332332
}
@@ -595,8 +595,8 @@ int main( int argc, const char ** argv )
595595

596596
result = ele->QueryDoubleAttribute( "attr0", &dVal );
597597
XMLTest( "Query attribute: int as double", XML_SUCCESS, result);
598-
XMLTest( "Query attribute: int as double", 1, (int)dVal );
599-
XMLTest( "Query attribute: int as double", 1, (int)ele->DoubleAttribute("attr0"));
598+
XMLTest( "Query attribute: int as double", 1, static_cast<int>(dVal) );
599+
XMLTest( "Query attribute: int as double", 1, static_cast<int>(ele->DoubleAttribute("attr0")));
600600

601601
result = ele->QueryDoubleAttribute( "attr1", &dVal );
602602
XMLTest( "Query attribute: double as double", XML_SUCCESS, result);
@@ -648,17 +648,17 @@ int main( int argc, const char ** argv )
648648

649649
{
650650
XMLError queryResult = ele->QueryAttribute( "int", &iVal2 );
651-
XMLTest( "Query int attribute generic", (int)XML_SUCCESS, queryResult);
651+
XMLTest( "Query int attribute generic", static_cast<int>(XML_SUCCESS), queryResult);
652652
}
653653
{
654654
XMLError queryResult = ele->QueryAttribute( "double", &dVal2 );
655-
XMLTest( "Query double attribute generic", (int)XML_SUCCESS, queryResult);
655+
XMLTest( "Query double attribute generic", static_cast<int>(XML_SUCCESS), queryResult);
656656
}
657657

658658
XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) );
659659
XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
660660
XMLTest( "Attribute round trip. int.", 1, iVal );
661-
XMLTest( "Attribute round trip. double.", -1, (int)dVal );
661+
XMLTest( "Attribute round trip. double.", -1, static_cast<int>(dVal) );
662662
XMLTest( "Alternate query", true, iVal == iVal2 );
663663
XMLTest( "Alternate query", true, dVal == dVal2 );
664664
XMLTest( "Alternate query", true, iVal == ele->IntAttribute("int") );
@@ -824,7 +824,7 @@ int main( int argc, const char ** argv )
824824
{
825825
int v = 0;
826826
XMLError queryResult = element->QueryAttribute("attrib", &v);
827-
XMLTest("Attribute: int", (int)XML_SUCCESS, queryResult, true);
827+
XMLTest("Attribute: int", static_cast<int>(XML_SUCCESS), queryResult, true);
828828
XMLTest("Attribute: int", -100, v, true);
829829
}
830830
XMLTest("Attribute: int", -100, element->IntAttribute("attrib"), true);
@@ -840,7 +840,7 @@ int main( int argc, const char ** argv )
840840
{
841841
unsigned v = 0;
842842
XMLError queryResult = element->QueryAttribute("attrib", &v);
843-
XMLTest("Attribute: unsigned", (int)XML_SUCCESS, queryResult, true);
843+
XMLTest("Attribute: unsigned", static_cast<int>(XML_SUCCESS), queryResult, true);
844844
XMLTest("Attribute: unsigned", unsigned(100), v, true);
845845
}
846846
{
@@ -864,7 +864,7 @@ int main( int argc, const char ** argv )
864864
{
865865
int64_t v = 0;
866866
XMLError queryResult = element->QueryAttribute("attrib", &v);
867-
XMLTest("Attribute: int64_t", (int)XML_SUCCESS, queryResult, true);
867+
XMLTest("Attribute: int64_t", static_cast<int>(XML_SUCCESS), queryResult, true);
868868
XMLTest("Attribute: int64_t", BIG, v, true);
869869
}
870870
XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);
@@ -880,7 +880,7 @@ int main( int argc, const char ** argv )
880880
{
881881
uint64_t v = 0;
882882
XMLError queryResult = element->QueryAttribute("attrib", &v);
883-
XMLTest("Attribute: uint64_t", (int)XML_SUCCESS, queryResult, true);
883+
XMLTest("Attribute: uint64_t", static_cast<int>(XML_SUCCESS), queryResult, true);
884884
XMLTest("Attribute: uint64_t", BIG_POS, v, true);
885885
}
886886
XMLTest("Attribute: uint64_t", BIG_POS, element->Unsigned64Attribute("attrib"), true);
@@ -896,7 +896,7 @@ int main( int argc, const char ** argv )
896896
{
897897
bool v = false;
898898
XMLError queryResult = element->QueryAttribute("attrib", &v);
899-
XMLTest("Attribute: bool", (int)XML_SUCCESS, queryResult, true);
899+
XMLTest("Attribute: bool", static_cast<int>(XML_SUCCESS), queryResult, true);
900900
XMLTest("Attribute: bool", true, v, true);
901901
}
902902
XMLTest("Attribute: bool", true, element->BoolAttribute("attrib"), true);
@@ -924,7 +924,7 @@ int main( int argc, const char ** argv )
924924
{
925925
double v = 0;
926926
XMLError queryResult = element->QueryAttribute("attrib", &v);
927-
XMLTest("Attribute: bool", (int)XML_SUCCESS, queryResult, true);
927+
XMLTest("Attribute: bool", static_cast<int>(XML_SUCCESS), queryResult, true);
928928
XMLTest("Attribute: double", 100.0, v, true);
929929
}
930930
XMLTest("Attribute: double", 100.0, element->DoubleAttribute("attrib"), true);
@@ -940,7 +940,7 @@ int main( int argc, const char ** argv )
940940
{
941941
float v = 0;
942942
XMLError queryResult = element->QueryAttribute("attrib", &v);
943-
XMLTest("Attribute: float", (int)XML_SUCCESS, queryResult, true);
943+
XMLTest("Attribute: float", static_cast<int>(XML_SUCCESS), queryResult, true);
944944
XMLTest("Attribute: float", 100.0f, v, true);
945945
}
946946
XMLTest("Attribute: float", 100.0f, element->FloatAttribute("attrib"), true);
@@ -2779,9 +2779,9 @@ int main( int argc, const char ** argv )
27792779
#endif
27802780

27812781
#if defined( _MSC_VER )
2782-
const double duration = 1000.0 * (double)(end - start) / ((double)freq * (double)COUNT);
2782+
const double duration = 1000.0 * static_cast<double>(end - start) / (static_cast<double>(freq) * static_cast<double>(COUNT));
27832783
#else
2784-
const double duration = (double)(cend - cstart) / (double)COUNT;
2784+
const double duration = static_cast<double>(cend - cstart) / static_cast<double>(COUNT);
27852785
#endif
27862786
printf("\nParsing dream.xml (%s): %.3f milli-seconds\n", note, duration);
27872787
}

0 commit comments

Comments
 (0)