forked from Imagelibrary/rtems
score: Return a status in _Objects_Set_name()
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/apimutex.h>
|
#include <rtems/score/apimutex.h>
|
||||||
#include <rtems/score/assert.h>
|
#include <rtems/score/assert.h>
|
||||||
#include <rtems/score/isrlock.h>
|
#include <rtems/score/isrlock.h>
|
||||||
|
#include <rtems/score/status.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/threaddispatch.h>
|
#include <rtems/score/threaddispatch.h>
|
||||||
|
|
||||||
@@ -461,14 +462,15 @@ size_t _Objects_Name_to_string(
|
|||||||
* or up to the first four characters of the string based upon
|
* or up to the first four characters of the string based upon
|
||||||
* whether this object class uses strings for names.
|
* whether this object class uses strings for names.
|
||||||
*
|
*
|
||||||
* @param information points to the object information structure
|
* @param information points to the object information.
|
||||||
* @param[out] the_object is the object to operate upon
|
* @param[out] the_object is the object to operate upon.
|
||||||
* @param name is a pointer to the name to use
|
* @param name is a pointer to the name to use.
|
||||||
*
|
*
|
||||||
* @retval true The operation succeeded.
|
* @retval STATUS_SUCCESSFUL The operation succeeded.
|
||||||
* @retval false The operation failed.
|
*
|
||||||
|
* @retval STATUS_NO_MEMORY There was no memory available to duplicate the name.
|
||||||
*/
|
*/
|
||||||
bool _Objects_Set_name(
|
Status_Control _Objects_Set_name(
|
||||||
const Objects_Information *information,
|
const Objects_Information *information,
|
||||||
Objects_Control *the_object,
|
Objects_Control *the_object,
|
||||||
const char *name
|
const char *name
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
bool _Objects_Set_name(
|
Status_Control _Objects_Set_name(
|
||||||
const Objects_Information *information,
|
const Objects_Information *information,
|
||||||
Objects_Control *the_object,
|
Objects_Control *the_object,
|
||||||
const char *name
|
const char *name
|
||||||
@@ -38,7 +38,7 @@ bool _Objects_Set_name(
|
|||||||
length = strnlen( name, information->name_length );
|
length = strnlen( name, information->name_length );
|
||||||
dup = _Workspace_String_duplicate( name, length );
|
dup = _Workspace_String_duplicate( name, length );
|
||||||
if ( dup == NULL ) {
|
if ( dup == NULL ) {
|
||||||
return false;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
the_object->name.name_p = dup;
|
the_object->name.name_p = dup;
|
||||||
@@ -60,5 +60,5 @@ bool _Objects_Set_name(
|
|||||||
_Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );
|
_Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return STATUS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static rtems_task Init(
|
|||||||
Objects_Control *the_object;
|
Objects_Control *the_object;
|
||||||
char name[64];
|
char name[64];
|
||||||
size_t name_len;
|
size_t name_len;
|
||||||
bool bc;
|
Status_Control status;
|
||||||
|
|
||||||
TEST_BEGIN();
|
TEST_BEGIN();
|
||||||
|
|
||||||
@@ -70,12 +70,12 @@ static rtems_task Init(
|
|||||||
puts( "INIT - _Objects_Set_name fails - out of memory" );
|
puts( "INIT - _Objects_Set_name fails - out of memory" );
|
||||||
rtems_workspace_greedy_allocate( NULL, 0 );
|
rtems_workspace_greedy_allocate( NULL, 0 );
|
||||||
|
|
||||||
bc = _Objects_Set_name(
|
status = _Objects_Set_name(
|
||||||
&Test_Information,
|
&Test_Information,
|
||||||
&_Thread_Get_executing()->Object,
|
&_Thread_Get_executing()->Object,
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
rtems_test_assert( bc == false );
|
rtems_test_assert( status == STATUS_NO_MEMORY );
|
||||||
|
|
||||||
TEST_END();
|
TEST_END();
|
||||||
rtems_test_exit(0);
|
rtems_test_exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user