From b95aa03f38d2073e68968145c99a216e4d45084f Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Fri, 28 Sep 2018 19:41:57 +0800 Subject: futility: updater: Revise verbosity and error messages `futility` used to print debug messages to stdout, but there is a side effect that stdout may be buffered and then flush later than stderr. For example, when calling futility via ssh, we will see flashrom messages before any of futility's own messages. Also, many people want to get flashrom verbose messages (-V). With this change, when calling ERROR and DEBUG, we will always output to stderr. This also enables better parameter type checking. `-d` and `-v` both contribute to verbosity, that will be converted to -V's when calling flashrom. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1d22a8054fc43cdc5e6c7415e131cc9826fbff0c Signed-off-by: Hung-Te Lin Reviewed-on: https://chromium-review.googlesource.com/1251145 --- futility/updater.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'futility/updater.h') diff --git a/futility/updater.h b/futility/updater.h index 58445a1c..3993f073 100644 --- a/futility/updater.h +++ b/futility/updater.h @@ -8,11 +8,15 @@ #ifndef VBOOT_REFERENCE_FUTILITY_UPDATER_H_ #define VBOOT_REFERENCE_FUTILITY_UPDATER_H_ +#include + #include "fmap.h" -#include "futility.h" -#define DEBUG(format, ...) Debug("%s: " format "\n", __FUNCTION__,##__VA_ARGS__) -#define ERROR(format, ...) Error("%s: " format "\n", __FUNCTION__,##__VA_ARGS__) +extern int debugging_enabled; +#define DEBUG(format, ...) do { if (debugging_enabled) fprintf(stderr, \ + "DEBUG: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__); } while (0) +#define ERROR(format, ...) fprintf(stderr, \ + "ERROR: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__) /* FMAP section names. */ static const char * const FMAP_RO_FRID = "RO_FRID", @@ -97,6 +101,7 @@ struct updater_config { int try_update; int force_update; int legacy_update; + int verbosity; const char *emulation; }; @@ -153,7 +158,8 @@ int updater_setup_config(struct updater_config *cfg, const char *write_protection, int is_factory, int try_update, - int force_update); + int force_update, + int verbosity); /* Prints the name and description from all supported quirks. */ void updater_list_config_quirks(const struct updater_config *cfg); -- cgit v1.2.1