Module: xenomai-forge
Branch: next
Commit: 04bb757e0c81078b636b59a96a6f527a44ff0cb8
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=04bb757e0c81078b636b59a96a6f527a44ff0cb8

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Feb 19 15:04:05 2014 +0100

cobalt/registry: allow NULL key for anonymous objects

---

 include/cobalt/kernel/registry.h |    2 +-
 kernel/cobalt/registry.c         |   15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/kernel/registry.h b/include/cobalt/kernel/registry.h
index db99140..5bcac4a 100644
--- a/include/cobalt/kernel/registry.h
+++ b/include/cobalt/kernel/registry.h
@@ -34,7 +34,7 @@ struct xnpnode;
 
 struct xnobject {
        void *objaddr;
-       const char *key;          /* !< Hash key. */
+       const char *key;          /* !< Hash key. May be NULL if anonynous. */
        struct xnsynch safesynch; /* !< Safe synchronization object. */
        unsigned long safelock;   /* !< Safe lock count. */
        unsigned long cstamp;             /* !< Creation stamp. */
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index aae2c1f..21938b6 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -590,8 +590,8 @@ static inline int registry_wakeup_sleepers(const char *key)
  * be indexed and later retrieved in the registry. Since it is assumed
  * that such key is stored into the registered object, it will *not*
  * be copied but only kept by reference in the registry. Pass an empty
- * string if the object shall only occupy a registry slot
- * for handle-based lookups.
+ * or NULL string if the object shall only occupy a registry slot for
+ * handle-based lookups.
  *
  * @param objaddr An opaque pointer to the object to index by @a
  * key.
@@ -609,8 +609,8 @@ static inline int registry_wakeup_sleepers(const char *key)
  *
  * @return 0 is returned upon success. Otherwise:
  *
- * - -EINVAL is returned if @a objaddr are NULL, or if @a key constains
- * an invalid '/' character.
+ * - -EINVAL is returned if @a objaddr is NULL, or if @a key is
+ * non-NULL and contains an invalid '/' character.
  *
  * - -ENOMEM is returned if the system fails to get enough dynamic
  * memory from the global real-time heap in order to register the
@@ -627,7 +627,7 @@ int xnregistry_enter(const char *key, void *objaddr,
        spl_t s;
        int ret;
 
-       if (key == NULL || objaddr == NULL || strchr(key, '/'))
+       if (objaddr == NULL || (key != NULL && strchr(key, '/')))
                return -EINVAL;
 
        xnlock_get_irqsave(&nklock, s);
@@ -646,7 +646,7 @@ int xnregistry_enter(const char *key, void *objaddr,
 #ifdef CONFIG_XENO_OPT_VFILE
        object->pnode = NULL;
 #endif
-       if (*key == '\0') {
+       if (key == NULL || *key == '\0') {
                object->key = NULL;
                *phandle = object - registry_obj_slots;
                ret = 0;
@@ -862,6 +862,9 @@ int xnregistry_unlink(const char *key)
        int ret = 0;
        spl_t s;
 
+       if (key == NULL)
+               return -EINVAL;
+
        xnlock_get_irqsave(&nklock, s);
 
        object = registry_hash_find(key);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to