From patchwork Mon Jul 9 21:21:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 941684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Pdb44L0Dz9rxs for ; Tue, 10 Jul 2018 07:22:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="AjsuI1kn"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Pdb42mSgzDrcC for ; Tue, 10 Jul 2018 07:22:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="AjsuI1kn"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41PdZJ3P7WzDrSd for ; Tue, 10 Jul 2018 07:21:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SQtm9cg2E/wbnWafjpzG9HJSzjOCxUllutbTpI5fIhE=; b=AjsuI1kn3GGFiXQDczh8ZiNWJ Jcb+wC5JxR7kF+AkfJHisdDlrdGOohPpR6sckvIMz/iXuX61ueUfMe8U3mY+y7FbTLppNzPWOkZC8 C8ubXE59q1JZX2t/FniqWDU5obYNVfuTiCxPiWLJkQasQawfRzHYo8or0KF3ickN5jlmv1fMFtUXA IEvzMu8DbhCH5v9YoSDCXbpymKeBKHk0hOJDlllWhB+pPuonse8xieSMK8nUFBMbCdIfcp4UIp6ar TTiuybgW4Kg4PgRWzA9he46q+D69hEGIrNEhbyyvOMDa3yRSbJPMoHIOaIF0tk7MFs4cN7OxpHvAE 0aROIkX3w==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcdbX-0001Rm-Sl; Mon, 09 Jul 2018 21:21:55 +0000 Message-Id: <50dfba3d54e171403c67e7ae1f6cb428b01a34a3.1531170563.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Mon, 9 Jul 2018 13:57:53 -0700 Subject: [PATCH v1 08/10] discover/parser: Remove parser_stat_path context To: Samuel Mendoza-Jonas Date: Mon, 09 Jul 2018 21:21:55 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" parser_stat_path just uses the context when allocating a temp variable. Remove the context to make parser_stat_path more versatile. Signed-off-by: Geoff Levand --- discover/grub2/blscfg.c | 2 +- discover/grub2/builtins.c | 4 ++-- discover/parser.c | 12 +++++------- discover/parser.h | 5 ++--- discover/syslinux-parser.c | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/discover/grub2/blscfg.c b/discover/grub2/blscfg.c index d4754aa..d46504c 100644 --- a/discover/grub2/blscfg.c +++ b/discover/grub2/blscfg.c @@ -269,7 +269,7 @@ int builtin_blscfg(struct grub2_script *script, blsdir = script_env_get(script, "blsdir"); if (!blsdir) for (dir = bls_dirs; *dir; dir++) - if (!parser_stat_path(dc, dc->device, *dir, &statbuf)) { + if (!parser_stat_path(dc->device, *dir, &statbuf)) { blsdir = *dir; break; } diff --git a/discover/grub2/builtins.c b/discover/grub2/builtins.c index e42821a..3a5bc1a 100644 --- a/discover/grub2/builtins.c +++ b/discover/grub2/builtins.c @@ -143,7 +143,7 @@ static bool builtin_test_op_file(struct grub2_script *script, char op, int rc; struct stat statbuf; - rc = parser_stat_path(script->ctx, script->ctx->device, + rc = parser_stat_path(script->ctx->device, file, &statbuf); if (rc) return false; @@ -178,7 +178,7 @@ static bool builtin_test_op_dir(struct grub2_script *script, char op, if (op != 'd') return false; - rc = parser_stat_path(script->ctx, script->ctx->device, dir, &statbuf); + rc = parser_stat_path(script->ctx->device, dir, &statbuf); if (rc) { return false; } diff --git a/discover/parser.c b/discover/parser.c index 9fe1925..db23e0d 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -19,11 +19,10 @@ struct p_item { STATIC_LIST(parsers); -static char *local_path(struct discover_context *ctx, - struct discover_device *dev, +static char *local_path(void *alloc_ctx, struct discover_device *dev, const char *filename) { - return join_paths(ctx, dev->root_path, filename); + return join_paths(alloc_ctx, dev->root_path, filename); } int parser_request_file(struct discover_context *ctx, @@ -47,9 +46,8 @@ int parser_request_file(struct discover_context *ctx, return rc; } -int parser_stat_path(struct discover_context *ctx, - struct discover_device *dev, const char *path, - struct stat *statbuf) +int parser_stat_path(struct discover_device *dev, + const char *path, struct stat *statbuf) { int rc = -1; char *full_path; @@ -58,7 +56,7 @@ int parser_stat_path(struct discover_context *ctx, if (!dev->mount_path) return -1; - full_path = local_path(ctx, dev, path); + full_path = local_path(NULL, dev, path); rc = stat(full_path, statbuf); if (rc) { diff --git a/discover/parser.h b/discover/parser.h index bff52e3..f14259c 100644 --- a/discover/parser.h +++ b/discover/parser.h @@ -74,9 +74,8 @@ int parser_request_url(struct discover_context *ctx, struct pb_url *url, * does not have the limitations on file size that the functions above * do. Unlike some of the functions above, this function also works * on directories. */ -int parser_stat_path(struct discover_context *ctx, - struct discover_device *dev, const char *path, - struct stat *statbuf); +int parser_stat_path(struct discover_device *dev, + const char *path, struct stat *statbuf); /* Function used to list the files on a directory. The dirname should * be relative to the discover context device mount path. It returns * the number of files returned in files or a negative value on error. diff --git a/discover/syslinux-parser.c b/discover/syslinux-parser.c index defafd2..288048c 100644 --- a/discover/syslinux-parser.c +++ b/discover/syslinux-parser.c @@ -467,7 +467,7 @@ static int syslinux_parse(struct discover_context *dc) * guard against duplicate entries in case-insensitive * filesystems, mainly vfat boot partitions */ - rc = parser_stat_path(dc, dc->device, *filename, &statbuf); + rc = parser_stat_path(dc->device, *filename, &statbuf); if (rc) continue;