From patchwork Tue Jul 22 00:43:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 34013 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f199.google.com (mail-yk0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2088620492 for ; Tue, 22 Jul 2014 00:46:16 +0000 (UTC) Received: by mail-yk0-f199.google.com with SMTP id 79sf16478299ykr.10 for ; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=dIP+7BVcPKkPE1/ezQDzM1MFk/VTcvAAcShJnoikPno=; b=EbgrdSTvZjSwZ7bR4cyAKg1MI4M75xXo5qmliZPmjdYm9BpzWryyd0FA+rFQ5ccNRW thc5XlAphghPWHRr+8dbm6M75ADCc1sYvm5NwAbFW5gNMIreCJT0asXYjrxImpiKiRdo 7ySdrVpMAZwmNKXC9BLnsFy+oomQtZ4JG/vxYmlKCI0QgF5kRcV6xDn+0EZSw861AiIx K6MkV+BmOhtlba8a5GPumfeAe5Ym1btptdXhtO/MT968oYuXwjLM5QJ2ISiF6cfejMHy R1QLfyp2ogXSLbjsSeY+iZlraVQgnN6mEblRzjiyJmpkbnviLrGA5dYb+z8A/MeVN8Zx OA9A== X-Gm-Message-State: ALoCoQlVLKGs5EoPZFd7oEwKl4gajcjB/Pn4uFBONzX2HfkxqRLLekILeECkmGiELwnmhgB+s+wV X-Received: by 10.236.126.103 with SMTP id a67mr13065968yhi.4.1405989975811; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.203 with SMTP id v69ls2082976qgd.6.gmail; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-Received: by 10.221.56.132 with SMTP id wc4mr34979725vcb.38.1405989975662; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id re13si12876135vcb.8.2014.07.21.17.46.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so13678038vcb.36 for ; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr34969181vcb.0.1405989975579; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp154152vcb; Mon, 21 Jul 2014 17:46:15 -0700 (PDT) X-Received: by 10.140.85.101 with SMTP id m92mr45952153qgd.26.1405989974688; Mon, 21 Jul 2014 17:46:14 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id n11si28863482qgd.126.2014.07.21.17.46.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:14 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBi-00008v-8h; Tue, 22 Jul 2014 00:44:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBg-00008E-JQ for xen-devel@lists.xen.org; Tue, 22 Jul 2014 00:44:12 +0000 Received: from [85.158.137.68:45659] by server-7.bemta-3.messagelabs.com id 5F/99-01084-BD3BDC35; Tue, 22 Jul 2014 00:44:11 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1405989849!17122808!1 X-Originating-IP: [209.85.220.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11627 invoked from network); 22 Jul 2014 00:44:10 -0000 Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Jul 2014 00:44:10 -0000 Received: by mail-pa0-f44.google.com with SMTP id eu11so10815981pac.17 for ; Mon, 21 Jul 2014 17:44:08 -0700 (PDT) X-Received: by 10.68.103.66 with SMTP id fu2mr7583771pbb.133.1405989848865; Mon, 21 Jul 2014 17:44:08 -0700 (PDT) Received: from rfranz-t520.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id fl3sm15417298pbc.35.2014.07.21.17.44.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 17:44:08 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Mon, 21 Jul 2014 17:43:28 -0700 Message-Id: <1405989815-25236-6-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> References: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH V2 05/12] replace split_value() with truncate_string() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Replace the split_value() function with a more generic string handling function truncate_string(). split_value() used to update the multiboot structures directly, and this has been moved to the call sites to allow truncate_string() to be more generic. Signed-off-by: Roy Franz --- xen/arch/x86/efi/boot.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 17aaa67..546ff1c 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -466,7 +466,13 @@ static char *__init get_value(const struct file *cfg, const char *section, break; default: if ( match && strncmp(ptr, item, ilen) == 0 && ptr[ilen] == '=' ) - return ptr + ilen + 1; + { + ptr += ilen + 1; + /* strip off any leading spaces */ + while ( *ptr && isspace(*ptr) ) + ptr++; + return ptr; + } break; } ptr += strlen(ptr); @@ -489,14 +495,19 @@ bool_t __init load_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, return 0; } -static void __init split_value(char *s) +/* Truncate string at first space, and return pointer + * to remainder of string. + */ +char * __init truncate_string(char *s) { - while ( *s && isspace(*s) ) - ++s; - place_string(&mb_modules[mbi.mods_count].string, s); while ( *s && !isspace(*s) ) ++s; - *s = 0; + if (*s) + { + *s = 0; + return(s + 1); + } + return(NULL); } static void __init edd_put_string(u8 *dst, size_t n, const char *src) @@ -893,7 +904,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } if ( !name.s ) blexit(L"No Dom0 kernel image specified."); - split_value(name.s); + place_string(&mb_modules[mbi.mods_count].string, name.s); + truncate_string(name.s); load_ok = load_file(dir_handle, s2w(&name), &kernel); efi_bs->FreePool(name.w); if ( !load_ok ) @@ -907,7 +919,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s = get_value(&cfg, section.s, "ramdisk"); if ( name.s ) { - split_value(name.s); + place_string(&mb_modules[mbi.mods_count].string, name.s); + truncate_string(name.s); load_ok = load_file(dir_handle, s2w(&name), &ramdisk); efi_bs->FreePool(name.w); if ( !load_ok ) @@ -920,7 +933,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( name.s ) { microcode_set_module(mbi.mods_count); - split_value(name.s); + place_string(&mb_modules[mbi.mods_count].string, name.s); + truncate_string(name.s); load_ok = load_file(dir_handle, s2w(&name), &ucode); efi_bs->FreePool(name.w); if ( !load_ok ) @@ -930,7 +944,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s = get_value(&cfg, section.s, "xsm"); if ( name.s ) { - split_value(name.s); + place_string(&mb_modules[mbi.mods_count].string, name.s); + truncate_string(name.s); load_ok = load_file(dir_handle, s2w(&name), &xsm); efi_bs->FreePool(name.w); if ( !load_ok )