diff options
author | Miles Bader <miles@gnu.org> | 1995-04-23 20:07:53 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1995-04-23 20:07:53 +0000 |
commit | 9818c608a0b62ff31018d8c348d383fdbf7585b0 (patch) | |
tree | 7ca0a7be04963707d2c19dc2f9b7a53a0a6db311 | |
parent | 2b67bbae80a24b8f6dcdd0f26d872465e2727cc1 (diff) |
(_find_device, add_device, remove_device): Remove the LEN parameter and
the incorrectly computed value which was shadowing it, both of which are the
wrong thing anyway.
-rw-r--r-- | login/utmp.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/login/utmp.c b/login/utmp.c index e92d678f..3a83a278 100644 --- a/login/utmp.c +++ b/login/utmp.c @@ -56,22 +56,24 @@ static int devices_alloced = 0; /* ---------------------------------------------------------------- */ /* If NAME is in the global DEVICES vector, return a pointer to it in - DEVICES, otherwise return NULL. LEN should be the length of NAME. */ + DEVICES, otherwise return NULL. */ static char * -_find_device(char *name, int len) +_find_device(char *name) { - int len = strlen(name); char *dev = devices; int left = devices_len; while (left > 0) - if (strcmp(name, dev) == 0) - return dev; - else - { - dev += len; - left -= len; - } + { + if (strcmp(name, dev) == 0) + return dev; + else + { + int skip = strlen (dev) + 1; + dev += skip; + left -= skip; + } + } return 0; } @@ -83,7 +85,7 @@ add_device(char *name) { int len = strlen(name) + 1; - if (!_find_device(name, len)) + if (!_find_device(name)) { if (len + devices_len > devices_alloced) { @@ -107,11 +109,11 @@ add_device(char *name) static void remove_device(char *name) { - int len = strlen(name) + 1; - char *dev = _find_device(name, len); + char *dev = _find_device(name); if (dev) { + int len = strlen(name) + 1; int tail_len = devices_len - ((dev - devices) + len); if (tail_len > 0) bcopy(dev + len, dev, tail_len); |