From b98d399f3c4f7fc19a80a7f12503f0b4226c59dc Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 13 Dec 2011 12:56:53 +0000 Subject: 2011-12-13 Sebastian Huber * posix/src/mqueuenametoid.c, posix/src/semaphorenametoid.c: Removed files. * posix/src/psxnametoid.c: New file. * posix/Makefile.am: Reflect changes above. * posix/include/rtems/posix/config.h: Fixed integer types. * posix/include/rtems/posix/posixapi.h: Declare _POSIX_Name_to_id(). * posix/include/rtems/posix/mqueue.h, posix/inline/rtems/posix/mqueue.inl: Changed parameter of _POSIX_Message_queue_Create_support(). _POSIX_Message_queue_Name_to_id() is now inline. * posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl: Changed parameter of _POSIX_Semaphore_Create_support(). _POSIX_Semaphore_Name_to_id() is now inline. * posix/src/mqueuecreatesupp.c, posix/src/semaphorecreatesupp.c: Use _Workspace_String_duplicate(). * posix/src/mqueuesendsupp.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/semunlink.c: Update due to API changes. --- cpukit/posix/src/mqueuecreatesupp.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'cpukit/posix/src/mqueuecreatesupp.c') diff --git a/cpukit/posix/src/mqueuecreatesupp.c b/cpukit/posix/src/mqueuecreatesupp.c index bad22b536d..5941137d3e 100644 --- a/cpukit/posix/src/mqueuecreatesupp.c +++ b/cpukit/posix/src/mqueuecreatesupp.c @@ -42,9 +42,6 @@ #include #include -/* pure ANSI mode does not have this prototype */ -size_t strnlen(const char *, size_t); - /* * _POSIX_Message_queue_Create_support * @@ -54,6 +51,7 @@ size_t strnlen(const char *, size_t); int _POSIX_Message_queue_Create_support( const char *name_arg, + size_t name_len, int pshared, struct mq_attr *attr_ptr, POSIX_Message_queue_Control **message_queue @@ -63,9 +61,7 @@ int _POSIX_Message_queue_Create_support( CORE_message_queue_Attributes *the_mq_attr; struct mq_attr attr; char *name; - size_t n; - n = strnlen( name_arg, NAME_MAX ); /* length of name has already been validated */ _Thread_Disable_dispatch(); @@ -99,22 +95,21 @@ int _POSIX_Message_queue_Create_support( rtems_set_errno_and_return_minus_one( ENFILE ); } - the_mq->process_shared = pshared; - the_mq->named = true; - the_mq->open_count = 1; - the_mq->linked = true; - /* * Make a copy of the user's string for name just in case it was * dynamically constructed. */ - name = _Workspace_Allocate(n+1); - if (!name) { + name = _Workspace_String_duplicate( name_arg, name_len ); + if ( !name ) { _POSIX_Message_queue_Free( the_mq ); _Thread_Enable_dispatch(); rtems_set_errno_and_return_minus_one( ENOMEM ); } - strncpy( name, name_arg, n+1 ); + + the_mq->process_shared = pshared; + the_mq->named = true; + the_mq->open_count = 1; + the_mq->linked = true; /* * NOTE: That thread blocking discipline should be based on the -- cgit v1.2.3