From patchwork Thu Oct 8 03:19:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 527561 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 392ED140273 for ; Thu, 8 Oct 2015 14:18:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=w4YikLFb; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3AD8F4B8E8; Thu, 8 Oct 2015 05:17:48 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gnNqbjnH0l8d; Thu, 8 Oct 2015 05:17:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30D1B4B8EC; Thu, 8 Oct 2015 05:17:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B5D64B8A1 for ; Thu, 8 Oct 2015 05:17:03 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HnC0sjcEsRJQ for ; Thu, 8 Oct 2015 05:17:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by theia.denx.de (Postfix) with ESMTPS id 28AF44B8AE for ; Thu, 8 Oct 2015 05:16:53 +0200 (CEST) Received: by pacex6 with SMTP id ex6so40223924pac.0 for ; Wed, 07 Oct 2015 20:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=Jb16B0He9oGhTOpzONmF+E1J4BUocUaVk2OFJgsT9cc=; b=w4YikLFbkvZD7KnRVDXp/MjPkbXqUXuHAWCblLpsJKmaBI0GXrwjujkHB389yc8BoD nieqfj4hpY4T+sG4Eaa+L6I58PDnlt+8L3v4z/rsLAoiSK8ut0O/JYN/RCgBGasARqiW ZH6dUMcVuuw0w2r2Mb5YsRq9r8XzHGPy6pbFcd5ynIGajGCjxDSm4/3yw7esywtahc8K 16Avk12jnhYyzJwtTz2EAHf6LDH0qj7XzFOvB5yXd4UVwva6hU3PZAXp6zv5OHcpMvCX Dteoh3XtRD6BO7WCI8TIS6dNgmbNF/4CAz28mzdeYj4Px5chhJLl+d2hXBk5VQrUeMDD z7hg== X-Received: by 10.68.254.7 with SMTP id ae7mr5266319pbd.131.1444274212681; Wed, 07 Oct 2015 20:16:52 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id fb1sm42284352pab.9.2015.10.07.20.16.51 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 20:16:52 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List , Tom Rini , Hannes Schmelzer , Jian Luo , Miao Yan , Dean Armstrong Date: Wed, 7 Oct 2015 20:19:15 -0700 Message-Id: <1444274360-30189-8-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1444274360-30189-1-git-send-email-bmeng.cn@gmail.com> References: <1444274360-30189-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v3 07/12] cmd: bootvx: Avoid strlen() calls when constructing VxWorks bootline X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Remember the position in the VxWorks bootline buffer to avoid the call to strlen() each time. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- Changes in v3: - New patch to avoid strlen() calls when constructing VxWorks bootline Changes in v2: None common/cmd_elf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 62863df..6c95851 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -213,6 +213,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *bootline; /* Text of the bootline */ char *tmp; /* Temporary char pointer */ char build_buf[128]; /* Buffer for building the bootline */ + int ptr = 0; /* * Check the loadaddr variable. @@ -277,30 +278,29 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) max(strlen(bootline), (size_t)255)); flush_cache(bootaddr, max(strlen(bootline), (size_t)255)); } else { - sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE); + ptr = sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE); tmp = getenv("bootfile"); if (tmp) - sprintf(&build_buf[strlen(build_buf)], - "%s:%s ", CONFIG_SYS_VXWORKS_SERVERNAME, tmp); + ptr += sprintf(build_buf + ptr, "%s:%s ", + CONFIG_SYS_VXWORKS_SERVERNAME, tmp); else - sprintf(&build_buf[strlen(build_buf)], - "%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME); + ptr += sprintf(build_buf + ptr, "%s:file ", + CONFIG_SYS_VXWORKS_SERVERNAME); tmp = getenv("ipaddr"); if (tmp) - sprintf(&build_buf[strlen(build_buf)], "e=%s ", tmp); + ptr += sprintf(build_buf + ptr, "e=%s ", tmp); tmp = getenv("serverip"); if (tmp) - sprintf(&build_buf[strlen(build_buf)], "h=%s ", tmp); + ptr += sprintf(build_buf + ptr, "h=%s ", tmp); tmp = getenv("hostname"); if (tmp) - sprintf(&build_buf[strlen(build_buf)], "tn=%s ", tmp); + ptr += sprintf(build_buf + ptr, "tn=%s ", tmp); #ifdef CONFIG_SYS_VXWORKS_ADD_PARAMS - sprintf(&build_buf[strlen(build_buf)], - CONFIG_SYS_VXWORKS_ADD_PARAMS); + ptr += sprintf(build_buf + ptr, CONFIG_SYS_VXWORKS_ADD_PARAMS); #endif memcpy((void *)bootaddr, build_buf,