libs/libc/builtin/: builtint_isavail() should not set the errno variable because this functions may be used by internal OS logic for which setting the rrno variable would be inappropriate.
This commit is contained in:
parent
d8adf712a2
commit
254a906409
1
TODO
1
TODO
@ -286,6 +286,7 @@ o Task/Scheduler (sched/)
|
|||||||
open() used within the OS. There are places under libs/ and
|
open() used within the OS. There are places under libs/ and
|
||||||
boards/ that have not been converted. I also note cases
|
boards/ that have not been converted. I also note cases
|
||||||
where fopen() is called under libs/libc/netdb/.
|
where fopen() is called under libs/libc/netdb/.
|
||||||
|
2019-09-11: built_isavail() no longer sets the errno varaible.
|
||||||
|
|
||||||
Status: Open
|
Status: Open
|
||||||
Priority: Low. Things are working OK the way they are. But the design
|
Priority: Low. Things are working OK the way they are. But the design
|
||||||
|
@ -123,11 +123,9 @@ static int builtin_loadbinary(struct binary_s *binp)
|
|||||||
index = builtin_isavail(filename);
|
index = builtin_isavail(filename);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
int errval = get_errno();
|
|
||||||
berr("ERROR: %s is not a builtin application\n", filename);
|
berr("ERROR: %s is not a builtin application\n", filename);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -errval;
|
return index;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the load information. NOTE: that there is no way to configure
|
/* Return the load information. NOTE: that there is no way to configure
|
||||||
|
@ -131,9 +131,9 @@ EXTERN const int g_builtin_count;
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* builtins - The list of built-in functions. Each entry is a name-value
|
* builtins - The list of built-in functions. Each entry is a name-value
|
||||||
* pair that maps a builtin function name to its user-space
|
* pair that maps a built-in function name to its user-space
|
||||||
* entry point address.
|
* entry point address.
|
||||||
* count - The number of name-value pairs in the builtin list.
|
* count - The number of name-value pairs in the built-in list.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
@ -149,15 +149,18 @@ void builtin_setlist(FAR const struct builtin_s *builtins, int count);
|
|||||||
* Name: builtin_isavail
|
* Name: builtin_isavail
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Checks for availability of application registered during compile time.
|
* Checks for availability of an application named 'appname' registered
|
||||||
|
* during compile time and, if available, returns the index into the table
|
||||||
|
* of built-in applications.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* filename - Name of the linked-in binary to be started.
|
* filename - Name of the linked-in binary to be started.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* This is an end-user function, so it follows the normal convention:
|
* This is an internal function, used by by the NuttX binfmt logic and
|
||||||
* Returns index of builtin application. If it is not found then it
|
* by the application built-in logic. It returns a non-negative index to
|
||||||
* returns -1 (ERROR) and sets errno appropriately.
|
* the application entry in the table of built-in applications on success
|
||||||
|
* or a negated errno value in the event of a failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -185,9 +188,10 @@ FAR const char *builtin_getname(int index);
|
|||||||
* Name: builtin_for_index
|
* Name: builtin_for_index
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Returns the builtin_s structure for the selected builtin.
|
* Returns the builtin_s structure for the selected built-in.
|
||||||
* If support for builtin functions is enabled in the NuttX configuration,
|
* If support for built-in functions is enabled in the NuttX
|
||||||
* then this function must be provided by the application code.
|
* configuration, then this function must be provided by the application
|
||||||
|
* code.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* index, from 0 and on...
|
* index, from 0 and on...
|
||||||
|
@ -49,6 +49,25 @@
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: builtin_for_index
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Returns the builtin_s structure for the selected built-in.
|
||||||
|
* If support for built-in functions is enabled in the NuttX
|
||||||
|
* configuration, then this function must be provided by the application
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* index, from 0 and on...
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Returns valid pointer pointing to the builtin_s structure if index is
|
||||||
|
* valid.
|
||||||
|
* Otherwise, NULL is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
FAR const struct builtin_s *builtin_for_index(int index)
|
FAR const struct builtin_s *builtin_for_index(int index)
|
||||||
{
|
{
|
||||||
if (index < g_builtin_count)
|
if (index < g_builtin_count)
|
||||||
|
@ -58,8 +58,15 @@
|
|||||||
* Name: builtin_getname
|
* Name: builtin_getname
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return the name of the application at index in the table of builtin
|
* Returns pointer the a name of the application at 'index' in the table
|
||||||
* applications.
|
* of built-in applications.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* index - From 0 and on ...
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Returns valid pointer pointing to the app name if index is valid.
|
||||||
|
* Otherwise NULL is returned.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* With subsequent updates, modifications, and general maintenance by:
|
* With subsequent updates, modifications, and general maintenance by:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -62,8 +62,18 @@
|
|||||||
* Name: builtin_isavail
|
* Name: builtin_isavail
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return the index into the table of applications for the application with
|
* Checks for availability of an application named 'appname' registered
|
||||||
* the name 'appname'.
|
* during compile time and, if available, returns the index into the table
|
||||||
|
* of built-in applications.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* filename - Name of the linked-in binary to be started.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* This is an internal function, used by by the NuttX binfmt logic and
|
||||||
|
* by the application built-in logic. It returns a non-negative index to
|
||||||
|
* the application entry in the table of built-in applications on success
|
||||||
|
* or a negated errno value in the event of a failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -72,16 +82,15 @@ int builtin_isavail(FAR const char *appname)
|
|||||||
FAR const char *name;
|
FAR const char *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; (name = builtin_getname(i)); i++)
|
for (i = 0; (name = builtin_getname(i)) != NULL; i++)
|
||||||
{
|
{
|
||||||
if (!strncmp(name, appname, NAME_MAX))
|
if (strncmp(name, appname, NAME_MAX) == 0)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_errno(ENOENT);
|
return -ENOENT;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_BUILTIN_CONTEXT */
|
#endif /* HAVE_BUILTIN_CONTEXT */
|
||||||
|
@ -78,9 +78,9 @@ int g_builtin_count;
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* builtins - The list of built-in functions. Each entry is a name-value
|
* builtins - The list of built-in functions. Each entry is a name-value
|
||||||
* pair that maps a builtin function name to its user-space
|
* pair that maps a built-in function name to its user-space
|
||||||
* entry point address.
|
* entry point address.
|
||||||
* count - The number of name-value pairs in the builtin list.
|
* count - The number of name-value pairs in the built-in list.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
|
Loading…
Reference in New Issue
Block a user