<div dir="ltr">Should rtems_object_set_name() propagate the memory error condition also?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 24, 2020 at 5:52 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
cpukit/include/rtems/score/objectimpl.h | 14 ++++++++------<br>
cpukit/score/src/objectsetname.c | 6 +++---<br>
testsuites/psxtests/psxobj01/init.c | 6 +++---<br>
3 files changed, 14 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h<br>
index 32387594f2..a963396d65 100644<br>
--- a/cpukit/include/rtems/score/objectimpl.h<br>
+++ b/cpukit/include/rtems/score/objectimpl.h<br>
@@ -25,6 +25,7 @@<br>
#include <rtems/score/apimutex.h><br>
#include <rtems/score/assert.h><br>
#include <rtems/score/isrlock.h><br>
+#include <rtems/score/status.h><br>
#include <rtems/score/sysstate.h><br>
#include <rtems/score/threaddispatch.h><br>
<br>
@@ -463,14 +464,15 @@ size_t _Objects_Name_to_string(<br>
* or up to the first four characters of the string based upon<br>
* whether this object class uses strings for names.<br>
*<br>
- * @param information points to the object information structure<br>
- * @param[out] the_object is the object to operate upon<br>
- * @param name is a pointer to the name to use<br>
+ * @param information points to the object information.<br>
+ * @param[out] the_object is the object to operate upon.<br>
+ * @param name is a pointer to the name to use.<br>
*<br>
- * @retval true The operation succeeded.<br>
- * @retval false The operation failed.<br>
+ * @retval STATUS_SUCCESSFUL The operation succeeded.<br>
+ *<br>
+ * @retval STATUS_NO_MEMORY There was no memory available to duplicate the name.<br>
*/<br>
-bool _Objects_Set_name(<br>
+Status_Control _Objects_Set_name(<br>
const Objects_Information *information,<br>
Objects_Control *the_object,<br>
const char *name<br>
diff --git a/cpukit/score/src/objectsetname.c b/cpukit/score/src/objectsetname.c<br>
index 0808ab87af..4d85332711 100644<br>
--- a/cpukit/score/src/objectsetname.c<br>
+++ b/cpukit/score/src/objectsetname.c<br>
@@ -24,7 +24,7 @@<br>
<br>
#include <string.h><br>
<br>
-bool _Objects_Set_name(<br>
+Status_Control _Objects_Set_name(<br>
const Objects_Information *information,<br>
Objects_Control *the_object,<br>
const char *name<br>
@@ -37,7 +37,7 @@ bool _Objects_Set_name(<br>
length = strnlen( name, information->name_length );<br>
dup = _Workspace_String_duplicate( name, length );<br>
if ( dup == NULL ) {<br>
- return false;<br>
+ return STATUS_NO_MEMORY;<br>
}<br>
<br>
the_object->name.name_p = dup;<br>
@@ -59,5 +59,5 @@ bool _Objects_Set_name(<br>
_Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );<br>
}<br>
<br>
- return true;<br>
+ return STATUS_SUCCESSFUL;<br>
}<br>
diff --git a/testsuites/psxtests/psxobj01/init.c b/testsuites/psxtests/psxobj01/init.c<br>
index ba1e327ea5..fef749b3e9 100644<br>
--- a/testsuites/psxtests/psxobj01/init.c<br>
+++ b/testsuites/psxtests/psxobj01/init.c<br>
@@ -37,7 +37,7 @@ static rtems_task Init(<br>
Objects_Control *the_object;<br>
char name[64];<br>
size_t name_len;<br>
- bool bc;<br>
+ Status_Control status;<br>
<br>
TEST_BEGIN();<br>
<br>
@@ -70,12 +70,12 @@ static rtems_task Init(<br>
puts( "INIT - _Objects_Set_name fails - out of memory" );<br>
rtems_workspace_greedy_allocate( NULL, 0 );<br>
<br>
- bc = _Objects_Set_name(<br>
+ status = _Objects_Set_name(<br>
&Test_Information,<br>
&_Thread_Get_executing()->Object,<br>
name<br>
);<br>
- rtems_test_assert( bc == false );<br>
+ rtems_test_assert( status == STATUS_NO_MEMORY );<br>
<br>
TEST_END();<br>
rtems_test_exit(0);<br>
-- <br>
2.26.2<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>