summaryrefslogtreecommitdiffstats
path: root/lib/consoles.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-09 09:52:35 +0100
committerKarel Zak2012-11-09 09:52:35 +0100
commit6c7c1eaf2a3372347852aeeb00f95907b0e1a4ba (patch)
treeb32faf73972c921a522f6cbfb947568a7e83d1bc /lib/consoles.c
parentlib/consoles: remove global variable initcp (diff)
downloadkernel-qcow2-util-linux-6c7c1eaf2a3372347852aeeb00f95907b0e1a4ba.tar.gz
kernel-qcow2-util-linux-6c7c1eaf2a3372347852aeeb00f95907b0e1a4ba.tar.xz
kernel-qcow2-util-linux-6c7c1eaf2a3372347852aeeb00f95907b0e1a4ba.zip
lib/consolas: remove global variable concount, fix linked list
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/consoles.c')
-rw-r--r--lib/consoles.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/consoles.c b/lib/consoles.c
index bc7c039bd..b304e37a9 100644
--- a/lib/consoles.c
+++ b/lib/consoles.c
@@ -176,9 +176,6 @@ char* scandev(DIR *dir, dev_t comparedev)
* initialize its default values, and append it to
* the global linked list.
*/
-
-static int concount; /* Counter for console IDs */
-
static
#ifdef __GNUC__
__attribute__((__nonnull__,__hot__))
@@ -192,26 +189,28 @@ void consalloc(char * name)
.parity = 0
};
struct console *restrict tail;
-
+ struct console *last;
if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct console))) != 0)
perror("memory allocation");
+ for (last = consoles; last && last->next; last = last->next);
+
tail->next = NULL;
tail->tty = name;
tail->file = (FILE*)0;
tail->flags = 0;
tail->fd = -1;
- tail->id = concount++;
+ tail->id = last ? last->id + 1 : 0;
tail->pid = 0;
memset(&tail->tio, 0, sizeof(tail->tio));
memcpy(&tail->cp, &initcp, sizeof(struct chardata));
- if (!consoles)
+ if (!last)
consoles = tail;
else
- consoles->next = tail;
+ last->next = tail;
}
/*