commit 5a2f3c85b7baf5c5d920b8579ad3178b26592366
Author: FRIGN <[email protected]>
Date:   Thu Jun 5 11:28:08 2014 +0100

    Bring back some C89/C90 elements
    
    dmesg: don't use VLAs
    getty, su: no need to use compound literals

diff --git a/dmesg.c b/dmesg.c
index c60c503..b90d9ac 100644
--- a/dmesg.c
+++ b/dmesg.c
@@ -80,12 +80,13 @@ static int
 dmesg_show(int fd, const void *buf, size_t n)
 {
        int last = '
';
-       char newbuf[n], *q = newbuf;
+       char *newbuf, *q;
        const char *p = buf;
        ssize_t r;
        size_t i;
 
-       memset(newbuf, 0, n);
+       newbuf = calloc(n, sizeof(char));
+       q = newbuf;
        for (i = 0; i < n; ) {
                if (last == '
' && p[i] == '<') {
                        i += 2;
@@ -97,6 +98,7 @@ dmesg_show(int fd, const void *buf, size_t n)
                last = p[i++];
        }
        r = write(fd, newbuf, n);
+       free(newbuf);
        if(r < 0 || (size_t)r != n)
                return -1;
        if (last != '
')
diff --git a/getty.c b/getty.c
index 3a580ad..6c0af00 100644
--- a/getty.c
+++ b/getty.c
@@ -109,5 +109,5 @@ main(int argc, char *argv[])
                eprintf("login name cannot start with '-'
");
        if (logname[0] == '

Reply via email to