Skip to content

Commit

Permalink
Merge pull request #1317 from JDimproved/fix-codes-that-are-reported-…
Browse files Browse the repository at this point in the history
…by-cppcheck-2-13-0

Fix codes that are reported by cppcheck 2.13.0
  • Loading branch information
ma8ma authored Jan 6, 2024
2 parents 02ae109 + 42be573 commit 3409bab
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/article/preference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void Preferences::slot_ok_clicked()
std::vector< char > vec_abone_res;
vec_abone_res.resize( DBTREE::article_number_load( get_url() ) + 1 );
std::list< std::string > list_res = MISC::get_lines( m_edit_res.get_text() );
for( std::string& num_str : list_res ) {
for( const std::string& num_str : list_res ) {

int number = atoi( num_str.c_str() );
if( number >= 1 ){
Expand Down
2 changes: 1 addition & 1 deletion src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ guint64 CACHE::get_dirsize( const std::string& dir )
DIR *dirp = opendir( to_locale_cstr( dir ) );
if( !dirp ) return 0;

struct dirent *direntry;
const struct dirent *direntry;
while( ( direntry = readdir( dirp ) ) ){
std::string filename = dir + direntry->d_name;
total_size += CACHE::get_filesize( filename );
Expand Down
2 changes: 1 addition & 1 deletion src/cssmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ size = atof( sizestr.c_str() ); \
type = SIZETYPE_PX; \
if( sizestr.find( "em" ) != std::string::npos ) type = SIZETYPE_EM; \
}while(0)
CSS_PROPERTY Css_Manager::create_property( std::map< std::string, std::string >& css_pair )
CSS_PROPERTY Css_Manager::create_property( const std::map<std::string, std::string>& css_pair )
{
CSS_PROPERTY css;
clear_property( &css );
Expand Down
2 changes: 1 addition & 1 deletion src/cssmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace CORE
int register_class( const std::string& classname );

// cssプロパティ関係
CSS_PROPERTY create_property( std::map< std::string, std::string >& css_pair );
CSS_PROPERTY create_property( const std::map<std::string, std::string>& css_pair );
void set_property( const std::string& classname, const CSS_PROPERTY& css );
void clear_property( CSS_PROPERTY* css );
void set_default_css();
Expand Down
4 changes: 2 additions & 2 deletions src/dbtree/nodetreebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3701,7 +3701,7 @@ bool NodeTreeBase::check_abone_chain( const int number )
// ひとつでもあぼーんされていないレスが見付かったらあぼーんしない
while( anc_from <= anc_to ){

NODE* tmphead = res_header( anc_from++ );
const NODE* tmphead = res_header( anc_from++ );
if( tmphead && ! tmphead->headinfo->abone ) return false;
}

Expand Down Expand Up @@ -3782,7 +3782,7 @@ void NodeTreeBase::check_reference( const int number )
#ifdef _DEBUG
std::cout << "from " << from << std::endl;
#endif
NODE* tmphead = res_header( from );
const NODE* tmphead = res_header( from );
if( tmphead && ! tmphead->headinfo->abone ){
m_refer_posts.insert( from );
}
Expand Down
2 changes: 1 addition & 1 deletion src/jdlib/jdiconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ std::string& Iconv::convert( char* str_in, std::size_t size_in, std::string& out
const char* buf_in_end = str_in + size_in;

char* buf_out_tmp = out_buf.data();
char* buf_out_end = out_buf.data() + out_buf.size();
const char* buf_out_end = out_buf.data() + out_buf.size();

const char* pre_check = nullptr; // 前回チェックしたUTF-8の先頭

Expand Down
4 changes: 2 additions & 2 deletions src/jdlib/miscutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1843,9 +1843,9 @@ std::string MISC::recover_path( const std::string& str )
return str;
}

std::vector< std::string > MISC::recover_path( std::vector< std::string > list_str )
std::vector<std::string> MISC::recover_path( const std::vector<std::string>& list_path )
{
return list_str;
return list_path;
}


Expand Down
2 changes: 1 addition & 1 deletion src/jdlib/miscutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace MISC

// pathセパレータを / に置き換える
std::string recover_path( const std::string& str );
std::vector< std::string > recover_path( std::vector< std::string > list_str );
std::vector<std::string> recover_path( const std::vector<std::string>& list_path );

// 文字列(utf-8)に全角英数字が含まれるか判定する
bool has_widechar( const char* str );
Expand Down
8 changes: 2 additions & 6 deletions src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,15 +1153,11 @@ void SESSION::set_col_diff( const int width ){ board_col_diff = width; }
// 現在開いているarticle の ARTICLE::DrawAreaBase
ARTICLE::DrawAreaBase* SESSION::get_base_drawarea()
{
ARTICLE::ArticleViewBase* base_view = nullptr;
base_view = dynamic_cast< ARTICLE::ArticleViewBase* >( ARTICLE::get_admin()->get_current_view() );
auto base_view = dynamic_cast<const ARTICLE::ArticleViewBase*>( ARTICLE::get_admin()->get_current_view() );

if( base_view == nullptr ) return nullptr;

ARTICLE::DrawAreaBase* base_drawarea = nullptr;
base_drawarea = base_view->drawarea();

return base_drawarea;
return base_view->drawarea();
}


Expand Down
2 changes: 1 addition & 1 deletion src/viewfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "message/messageview.h"

SKELETON::View* CORE::ViewFactory( int type, const std::string& url, VIEWFACTORY_ARGS view_args )
SKELETON::View* CORE::ViewFactory( int type, const std::string& url, const VIEWFACTORY_ARGS& view_args )
{
switch( type )
{
Expand Down
2 changes: 1 addition & 1 deletion src/viewfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace CORE
std::string arg4;
};

SKELETON::View* ViewFactory( int type, const std::string& url, VIEWFACTORY_ARGS view_args = VIEWFACTORY_ARGS() );
SKELETON::View* ViewFactory( int type, const std::string& url, const VIEWFACTORY_ARGS& view_args = {} );
}

#endif

0 comments on commit 3409bab

Please sign in to comment.