From patchwork Wed May 4 11:51:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Huber X-Patchwork-Id: 618387 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 3r0GfK4RVRz9sCY for ; Wed, 4 May 2016 21:54:01 +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 1axvM1-0006oj-Ak; Wed, 04 May 2016 13:52:33 +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 1axvLn-0006kD-U8 for flashrom@flashrom.org; Wed, 04 May 2016 13:52:27 +0200 Received: from localhost (alg1 [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id D21271A06DA for ; Wed, 4 May 2016 13:52:07 +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 DwZjJBXIopEs for ; Wed, 4 May 2016 13:52:05 +0200 (CEST) Received: from mail-essen-01.secunet.de (unknown [10.53.40.204]) by a.mx.secunet.com (Postfix) with ESMTP id DCAEA1A074D for ; Wed, 4 May 2016 13:52:01 +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:52:02 +0200 From: Nico Huber To: Date: Wed, 4 May 2016 13:51:44 +0200 Message-ID: <1462362706-31216-13-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.0A0C0202.5729E262.0263, 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: DB8ACFAD-CA2A-49E0-8658-9BCB38E1797F X-Spam-Score: -1.6 (-) Subject: [flashrom] [PATCH 12/14] Fix linking with libpayload 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 o flashbuses_to_text() is a cli function and should actually be moved or not be called from flashrom.c. o I couldn't find any libc that defines HAVE_STRNLEN. Signed-off-by: Nico Huber --- flash.h | 2 +- flashrom.c | 9 ++++++--- helpers.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flash.h b/flash.h index 05cb59b..765ae4f 100644 --- a/flash.h +++ b/flash.h @@ -262,7 +262,7 @@ void tolower_string(char *str); #ifdef __MINGW32__ char* strtok_r(char *str, const char *delim, char **nextp); #endif -#if defined(__DJGPP__) || !defined(HAVE_STRNLEN) +#if defined(__DJGPP__) size_t strnlen(const char *str, size_t n); #endif diff --git a/flashrom.c b/flashrom.c index 0fcbab8..579376a 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1166,7 +1166,7 @@ int probe_flash(struct registered_master *mst, int startchip, struct flashctx *f { const struct flashchip *chip; enum chipbustype buses_common; - char *tmp; + char *tmp = NULL; for (chip = flashchips + startchip; chip && chip->name; chip++) { if (chip_to_probe && strcmp(chip->name, chip_to_probe) != 0) @@ -1248,9 +1248,12 @@ notfound: return -1; +#ifndef __LIBPAYLOAD__ tmp = flashbuses_to_text(flash->chip->bustype); - msg_cinfo("%s %s flash chip \"%s\" (%d kB, %s) ", force ? "Assuming" : "Found", - flash->chip->vendor, flash->chip->name, flash->chip->total_size, tmp); +#endif + msg_cinfo("%s %s flash chip \"%s\" (%d kB%s%s) ", force ? "Assuming" : "Found", + flash->chip->vendor, flash->chip->name, flash->chip->total_size, + tmp ? ", " : "", tmp ? tmp : ""); free(tmp); #if CONFIG_INTERNAL == 1 if (programmer_table[programmer].map_flash_region == physmap) diff --git a/helpers.c b/helpers.c index f6eae46..7a146c3 100644 --- a/helpers.c +++ b/helpers.c @@ -92,7 +92,7 @@ char* strtok_r(char *str, const char *delim, char **nextp) #endif /* There is no strnlen in DJGPP */ -#if defined(__DJGPP__) || !defined(HAVE_STRNLEN) +#if defined(__DJGPP__) size_t strnlen(const char *str, size_t n) { size_t i;