Skip to content

Commit ba085cf

Browse files
authored
Merge pull request #77 from benvenutti/feature/fix-coverity-scan-issues
Feature/fix coverity scan issues
2 parents e185dca + 84d74a3 commit ba085cf

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

app-command-line/src/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ struct RequestVisitor
1212
{
1313
bool operator()( const Utilities::CommandLineParser::Config& config ) const
1414
{
15-
const Hasm::AssemblerEngine assembler{ []( const auto& log ) { std::cout << log << std::endl; } };
16-
17-
return assembler.run( { config.inputFile, config.exportSymbols } );
15+
try
16+
{
17+
const Hasm::AssemblerEngine assembler{ []( const auto& log ) { std::cout << log << std::endl; } };
18+
19+
return assembler.run( { config.inputFile, config.exportSymbols } );
20+
}
21+
catch ( const std::exception& exception )
22+
{
23+
std::cerr << exception.what() << std::endl;
24+
25+
return false;
26+
}
1827
}
1928

2029
bool operator()( const Utilities::CommandLineParser::RequestToPrintHelp& help ) const

hasm/include/hasm/Assembler.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class Assembler
3434
Hack::word computeValue( const std::string& symbol );
3535
bool isValidValue( Hack::word value ) const;
3636
void output( Hack::word word );
37-
void displayInvalidACommandMessage();
3837

3938
std::ostream& m_out;
4039
Parser m_parser;

hasm/src/hasm/Assembler.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,17 @@ bool Assembler::assembleAddressingInstruction()
9292
{
9393
const auto symbol = m_parser.symbol();
9494
const auto value = computeValue( symbol );
95-
const auto isValid = isValidValue( value );
9695

97-
if ( isValid )
96+
if ( isValidValue( value ) )
9897
{
9998
output( value );
100-
}
101-
else
102-
{
103-
displayInvalidACommandMessage();
104-
}
10599

106-
return isValid;
107-
}
100+
return true;
101+
}
108102

109-
void Assembler::displayInvalidACommandMessage()
110-
{
111-
const auto cmd = m_parser.getInstruction();
112-
const auto lineNumber = m_parser.getCurrentLineNumber();
103+
m_logger( ErrorMessage::invalidLoadValue( m_parser.getInstruction(), m_parser.getCurrentLineNumber() ) );
113104

114-
m_logger( ErrorMessage::invalidLoadValue( cmd, lineNumber ) );
105+
return false;
115106
}
116107

117108
bool Assembler::assembleComputationInstruction()

0 commit comments

Comments
 (0)