← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Fix warnings.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/155244

Fix warnings.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/155244
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/util/base64_util.cpp'
--- src/util/base64_util.cpp	2013-03-19 06:12:47 +0000
+++ src/util/base64_util.cpp	2013-03-25 14:51:30 +0000
@@ -207,14 +207,14 @@
 
 size_type decode( char const *from, size_type from_len, std::vector<char> *to,
                   int options ) {
-  size_type total_decoded = 0;
+  size_type decoded = 0;
   if ( from_len ) {
     std::vector<char>::size_type const orig_size = to->size();
     to->resize( orig_size + decoded_size( from_len ) );
-    total_decoded = decode( from, from_len, &(*to)[ orig_size ], options );
-    to->resize( orig_size + total_decoded );
+    decoded = decode( from, from_len, &(*to)[ orig_size ], options );
+    to->resize( orig_size + decoded );
   }
-  return total_decoded;
+  return decoded;
 }
 
 size_type decode( istream &from, ostream &to, int options ) {
@@ -241,7 +241,6 @@
 
 size_type decode( istream &from, vector<char> *to, int options ) {
   bool const ignore_ws = !!(options & dopt_ignore_ws);
-  vector<char>::size_type const orig_size = to->size();
   size_type total_decoded = 0;
   while ( !from.eof() ) {
     char from_buf[ 1024 * 4 ];
@@ -253,13 +252,15 @@
       gcount = from.gcount();
     }
     if ( gcount ) {
-      to->resize( to->size() + decoded_size( gcount ) );
-      total_decoded +=
+      vector<char>::size_type const orig_size = to->size();
+      to->resize( orig_size + decoded_size( gcount ) );
+      size_type const decoded =
         decode( from_buf, gcount, &(*to)[ total_decoded ], options );
+      to->resize( orig_size + decoded );
+      total_decoded += decoded;
     } else
       break;
   }
-  to->resize( orig_size + total_decoded );
   return total_decoded;
 }
 

=== modified file 'src/util/base64_util.h'
--- src/util/base64_util.h	2013-03-19 14:33:26 +0000
+++ src/util/base64_util.h	2013-03-25 14:51:30 +0000
@@ -134,14 +134,14 @@
 template<class ToStringType>
 size_type decode( char const *from, size_type from_len, ToStringType *to,
                   int options = dopt_none ) {
-  size_type total_decoded = 0;
+  size_type decoded = 0;
   if ( from_len ) {
     typename ToStringType::size_type const orig_size = to->size();
     to->resize( orig_size + decoded_size( from_len ) );
-    total_decoded = decode( from, from_len, &to->at( orig_size ), options );
-    to->resize( orig_size + total_decoded );
+    decoded = decode( from, from_len, &to->at( orig_size ), options );
+    to->resize( orig_size + decoded );
   }
-  return total_decoded;
+  return decoded;
 }
 
 /**
@@ -279,14 +279,14 @@
  */
 template<class ToStringType>
 size_type encode( char const *from, size_type from_len, ToStringType *to ) {
-  size_type total_encoded = 0;
+  size_type encoded = 0;
   if ( from_len ) {
     typename ToStringType::size_type const orig_size = to->size();
     to->resize( orig_size + encoded_size( from_len ) );
-    total_encoded = encode( from, from_len, &to->at( orig_size ) );
-    to->resize( orig_size + total_encoded );
+    encoded = encode( from, from_len, &to->at( orig_size ) );
+    to->resize( orig_size + encoded );
   }
-  return total_encoded;
+  return encoded;
 }
 
 /**

=== modified file 'src/util/hexbinary_util.cpp'
--- src/util/hexbinary_util.cpp	2013-03-19 14:27:55 +0000
+++ src/util/hexbinary_util.cpp	2013-03-25 14:51:30 +0000
@@ -110,14 +110,14 @@
     from = ascii::trim_whitespace( from, &from_len );
   if ( from_len % 2 )
     throw invalid_argument( "HexBinary length is not a multiple of 2" );
-  size_type total_decoded = 0;
+  size_type decoded = 0;
   if ( from_len ) {
     std::vector<char>::size_type const orig_size = to->size();
     to->resize( orig_size + decoded_size( from_len ) );
-    total_decoded = decode( from, from_len, &(*to)[ orig_size ], options );
-    to->resize( orig_size + total_decoded );
+    decoded = decode( from, from_len, &(*to)[ orig_size ], options );
+    to->resize( orig_size + decoded );
   }
-  return total_decoded;
+  return decoded;
 }
 
 size_type decode( istream &from, ostream &to, int options ) {
@@ -144,7 +144,6 @@
 
 size_type decode( istream &from, vector<char> *to, int options ) {
   bool const ignore_ws = !!(options & dopt_ignore_ws);
-  vector<char>::size_type const orig_size = to->size();
   size_type total_decoded = 0;
   while ( !from.eof() ) {
     char from_buf[ 1024 * 4 ];
@@ -156,9 +155,12 @@
       gcount = from.gcount();
     }
     if ( gcount ) {
-      to->resize( to->size() + decoded_size( gcount ) );
-      total_decoded +=
+      vector<char>::size_type const orig_size = to->size();
+      to->resize( orig_size + decoded_size( gcount ) );
+      size_type const decoded =
         decode( from_buf, gcount, &(*to)[ total_decoded ], options );
+      to->resize( orig_size + decoded );
+      total_decoded += decoded;
     } else
       break;
   }
@@ -186,7 +188,6 @@
     std::vector<char>::size_type const orig_size = to->size();
     to->resize( orig_size + encoded_size( from_len ) );
     encoded = encode( from, from_len, &(*to)[ orig_size ] );
-    to->resize( orig_size + encoded );
   }
   return encoded;
 }
@@ -207,7 +208,6 @@
 }
 
 size_type encode( istream &from, vector<char> *to ) {
-  vector<char>::size_type const orig_size = to->size();
   size_type total_encoded = 0;
   while ( !from.eof() ) {
     char from_buf[ 1024 ];

=== modified file 'src/util/hexbinary_util.h'
--- src/util/hexbinary_util.h	2013-03-19 14:33:26 +0000
+++ src/util/hexbinary_util.h	2013-03-25 14:51:30 +0000
@@ -130,14 +130,14 @@
 template<class ToStringType>
 size_type decode( char const *from, size_type from_len, ToStringType *to,
                   int options = dopt_none ) {
-  size_type total_decoded = 0;
+  size_type decoded = 0;
   if ( from_len ) {
     typename ToStringType::size_type const orig_size = to->size();
     to->resize( orig_size + decoded_size( from_len ) );
-    total_decoded = decode( from, from_len, &to->at( orig_size ), options );
-    to->resize( orig_size + total_decoded );
+    decoded = decode( from, from_len, &to->at( orig_size ), options );
+    to->resize( orig_size + decoded );
   }
-  return total_decoded;
+  return decoded;
 }
 
 /**
@@ -269,14 +269,13 @@
  */
 template<class ToStringType>
 size_type encode( char const *from, size_type from_len, ToStringType *to ) {
-  size_type total_encoded = 0;
+  size_type encoded = 0;
   if ( from_len ) {
     typename ToStringType::size_type const orig_size = to->size();
     to->resize( orig_size + encoded_size( from_len ) );
-    total_encoded = encode( from, from_len, &to->at( orig_size ) );
-    to->resize( orig_size + total_encoded );
+    encoded = encode( from, from_len, &to->at( orig_size ) );
   }
-  return total_encoded;
+  return encoded;
 }
 
 /**

=== modified file 'src/util/stream_util.cpp'
--- src/util/stream_util.cpp	2013-03-21 00:54:36 +0000
+++ src/util/stream_util.cpp	2013-03-25 14:51:30 +0000
@@ -79,23 +79,23 @@
     char const *numeral[2];
   };
   static roman_data const data[] = {
-    1000, {  "m",  "M" },
-     900, { "cm", "CM" },
-     500, {  "d",  "D" },
-     400, { "cd", "CD" },
-     100, {  "c",  "C" },
-      90, { "xc", "XC" },
-      50, {  "l",  "L" },
-      40, { "xl", "XL" },
-      10, {  "x",  "X" },
-       9, { "ix", "IX" },
-       5, {  "v",  "V" },
-       4, { "iv", "IV" },
-       1, {  "i",  "I" },
-       0, {    0,    0 }
+    { 1000, {  "m",  "M" } },
+    {  900, { "cm", "CM" } },
+    {  500, {  "d",  "D" } },
+    {  400, { "cd", "CD" } },
+    {  100, {  "c",  "C" } },
+    {   90, { "xc", "XC" } },
+    {   50, {  "l",  "L" } },
+    {   40, { "xl", "XL" } },
+    {   10, {  "x",  "X" } },
+    {    9, { "ix", "IX" } },
+    {    5, {  "v",  "V" } },
+    {    4, { "iv", "IV" } },
+    {    1, {  "i",  "I" } },
+    {    0, {    0,    0 } }
   };
   bool const uc = !!(o.flags() & ios::uppercase);
-  for ( roman_data const *r = data; r->value > 0; ++r )
+  for ( roman_data const *r = data; r->value; ++r )
     for ( ; n >= r->value; n -= r->value )
       o << r->numeral[ uc ];
   return o;

=== modified file 'src/util/time_util.cpp'
--- src/util/time_util.cpp	2013-03-21 15:42:04 +0000
+++ src/util/time_util.cpp	2013-03-25 14:51:30 +0000
@@ -143,7 +143,7 @@
 int convert_wday_from( unsigned wday, type from ) {
   switch ( from ) {
     case AD : return static_cast<int>( wday );
-    case ISO: return wday == iso8601::sun ? time::sun : wday;
+    case ISO: return wday == (unsigned)iso8601::sun ? time::sun : wday;
     default : return -1;
   }
 }
@@ -151,7 +151,7 @@
 int convert_wday_to( unsigned wday, type to ) {
   switch ( to ) {
     case AD : return static_cast<int>( wday );
-    case ISO: return wday == time::sun ? iso8601::sun : wday;
+    case ISO: return wday == (unsigned)time::sun ? iso8601::sun : wday;
     default : return -1;
   }
 }
@@ -175,7 +175,7 @@
 
 bool calc_mday_mon( unsigned yday, unsigned *mday, unsigned *mon,
                     unsigned year ) {
-  assert( yday < days_in_year( year ) );
+  assert( (int)yday < days_in_year( year ) );
 
   unsigned const *const ym = yday_mon[ is_leap_year( year ) ];
   for ( unsigned m = 1; m <= 12; ++m ) 
@@ -236,7 +236,7 @@
  */
 int calc_wday( unsigned mday, unsigned mon, unsigned year ) {
   assert( mday >= 1 );
-  assert( mday <= days_in_month( mon, year ) );
+  assert( (int)mday <= days_in_month( mon, year ) );
   assert( mon < 12 );
 
   ++mon; // Tondering's algorithm assumes month value in range 1-12.
@@ -248,7 +248,7 @@
 
 int calc_yday( unsigned mday, unsigned mon, unsigned year ) {
   assert( mday >= 1 );
-  assert( mday <= days_in_month( mon, year ) );
+  assert( (int)mday <= days_in_month( mon, year ) );
   return (int)yday_mon[ is_leap_year( year ) ][ mon ] + mday - 1;
 }
 


Follow ups