From e0727715162d169ac81817d9d58cccf5f416579d Mon Sep 17 00:00:00 2001 From: buxiasen Date: Sat, 22 Feb 2025 18:28:57 +0800 Subject: [PATCH] binfmt/copyactions: fix comments, make the actions life cycle more clear Signed-off-by: buxiasen --- binfmt/binfmt.h | 3 ++- binfmt/binfmt_copyactions.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/binfmt/binfmt.h b/binfmt/binfmt.h index a60d55318fd..3cdf07ecbfa 100644 --- a/binfmt/binfmt.h +++ b/binfmt/binfmt.h @@ -177,7 +177,8 @@ void binfmt_freeargv(FAR char * const *argv); * do not have any real option other than to copy the callers action list. * * Input Parameters: - * copy - Pointer of file actions + * copy - Pointer of the copied output file actions + * actions - Pointer of file actions to be copy * * Returned Value: * A non-zero copy is returned on success. diff --git a/binfmt/binfmt_copyactions.c b/binfmt/binfmt_copyactions.c index 715dcbdc753..d1ed70b56d9 100644 --- a/binfmt/binfmt_copyactions.c +++ b/binfmt/binfmt_copyactions.c @@ -52,7 +52,8 @@ * do not have any real option other than to copy the callers action list. * * Input Parameters: - * copy - Pointer of file actions + * copy - Pointer of the copied output file actions + * actions - Pointer of file actions to be copy * * Returned Value: * A non-zero copy is returned on success. @@ -108,6 +109,11 @@ int binfmt_copyactions(FAR const posix_spawn_file_actions_t **copy, return -ENOMEM; } + /* We need to copy and re-organize the flink chain, be care not modify + * the actions it self, the prev have to point to the last time foreach + * item. + */ + for (entry = (FAR struct spawn_general_file_action_s *)actions, prev = NULL; entry != NULL; entry = entry->flink) {