[Cbe-oss-dev] [PATCH 8/9 v2]MARS: Task get name return null
Yuji Mano
yuji.mano at am.sony.com
Tue Oct 21 13:11:26 EST 2008
This fixes mars_task_get_name function so that if user specified NULL during
task creation, NULL will be returned rather than a pointer to an uninitialized
string array.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
v2:
- remove unecessary check for strlen of name param
src/host/lib/task.c | 2 ++
src/mpu/lib/task.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
--- a/src/host/lib/task.c
+++ b/src/host/lib/task.c
@@ -100,6 +100,8 @@ int mars_task_create(struct mars_context
task->id.workload_id = workload_id;
if (name)
strcpy((char *)task->id.name, name);
+ else
+ task->id.name[0] = 0;
/* initialize the elf parameters */
task->exec_ea = mars_ptr_to_ea((void *)ehdr + phdr->p_offset);
--- a/src/mpu/lib/task.c
+++ b/src/mpu/lib/task.c
@@ -35,6 +35,8 @@
* LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
*/
+#include <stdlib.h>
+
#include "mars/task.h"
#include "mars/task_types.h"
#include "mars/error.h"
@@ -160,5 +162,5 @@ const char *mars_task_get_name(void)
task = (struct mars_task_context *)mars_get_workload();
- return (const char *)task->id.name;
+ return task->id.name[0] ? (const char *)task->id.name : NULL;
}
More information about the cbe-oss-dev
mailing list