Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOMonitor: Refactor parameter type of member function #937

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/iomonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,15 @@ void IOMonitor::delete_fifo()
//
// 戻り値: 全て書き込まれたか否か
/*-------------------------------------------------------------------*/
bool IOMonitor::send_command( const char* command )
bool IOMonitor::send_command( const std::string& command )
{
if( ! command ) return false;

const size_t command_length = strlen( command );

// 異常に長かったら書き込まない
if( command_length > COMMAND_MAX_LENGTH ) return false;
if( command.size() > COMMAND_MAX_LENGTH ) return false;

g_assert( m_fifo_fd >= 0 );

int status = -1;
status = write( m_fifo_fd, command, command_length );

return ( (size_t)status == command_length );
const ssize_t status = write( m_fifo_fd, command.c_str(), command.size() );
return static_cast<std::size_t>( status ) == command.size();
}


Expand Down
2 changes: 1 addition & 1 deletion src/iomonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace CORE
bool is_main_process() const noexcept { return m_main_process; }

// FIFOに書き込み
bool send_command( const char* command );
bool send_command( const std::string& command );
};
}
#endif
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ int main( int argc, char **argv )
if( ! url_real.empty() ) url = url_real;

// FIFOに書き込む
iomonitor.send_command( url.c_str() );
iomonitor.send_command( url );

// マルチモードでなく、メインプロセスでもない場合は終了
if( ! multi_mode && ! iomonitor.is_main_process() ) return 0;
Expand Down