xiaoxiang781216 commented on code in PR #21454:
URL: https://github.com/apache/nuttx/pull/21454#discussion_r4468841202
##########
binfmt/binfmt_loadmodule.c:
##########
Review Comment:
```
if (first == OK && ret != -ENOEXEC)
{
first = ret;
}
if (ret == -EACCES)
{
break;
}
```
##########
binfmt/binfmt_loadmodule.c:
##########
@@ -150,9 +151,19 @@ static int load_absmodule(FAR struct binary_s *bin, FAR
const char *filename,
break;
}
+
+ /* -ENOEXEC is the "not my format" of a handler. Keep the first other
+ * error (a missing file, or -ENOMEM from a handler that knew the
+ * format): the next handlers must not hide it.
+ */
+
+ if (first == OK && ret != -ENOEXEC)
+ {
+ first = ret;
+ }
}
- return ret;
+ return ret == OK || ret == -EACCES || first == OK ? ret : first;
Review Comment:
`return ret == OK ? ret : first;`
##########
binfmt/builtin.c:
##########
@@ -76,24 +78,27 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
int nexports)
{
FAR const struct builtin_s *builtin;
- FAR char *name;
+ FAR const char *name;
+ struct stat buf;
int ret;
binfo("Loading file: %s\n", filename);
name = strrchr(filename, '/');
- if (name != NULL)
- {
- filename = name + 1;
- }
+ name = name != NULL ? name + 1 : filename;
/* Looking up the index to this name in g_builtins[] */
- ret = builtin_isavail(filename);
+ ret = builtin_isavail(name);
if (ret < 0)
{
- berr("ERROR: %s is not a builtin application\n", filename);
- return ret;
+ /* Not mine: -ENOEXEC for a file that exists, as in the other handlers;
+ * -ENOENT only for a file that is not there.
+ */
+
+ binfo("%s is not a builtin application\n", name);
+ ret = nx_stat(filename, &buf, 1);
Review Comment:
why need nx_stat, it's enough to return -ENOEXEC if builtin_isavail return
fail
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]