From patchwork Wed May 4 11:51:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Huber X-Patchwork-Id: 618392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r0Gfh5DwHz9sDX for ; Wed, 4 May 2016 21:54:20 +1000 (AEST) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1axvLy-0006mv-27; Wed, 04 May 2016 13:52:30 +0200 Received: from a.mx.secunet.com ([62.96.220.36]) by mail.coreboot.org with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.86_2) (envelope-from ) id 1axvLb-0006ji-At for flashrom@flashrom.org; Wed, 04 May 2016 13:52:19 +0200 Received: from localhost (alg1 [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 67E201A0674 for ; Wed, 4 May 2016 13:52:04 +0200 (CEST) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id j38FpaHmPeXZ for ; Wed, 4 May 2016 13:52:00 +0200 (CEST) Received: from mail-essen-01.secunet.de (unknown [10.53.40.204]) by a.mx.secunet.com (Postfix) with ESMTP id 4482D1A070A for ; Wed, 4 May 2016 13:51:58 +0200 (CEST) Received: from schawa.localdomain (10.182.9.137) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 4 May 2016 13:51:58 +0200 From: Nico Huber To: Date: Wed, 4 May 2016 13:51:38 +0200 Message-ID: <1462362706-31216-7-git-send-email-nico.huber@secunet.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1462362706-31216-1-git-send-email-nico.huber@secunet.com> References: <1462362706-31216-1-git-send-email-nico.huber@secunet.com> MIME-Version: 1.0 X-Originating-IP: [10.182.9.137] X-G-Data-MailSecurity-for-Exchange-SpamLevel: 0 X-G-Data-MailSecurity-for-Exchange-SpamFilter: 0; 1; str=0001.0A0C0201.5729E25F.005E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 32 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: D6962EF3-F00B-4082-AB52-848B6F0F22B5 X-Spam-Score: -1.6 (-) Subject: [flashrom] [PATCH 06/14] Adapt CLI to use new libflashrom interface' print callback X-BeenThere: flashrom@flashrom.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: flashrom discussion and development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: flashrom-bounces@flashrom.org Sender: "flashrom" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff This renames CLI's print() to fl_print_cb() and registers it through the new libflashrom interface. Signed-off-by: Nico Huber --- cli_classic.c | 3 +++ cli_output.c | 13 ++++++------- flash.h | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cli_classic.c b/cli_classic.c index a2c2014..ac4c6f8 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -30,6 +30,7 @@ #include "flash.h" #include "flashchips.h" #include "programmer.h" +#include "libflashrom.h" static void cli_classic_usage(const char *name) { @@ -135,6 +136,8 @@ int main(int argc, char *argv[]) char *tempstr = NULL; char *pparam = NULL; + fl_set_log_callback((fl_log_callback_t *)&fl_print_cb); + print_version(); print_banner(); diff --git a/cli_output.c b/cli_output.c index feafbd2..2805dec 100644 --- a/cli_output.c +++ b/cli_output.c @@ -71,19 +71,19 @@ void start_logging(void) #endif /* !STANDALONE */ /* Please note that level is the verbosity, not the importance of the message. */ -int print(enum msglevel level, const char *fmt, ...) +int fl_print_cb(enum msglevel level, const char *fmt, va_list ap) { - va_list ap; int ret = 0; FILE *output_type = stdout; + va_list logfile_args; + va_copy(logfile_args, ap); + if (level < MSG_INFO) output_type = stderr; if (level <= verbose_screen) { - va_start(ap, fmt); ret = vfprintf(output_type, fmt, ap); - va_end(ap); /* msg_*spew often happens inside chip accessors in possibly * time-critical operations. Don't slow them down by flushing. */ if (level != MSG_SPEW) @@ -91,12 +91,11 @@ int print(enum msglevel level, const char *fmt, ...) } #ifndef STANDALONE if ((level <= verbose_logfile) && logfile) { - va_start(ap, fmt); - ret = vfprintf(logfile, fmt, ap); - va_end(ap); + ret = vfprintf(logfile, fmt, logfile_args); if (level != MSG_SPEW) fflush(logfile); } #endif /* !STANDALONE */ + va_end(logfile_args); return ret; } diff --git a/flash.h b/flash.h index 5544160..3afa846 100644 --- a/flash.h +++ b/flash.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #if IS_WINDOWS #include @@ -319,6 +320,7 @@ enum msglevel { MSG_DEBUG2 = 4, MSG_SPEW = 5, }; +int fl_print_cb(enum msglevel level, const char *fmt, va_list ap); /* Let gcc and clang check for correct printf-style format strings. */ int print(enum msglevel level, const char *fmt, ...) #ifdef __MINGW32__