Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/27627 )
Change subject: util: Standardize console output in the m5 writefile
command.
......................................................................
util: Standardize console output in the m5 writefile command.
When the command reports an error, it should then exit(2) and not just
return as if everything worked. When printing the number of bytes
written or the file being opened, it should write this non-error message
to cout, and not cerr.
Also used proper capitalization and punctuation in a couple messages.
Change-Id: I2c0d6592357965ed2eee8f090c8b3d530b354b9f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27627
Reviewed-by: Jason Lowe-Power <[email protected]>
Reviewed-by: Pouya Fotouhi <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M util/m5/src/command/writefile.cc
1 file changed, 12 insertions(+), 6 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
Pouya Fotouhi: Looks good to me, approved
kokoro: Regressions pass
diff --git a/util/m5/src/command/writefile.cc
b/util/m5/src/command/writefile.cc
index bef1932..7771dfe 100644
--- a/util/m5/src/command/writefile.cc
+++ b/util/m5/src/command/writefile.cc
@@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <errno.h>
+
#include <cstring>
#include <fstream>
#include <iostream>
@@ -41,12 +43,13 @@
write_file(const DispatchTable &dt, const std::string &filename,
const std::string &host_filename)
{
- std::cerr << "opening " << filename << std::endl;
+ std::cout << "Opening \"" << filename << "\"." << std::endl;
std::ifstream src(filename, std::ios_base::in | std::ios_base::binary);
if (!src) {
- std::cerr << "error opening " << filename << std::endl;
- return;
+ std::cerr << "Error opening \"" << filename << "\": " <<
+ strerror(errno) << std::endl;
+ exit(2);
}
char buf[256 * 1024];
@@ -58,8 +61,11 @@
src.seekg(offset);
src.read(buf, sizeof(buf));
int len = src.gcount();
- if (!src && !src.eof())
- break;
+ if (!src && !src.eof()) {
+ std::cerr << "Error reading \"" << filename << "\": " <<
+ strerror(errno) << std::endl;
+ exit(2);
+ }
char *wbuf = buf;
while (len) {
int bytes = (*dt.m5_write_file)(
@@ -71,7 +77,7 @@
if (src.eof())
break;
}
- std::cerr << "Wrote " << offset << " bytes." << std::endl;
+ std::cout << "Wrote " << offset << " bytes." << std::endl;
}
bool
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27627
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2c0d6592357965ed2eee8f090c8b3d530b354b9f
Gerrit-Change-Number: 27627
Gerrit-PatchSet: 23
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Earl Ou <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Pouya Fotouhi <[email protected]>
Gerrit-Reviewer: Yu-hsin Wang <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s