Skip to content

Commit f217547

Browse files
authored
Merge pull request #253 from thomas-brunel/fix/wexitstatus-rvalue
[examples-EventsHandler] Clang - Fix WEXITSTATUS usage by passing a variable
2 parents 76626e4 + 8f44b14 commit f217547

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

examples/common/DefaultCentralSystemEventsHandler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::signCertifica
423423
std::stringstream sign_cert_cmd_line;
424424
sign_cert_cmd_line << "openssl x509 -req -sha256 -days 3650 -in " << csr_filename << " -CA " << ca_cert_path << " -CAkey "
425425
<< ca_cert_key_path << " -CAcreateserial -out " << certificate_filename;
426-
int err = WEXITSTATUS(system(sign_cert_cmd_line.str().c_str()));
426+
int system_ret = system(sign_cert_cmd_line.str().c_str());
427+
int err = WEXITSTATUS(system_ret);
427428
cout << "Command line : " << sign_cert_cmd_line.str() << " => " << err << endl;
428429

429430
// Check if the certificate has been generated
@@ -433,7 +434,8 @@ bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::signCertifica
433434
std::string bundle_filename = certificate_filename + ".bundle";
434435
std::stringstream generate_bundle_cmd_line;
435436
generate_bundle_cmd_line << "cat " << certificate_filename << " " << ca_cert_path << " > " << bundle_filename;
436-
err = WEXITSTATUS(system(generate_bundle_cmd_line.str().c_str()));
437+
int bundle_ret = system(generate_bundle_cmd_line.str().c_str());
438+
err = WEXITSTATUS(bundle_ret);
437439
cout << "Command line : " << generate_bundle_cmd_line.str() << " => " << err << endl;
438440
if (std::filesystem::exists(bundle_filename))
439441
{
@@ -611,7 +613,8 @@ bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118SignC
611613
std::stringstream sign_cert_cmd_line;
612614
sign_cert_cmd_line << "openssl x509 -req -sha256 -days 3650 -in " << csr_filename << " -CA " << ca_cert_path << " -CAkey "
613615
<< ca_cert_key_path << " -CAcreateserial -out " << certificate_filename;
614-
int err = WEXITSTATUS(system(sign_cert_cmd_line.str().c_str()));
616+
int system_ret = system(sign_cert_cmd_line.str().c_str());
617+
int err = WEXITSTATUS(system_ret);
615618
cout << "Command line : " << sign_cert_cmd_line.str() << " => " << err << endl;
616619

617620
// Check if the certificate has been generated
@@ -621,7 +624,8 @@ bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118SignC
621624
std::string bundle_filename = certificate_filename + ".bundle";
622625
std::stringstream generate_bundle_cmd_line;
623626
generate_bundle_cmd_line << "cat " << certificate_filename << " " << ca_cert_path << " > " << bundle_filename;
624-
err = WEXITSTATUS(system(generate_bundle_cmd_line.str().c_str()));
627+
int bundle_ret = system(generate_bundle_cmd_line.str().c_str());
628+
err = WEXITSTATUS(bundle_ret);
625629
cout << "Command line : " << generate_bundle_cmd_line.str() << " => " << err << endl;
626630
if (std::filesystem::exists(bundle_filename))
627631
{

examples/common/DefaultChargePointEventsHandler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ std::string DefaultChargePointEventsHandler::getDiagnostics(const ocpp::types::O
239239

240240
std::stringstream ss;
241241
ss << "zip " << diag_file << " " << m_config.stackConfig().databasePath();
242-
int err = WEXITSTATUS(system(ss.str().c_str()));
242+
int sys_ret = system(ss.str().c_str());
243+
int err = WEXITSTATUS(sys_ret);
243244
cout << "Command line : " << ss.str() << " => " << err << endl;
244245

245246
return diag_file;
@@ -295,7 +296,8 @@ bool DefaultChargePointEventsHandler::uploadFile(const std::string& file, const
295296
{
296297
std::stringstream ss;
297298
ss << "curl --silent " << params << " -T " << file << " " << connection_url;
298-
int err = WEXITSTATUS(system(ss.str().c_str()));
299+
int sys_ret = system(ss.str().c_str());
300+
int err = WEXITSTATUS(sys_ret);
299301
cout << "Command line : " << ss.str() << endl;
300302
ret = (err == 0);
301303
}
@@ -339,7 +341,8 @@ bool DefaultChargePointEventsHandler::downloadFile(const std::string& url, const
339341
{
340342
std::stringstream ss;
341343
ss << "curl --silent " << params << " -o " << file << " " << connection_url;
342-
int err = WEXITSTATUS(system(ss.str().c_str()));
344+
int sys_ret = system(ss.str().c_str());
345+
int err = WEXITSTATUS(sys_ret);
343346
cout << "Command line : " << ss.str() << endl;
344347
ret = (err == 0);
345348
}
@@ -627,7 +630,8 @@ std::string DefaultChargePointEventsHandler::getLog(ocpp::types::LogEnumType
627630

628631
std::stringstream ss;
629632
ss << "zip " << log_file << " " << m_config.stackConfig().databasePath();
630-
int err = WEXITSTATUS(system(ss.str().c_str()));
633+
int sys_ret = system(ss.str().c_str());
634+
int err = WEXITSTATUS(sys_ret);
631635
cout << "Command line : " << ss.str() << " => " << err << endl;
632636
}
633637

0 commit comments

Comments
 (0)