Adding -Wextra and fixing warnings from it

This commit is contained in:
Strahinja Val Markovic 2012-05-06 00:01:32 -07:00
parent 7cf580a447
commit 5f5b9bd7b4
6 changed files with 20 additions and 10 deletions

View File

@ -86,8 +86,7 @@ endif()
if( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG ) if( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG )
# We want all warnings, and warnings should be treated as errors # We want all warnings, and warnings should be treated as errors
# TODO: -Wextra? add_definitions( -Wall -Wextra -Werror )
add_definitions( -Wall -Werror )
endif() endif()
add_subdirectory( tests ) add_subdirectory( tests )

View File

@ -33,7 +33,7 @@ std::string GetWordBoundaryChars( const std::string &text )
{ {
std::string result; std::string result;
for ( int i = 0; i < text.size(); ++i ) for ( uint i = 0; i < text.size(); ++i )
{ {
if ( i == 0 || if ( i == 0 ||
IsUppercase( text[ i ] ) || IsUppercase( text[ i ] ) ||

View File

@ -16,6 +16,7 @@
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. // along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
#include "LetterHash.h" #include "LetterHash.h"
#include "standard.h"
namespace YouCompleteMe namespace YouCompleteMe
{ {
@ -45,7 +46,7 @@ LetterHash::LetterHash()
{ {
letters_.resize( kNumLetters ); letters_.resize( kNumLetters );
for ( int i = 0; i < letters_.size(); ++i ) for ( uint i = 0; i < letters_.size(); ++i )
{ {
letters_[ i ] = NULL; letters_[ i ] = NULL;
} }
@ -54,7 +55,7 @@ LetterHash::LetterHash()
LetterHash::~LetterHash() LetterHash::~LetterHash()
{ {
for ( int i = 0; i < letters_.size(); ++i ) for ( uint i = 0; i < letters_.size(); ++i )
{ {
delete letters_[ i ]; delete letters_[ i ];
} }

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. // along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
#include "standard.h"
#include "LetterNode.h" #include "LetterNode.h"
#include "standard.h"
namespace YouCompleteMe namespace YouCompleteMe
@ -36,7 +36,7 @@ LetterNode::LetterNode( const std::string &text )
letternode_per_text_index_.resize( text.size() ); letternode_per_text_index_.resize( text.size() );
for (int i = 0; i < text.size(); ++i) for ( uint i = 0; i < text.size(); ++i)
{ {
char letter = text[ i ]; char letter = text[ i ];
LetterNode *node = new LetterNode( letter ); LetterNode *node = new LetterNode( letter );
@ -44,7 +44,8 @@ LetterNode::LetterNode( const std::string &text )
letternode_per_text_index_[ i ] = boost::shared_ptr< LetterNode >( node ); letternode_per_text_index_[ i ] = boost::shared_ptr< LetterNode >( node );
} }
for ( int i = letternode_per_text_index_.size() - 1; i >= 0; --i ) for ( int i = static_cast< int >( letternode_per_text_index_.size() ) - 1;
i >= 0; --i )
{ {
LetterNode *node_to_add = letternode_per_text_index_[ i ].get(); LetterNode *node_to_add = letternode_per_text_index_[ i ].get();

View File

@ -16,6 +16,7 @@
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. // along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
#include "Result.h" #include "Result.h"
#include "standard.h"
#include "Utils.h" #include "Utils.h"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -30,8 +31,8 @@ namespace
int NumWordBoundaryCharMatches( const std::string &query, int NumWordBoundaryCharMatches( const std::string &query,
const std::string &word_boundary_chars ) const std::string &word_boundary_chars )
{ {
int i = 0; uint i = 0;
int j = 0; uint j = 0;
while ( j < query.size() && i < word_boundary_chars.size() ) while ( j < query.size() && i < word_boundary_chars.size() )
{ {
if ( toupper( query[ j ] ) == toupper( word_boundary_chars[ i ] ) ) if ( toupper( query[ j ] ) == toupper( word_boundary_chars[ i ] ) )

View File

@ -20,3 +20,11 @@
// We're most definitely not going to use // We're most definitely not going to use
// it as BOOST_FOREACH. // it as BOOST_FOREACH.
#define foreach BOOST_FOREACH #define foreach BOOST_FOREACH
namespace YouCompleteMe
{
typedef unsigned int uint;
} // namespace YouCompleteMe