Submitter | Idwer Vollering |
---|---|
Date | 2014-08-21 11:37:29 |
Message ID | <CAPp9Orm7LkZafjjzusQtsFmtN5nZ+LMJF0nL2BHZfOkv-p=mtQ@mail.gmail.com> |
Download | mbox | patch |
Permalink | /patch/4239/ |
State | New |
Headers | show |
Comments
2014-08-21 13:37 GMT+02:00 Idwer Vollering: > Tested on physical hardware, built on FreeBSD (less portability 'headaches'). > > Signed-off-By: Idwer Vollering <vidwer@gmail.com> > > Index: cli_output.c > =================================================================== > --- cli_output.c (revision 1846) > +++ cli_output.c (working copy) > @@ -52,8 +52,12 @@ > msg_gerr("No logfile name specified.\n"); > return 1; > } > - if ((logfile = fopen(filename, "w")) == NULL) { > + if ((logfile = fopen(filename, "xw")) == NULL) { > msg_gerr("Error: opening log file \"%s\" failed: > %s\n", filename, strerror(errno)); > + msg_gdbg("This means that flashrom can't write log output\n" \ > + "to the file you specified (\"%s\"),\n" \ > + "or you are using the same filename to read > from/write to (-r / -w)\n" \ > + "and write the log output to (-o).\n", filename); > return 1; > } > return 0; "xw" always fails if filename exists even if it's not the same used for read or write, yes strerror() will have printed "File exists" but having to delete the log file by hand is inconvenient (I always create a log file "just in case" but I rarely need it)
Patch
Index: cli_output.c =================================================================== --- cli_output.c (revision 1846) +++ cli_output.c (working copy) @@ -52,8 +52,12 @@ msg_gerr("No logfile name specified.\n"); return 1; } - if ((logfile = fopen(filename, "w")) == NULL) { + if ((logfile = fopen(filename, "xw")) == NULL) { msg_gerr("Error: opening log file \"%s\" failed: %s\n", filename, strerror(errno)); + msg_gdbg("This means that flashrom can't write log output\n" \ + "to the file you specified (\"%s\"),\n" \ + "or you are using the same filename to read from/write to (-r / -w)\n" \ + "and write the log output to (-o).\n", filename); return 1;
Tested on physical hardware, built on FreeBSD (less portability 'headaches'). Signed-off-By: Idwer Vollering <vidwer@gmail.com> } return 0;