Changeset 7a2c30f in rtems


Ignore:
Timestamp:
Nov 17, 2014, 2:58:26 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7840b66
Parents:
bac3d6d
git-author:
Sebastian Huber <sebastian.huber@…> (11/17/14 14:58:26)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/20/14 09:30:24)
Message:

shell: Simplify rtems_shell_add_cmd_struct()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/shell/shell_cmdset.c

    rbac3d6d r7a2c30f  
    109109)
    110110{
    111   rtems_shell_cmd_t *shell_pvt;
    112 
    113   shell_pvt = rtems_shell_first_cmd;
    114   while (shell_pvt) {
    115     if (strcmp(shell_pvt->name, shell_cmd->name) == 0)
     111  rtems_shell_cmd_t **next_ptr = &rtems_shell_first_cmd;
     112  rtems_shell_cmd_t *existing;
     113
     114  /*
     115   * Iterate through all commands and check if a command with this name is
     116   * already present.
     117   */
     118  while ((existing = *next_ptr) != NULL) {
     119    if (strcmp(existing->name, shell_cmd->name) == 0)
    116120      return NULL;
    117     shell_pvt = shell_pvt->next;
    118   }
    119 
    120   if ( !rtems_shell_first_cmd ) {
    121     rtems_shell_first_cmd = shell_cmd;
    122   } else {
    123     shell_pvt = rtems_shell_first_cmd;
    124     while (shell_pvt->next)
    125       shell_pvt = shell_pvt->next;
    126     shell_pvt->next = shell_cmd;
    127   }
     121
     122    next_ptr = &existing->next;
     123  }
     124
     125  /* Append */
     126  *next_ptr = shell_cmd;
     127
    128128  rtems_shell_add_topic( shell_cmd->topic );
     129
    129130  return shell_cmd;
    130131}
Note: See TracChangeset for help on using the changeset viewer.