Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve Edward O'Callaghan: Looks good to me, approved
Drop STANDALONE mode

STANDALONE mode was used to build flashrom without having support for
file handling. This was relevant to build libflashrom on top of
libpayload. For a while now, the code which is covered by STANDALONE has
moved to cli_*.c and is not used for libflashrom. Therefore we can drop
STANDALONE mode.

Change-Id: I58fb82270a9884a323d9850176708d230fdc5165
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63469
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
---
M Makefile
M cli_classic.c
M cli_output.c
M flash.h
M tests/meson.build
5 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile
index 367d8ee..26c77d9 100644
--- a/Makefile
+++ b/Makefile
@@ -290,7 +290,6 @@
.DEFAULT_GOAL := libflashrom.a
$(info Setting default goal to libflashrom.a)
endif
-FLASHROM_CFLAGS += -DSTANDALONE
$(call mark_unsupported,CONFIG_DUMMY)
# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
$(call mark_unsupported,CONFIG_ATAPROMISE)
diff --git a/cli_classic.c b/cli_classic.c
index 0b6e79c..c543ff7 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -112,12 +112,10 @@
/* Ensure a file is open by means of fstat */
static bool check_file(FILE *file)
{
-#ifndef STANDALONE
struct stat statbuf;

if (fstat(fileno(file), &statbuf) < 0)
return false;
-#endif /* !STANDALONE */
return true;
}

@@ -279,9 +277,7 @@
char *referencefile = NULL;
char *layoutfile = NULL;
char *fmapfile = NULL;
-#ifndef STANDALONE
char *logfile = NULL;
-#endif /* !STANDALONE */
char *tempstr = NULL;
char *pparam = NULL;
struct layout_include_args *include_args = NULL;
@@ -481,9 +477,6 @@
exit(0);
break;
case 'o':
-#ifdef STANDALONE
- cli_classic_abort_usage("Log file not supported in standalone mode. Aborting.\n");
-#else /* STANDALONE */
if (logfile) {
fprintf(stderr, "Warning: -o/--output specified multiple times.\n");
free(logfile);
@@ -493,7 +486,6 @@
if (logfile[0] == '\0') {
cli_classic_abort_usage("No log filename specified.\n");
}
-#endif /* STANDALONE */
break;
default:
cli_classic_abort_usage(NULL);
@@ -511,13 +503,10 @@
cli_classic_abort_usage(NULL);
if (referencefile && check_filename(referencefile, "reference"))
cli_classic_abort_usage(NULL);
-
-#ifndef STANDALONE
if (logfile && check_filename(logfile, "log"))
cli_classic_abort_usage(NULL);
if (logfile && open_logfile(logfile))
cli_classic_abort_usage(NULL);
-#endif /* !STANDALONE */

#if CONFIG_PRINT_WIKI == 1
if (list_supported_wiki) {
@@ -532,9 +521,7 @@
goto out;
}

-#ifndef STANDALONE
start_logging();
-#endif /* !STANDALONE */

print_buildinfo();
msg_gdbg("Command line (%i args):", argc - 1);
@@ -808,9 +795,7 @@
/* clean up global variables */
free((char *)chip_to_probe); /* Silence! Freeing is not modifying contents. */
chip_to_probe = NULL;
-#ifndef STANDALONE
free(logfile);
ret |= close_logfile();
-#endif /* !STANDALONE */
return ret;
}
diff --git a/cli_output.c b/cli_output.c
index e12446d..629db67 100644
--- a/cli_output.c
+++ b/cli_output.c
@@ -24,7 +24,6 @@
enum flashrom_log_level verbose_screen = FLASHROM_MSG_INFO;
enum flashrom_log_level verbose_logfile = FLASHROM_MSG_DEBUG2;

-#ifndef STANDALONE
static FILE *logfile = NULL;

int close_logfile(void)
@@ -64,7 +63,6 @@
print_version();
verbose_screen = oldverbose_screen;
}
-#endif /* !STANDALONE */

/* Please note that level is the verbosity, not the importance of the message. */
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap)
@@ -85,13 +83,13 @@
if (level != FLASHROM_MSG_SPEW)
fflush(output_type);
}
-#ifndef STANDALONE
+
if ((level <= verbose_logfile) && logfile) {
ret = vfprintf(logfile, fmt, logfile_args);
if (level != FLASHROM_MSG_SPEW)
fflush(logfile);
}
-#endif /* !STANDALONE */
+
va_end(logfile_args);
return ret;
}
diff --git a/flash.h b/flash.h
index f63aa5d..b283c6c 100644
--- a/flash.h
+++ b/flash.h
@@ -442,11 +442,9 @@
/* cli_output.c */
extern enum flashrom_log_level verbose_screen;
extern enum flashrom_log_level verbose_logfile;
-#ifndef STANDALONE
int open_logfile(const char * const filename);
int close_logfile(void);
void start_logging(void);
-#endif
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap);
/* Let gcc and clang check for correct printf-style format strings. */
int print(enum flashrom_log_level level, const char *fmt, ...)
diff --git a/tests/meson.build b/tests/meson.build
index 90e0df1..d3b46b1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -102,7 +102,6 @@
cargs,
'-ffunction-sections',
'-fdata-sections',
- # '-DSTANDALONE',
],
export_dynamic : true,
link_args : mocks,

2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 63469. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I58fb82270a9884a323d9850176708d230fdc5165
Gerrit-Change-Number: 63469
Gerrit-PatchSet: 5
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged