From 2217c50a4fd46567e27ed6073d153ee478a099c2 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Wed, 10 Jun 2020 09:29:25 -0700 Subject: [PATCH] fastboot: don't print anything in Status() if the input is empty Status() is called with an empty string to handle `fastboot oem` commands. This currently emits a set of spaces and sets last_start_time such that the epilog can track the time spent in this command. Emitting the spaces is problematic however, since it results in the follow: $ fastboot oem device-info (bootloader) Verity mode: false (bootloader) Device unlocked: true (bootloader) Device critical unlocked: true (bootloader) Charger screen enabled: true OKAY [ 0.000s] Finished. Total time: 0.000s If we skip emitting the spaces, then we get the correct result: $ fastboot oem device-info (bootloader) Verity mode: false (bootloader) Device unlocked: true (bootloader) Device critical unlocked: true (bootloader) Charger screen enabled: true OKAY [ 0.001s] Finished. Total time: 0.001s There are no other uses of Status() with an empty string, so this changes won't impact other commands. Bug: 158310284 Test: fastboot formats this and other commands correctly. Change-Id: I6294acefc65a8399160c0944b3fbc2f2ace919ed --- fastboot/fastboot.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 46d1d36d8..0e9713d4a 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -200,8 +200,10 @@ static std::string find_item(const std::string& item) { double last_start_time; static void Status(const std::string& message) { - static constexpr char kStatusFormat[] = "%-50s "; - fprintf(stderr, kStatusFormat, message.c_str()); + if (!message.empty()) { + static constexpr char kStatusFormat[] = "%-50s "; + fprintf(stderr, kStatusFormat, message.c_str()); + } last_start_time = now(); }