diff mbox series

[v1,08/10] discover/parser: Remove parser_stat_path context

Message ID 50dfba3d54e171403c67e7ae1f6cb428b01a34a3.1531170563.git.geoff@infradead.org
State Superseded
Headers show
Series [v1,01/10] docker: Add libfdt-dev | expand

Commit Message

Geoff Levand July 9, 2018, 9:21 p.m. UTC
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 <geoff@infradead.org>
---
 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(-)

Comments

Geoff Levand July 9, 2018, 10:41 p.m. UTC | #1
Hi Sam,

On 07/09/2018 02:21 PM, Geoff Levand wrote:
> parser_stat_path just uses the context when allocating a temp
> variable. Remove the context to make parser_stat_path more
> versatile.

On testing I found the test suite needs the discover_context,
so I'll drop this patch and also fix up the parser_is_unique
patch to have a discover_context.

-Geoff
diff mbox series

Patch

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;