From patchwork Sat Jun 28 01:25:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 32657 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2322D200B9 for ; Sat, 28 Jun 2014 01:27:53 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id 9sf8488530ykp.1 for ; Fri, 27 Jun 2014 18:27:52 -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=W8hdbtWp6FmMLbio5vZahWBY8Sqp0wkx02HoD465BCQ=; b=Nag5dhpoBbYHzNcPvNXgYk9pRezMWYTMgLiEXlghz8JQoWeWP6mY6OJgb/1FWY2POs N5FliZgfFHrVEsGd8WuatK1iQyl71lNK6yKcgcigusDWuWooTJFxh6uKZPRwfSVz7wUk cc7diBsten7v0LGAj4+sqCH8qNot06px5TnGONjbLqyhAfGzjuSRrsvjbS/EP2n7Pzl0 IUQmeVHlZ+bBS/V6vmhxl02s8IM6GAwi3ASad0nazfeu3woWWhmUFzjz5+qRZkWA2yXb mAVwYSarmP/J46F2eJgazOcSsET2Fq3n+NgB94uW/M07/12Akb16BlHo0coNZfAiP2/C +6AA== X-Gm-Message-State: ALoCoQk1wwS+UvOdGFTDDYPg7Pcs8xrkqqMHMkIKdoTZ1Qyln74Aw28sao0vPoNs0MHvioms6pFF X-Received: by 10.58.1.133 with SMTP id 5mr13510998vem.32.1403918872960; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls868704qge.74.gmail; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) X-Received: by 10.52.185.72 with SMTP id fa8mr19391101vdc.12.1403918872893; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id p19si7211287vdg.38.2014.06.27.18.27.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id jz11so6092847veb.2 for ; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) X-Received: by 10.52.29.236 with SMTP id n12mr19305036vdh.38.1403918872777; Fri, 27 Jun 2014 18:27:52 -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 tc5csp147865vcb; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) X-Received: by 10.58.8.12 with SMTP id n12mr22944301vea.28.1403918872453; Fri, 27 Jun 2014 18:27:52 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k14si5481586vdg.49.2014.06.27.18.27.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:52 -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 1X0hOx-0007I5-FT; Sat, 28 Jun 2014 01:25:59 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X0hOw-0007HO-Lw for xen-devel@lists.xen.org; Sat, 28 Jun 2014 01:25:58 +0000 Received: from [193.109.254.147:28272] by server-9.bemta-14.messagelabs.com id 60/95-14237-6A91EA35; Sat, 28 Jun 2014 01:25:58 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1403918755!14221910!1 X-Originating-IP: [209.85.192.175] 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 31342 invoked from network); 28 Jun 2014 01:25:56 -0000 Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 28 Jun 2014 01:25:56 -0000 Received: by mail-pd0-f175.google.com with SMTP id v10so5131110pde.34 for ; Fri, 27 Jun 2014 18:25:55 -0700 (PDT) X-Received: by 10.66.142.42 with SMTP id rt10mr35182838pab.1.1403918755225; Fri, 27 Jun 2014 18:25:55 -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 eh4sm16637918pbc.79.2014.06.27.18.25.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jun 2014 18:25:54 -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: Sat, 28 Jun 2014 02:25:25 +0100 Message-Id: <1403918735-30027-10-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1403918735-30027-1-git-send-email-roy.franz@linaro.org> References: <1403918735-30027-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH RFC 09/19] 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.128.171 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 | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 045714b..e61f9c9 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -174,12 +174,19 @@ void __init load_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, ++mbi.mods_count; } -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) { - 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) @@ -570,7 +577,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_file(dir_handle, s2w(&name), &kernel); efi_bs->FreePool(name.w); @@ -582,7 +590,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_file(dir_handle, s2w(&name), &ramdisk); efi_bs->FreePool(name.w); } @@ -593,7 +602,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_file(dir_handle, s2w(&name), &ucode); efi_bs->FreePool(name.w); } @@ -601,7 +611,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_file(dir_handle, s2w(&name), &xsm); efi_bs->FreePool(name.w); }