diff --git a/fs/inode/fs_inodebasename.c b/fs/inode/fs_inodebasename.c index 6398d9854c2..13a4486ba57 100644 --- a/fs/inode/fs_inodebasename.c +++ b/fs/inode/fs_inodebasename.c @@ -41,32 +41,16 @@ #include "inode/inode.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: inode_nextname + * Name: inode_basename * * Description: - * Given a path with node names separated by '/', return the next node - * name. + * Given a path with node names separated by '/', return name of last + * segment in the path. "" * ****************************************************************************/ @@ -84,13 +68,19 @@ FAR const char *inode_basename(FAR const char *name) * previous name that we saved is the basename. */ - if (*name == '\0') + if (name == NULL || *name == '\0') { - return basename; + /* Break out of the loop with basename pointer to the final + * segment of the path. + */ + + break; } + + /* Set basename to point to the remainder of the path */ + + basename = name; } - /* We won't get here */ - - return NULL; + return basename; } diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h index 2eb624bf702..cfd0feb19d8 100644 --- a/include/nuttx/semaphore.h +++ b/include/nuttx/semaphore.h @@ -60,12 +60,12 @@ struct inode; struct nsem_inode_s { - /* Inode payload unique to named semaphores. ns_sem must appear first in - * this structure in order to support casting between type sem_t and + /* Inode payload unique to named semaphores. ns_inode must appear first + * in this structure in order to support casting between type sem_t and * types of struct nsem_inode_s. */ - sem_t ns_sem; /* The semaphore */ FAR struct inode *ns_inode; /* Containing inode */ + sem_t ns_sem; /* The semaphore */ }; #endif