sysvinit-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] bootlogd: Use consistent indentation


From: Alexander Vickberg
Subject: [PATCH 1/2] bootlogd: Use consistent indentation
Date: Wed, 15 Dec 2021 17:43:39 +0100

This commit contain no code changes.

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
---
 src/bootlogd.c | 148 ++++++++++++++++++++++++-------------------------
 1 file changed, 71 insertions(+), 77 deletions(-)

diff --git a/src/bootlogd.c b/src/bootlogd.c
index 78e4c81..10d7c0e 100644
--- a/src/bootlogd.c
+++ b/src/bootlogd.c
@@ -105,7 +105,6 @@ void handler(int sig)
        got_signal = sig;
 }
 
-
 /*
  *     Scan /dev and find the device name.
  */
@@ -140,7 +139,7 @@ static int findtty(char *res, const char *startdir, int 
rlen, dev_t dev)
                        snprintf(path, rlen, "%s/%s", startdir, ent->d_name);
                        r = findtty(res, path, rlen, dev);
                        free(path);
-                       if (0 == r) { 
+                       if (0 == r) {
                                closedir(dir);
                                chdir(olddir);
                                return 0;
@@ -170,8 +169,6 @@ static int findtty(char *res, const char *startdir, int 
rlen, dev_t dev)
 }
 */
 
-
-
 /*
  *     For some reason, openpty() in glibc sometimes doesn't
  *     work at boot-time. It must be a bug with old-style pty
@@ -309,7 +306,7 @@ int consolenames(struct real_cons *cons, int max_consoles)
                close(fd);
        }
        if (didmount) umount("/proc");
-                
+
        if (n < 0) return 0;
 
        /*
@@ -333,7 +330,7 @@ int consolenames(struct real_cons *cons, int max_consoles)
                                                goto dontuse;
                                        }
                                }
-                       
+
                        num_consoles++;
                        if (num_consoles >= max_consoles) {
                                break;
@@ -351,7 +348,7 @@ dontuse:
         *      guess the default console.
         */
        for (n = 0; defcons[n]; n++)
-               if (isconsole(defcons[n], cons[0].name, sizeof(cons[0].name))) 
+               if (isconsole(defcons[n], cons[0].name, sizeof(cons[0].name)))
                        return 1;
 
        fprintf(stderr, "bootlogd: cannot deduce real console device\n");
@@ -359,7 +356,6 @@ dontuse:
        return 0;
 }
 
-
 /*
  *     Write data and make sure it's on disk.
  */
@@ -386,49 +382,49 @@ void writelog(FILE *fp, unsigned char *ptr, int len, int 
print_escape_characters
 
                /* remove escape sequences, but do it in a way that allows us 
to stop
                 * in the middle in case the string was cut off */
-                if (! print_escape_characters)
-                {
-                    if (inside_esc == 1) {
-                       /* first '[' is special because if we encounter it 
again, it should be considered the final byte */
-                       if (*ptr == '[') {
-                               /* multi char sequence */
-                               ignore = 1;
-                               inside_esc = 2;
-                       } else {
-                               /* single char sequence */
-                               if (*ptr >= 64 && *ptr <= 95) {
+               if (! print_escape_characters)
+               {
+                       if (inside_esc == 1) {
+                               /* first '[' is special because if we encounter 
it again, it should be considered the final byte */
+                               if (*ptr == '[') {
+                                       /* multi char sequence */
                                        ignore = 1;
-                               }
-                               inside_esc = 0;
-                       }
-                    } else if (inside_esc == 2) {
-                       switch (*ptr) {
-                               case '0' ... '9': /* intermediate chars of 
escape sequence */
-                               case ';':
-                               case 32 ... 47:
-                                       if (inside_esc) {
+                                       inside_esc = 2;
+                               } else {
+                                       /* single char sequence */
+                                       if (*ptr >= 64 && *ptr <= 95) {
                                                ignore = 1;
                                        }
-                                       break;
-                               case 64 ... 126: /* final char of escape 
sequence */
-                                       if (inside_esc) {
+                                       inside_esc = 0;
+                               }
+                       } else if (inside_esc == 2) {
+                               switch (*ptr) {
+                                       case '0' ... '9': /* intermediate chars 
of escape sequence */
+                                       case ';':
+                                       case 32 ... 47:
+                                               if (inside_esc) {
+                                                       ignore = 1;
+                                               }
+                                               break;
+                                       case 64 ... 126: /* final char of 
escape sequence */
+                                               if (inside_esc) {
+                                                       ignore = 1;
+                                                       inside_esc = 0;
+                                               }
+                                               break;
+                               }
+                       } else {
+                               switch (*ptr) {
+                                       case '\r':
                                                ignore = 1;
-                                               inside_esc = 0;
-                                       }
-                                       break;
-                        }
-                    } else {
-                       switch (*ptr) {
-                               case '\r':
-                                       ignore = 1;
-                                       break;
-                               case 27: /* ESC */
-                                       ignore = 1;
-                                       inside_esc = 1;
-                                       break;
+                                               break;
+                                       case 27: /* ESC */
+                                               ignore = 1;
+                                               inside_esc = 1;
+                                               break;
+                               }
                        }
-                    }
-                }     /* end of if we should filter escape characters */
+               } /* end of if we should filter escape characters */
 
                if (!ignore) {
                        fwrite(ptr, sizeof(char), 1, fp);
@@ -446,10 +442,8 @@ void writelog(FILE *fp, unsigned char *ptr, int len, int 
print_escape_characters
        outptr += len;
        if (outptr >= endptr)
                outptr = ringbuf;
-
 }
 
-
 /*
  *     Print usage message and exit.
  */
@@ -515,7 +509,7 @@ int main(int argc, char **argv)
        int             considx;
        struct real_cons cons[MAX_CONSOLES];
        int             num_consoles, consoles_left;
-        int             print_escape_sequence = 0;
+       int             print_escape_sequence = 0;
        fp = NULL;
        logfile = LOGFILE;
        pidfile = NULL;
@@ -542,9 +536,9 @@ int main(int argc, char **argv)
                case 'd':
                        dontfork = 1;
                        break;
-                case 'e':
-                        print_escape_sequence = 1;
-                        break;
+               case 'e':
+                       print_escape_sequence = 1;
+                       break;
                case 's':
                        syncalot = 1;
                        break;
@@ -564,7 +558,7 @@ int main(int argc, char **argv)
        /*
         *      Open console device directly.
         */
-        /*
+       /*
        if (consolename(realcons, sizeof(realcons)) < 0)
                return 1;
 
@@ -577,24 +571,24 @@ int main(int argc, char **argv)
                fprintf(stderr, "bootlogd: %s: %s\n", realcons, 
strerror(errno));
                return 1;
        }
-        */
-        if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0)
-                return 1;
-        consoles_left = num_consoles;
-        for (considx = 0; considx < num_consoles; considx++) {
-               if (strcmp(cons[considx].name, "/dev/tty0") == 0)
-                       strcpy(cons[considx].name, "/dev/tty1");
-               if (strcmp(cons[considx].name, "/dev/vc/0") == 0)
-                       strcpy(cons[considx].name, "/dev/vc/1");
-
-               if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) {
-                       fprintf(stderr, "bootlogd: %s: %s\n", 
-                                cons[considx].name, strerror(errno));
-                       consoles_left--;
-               }
-        }
-        if (!consoles_left)
-               return 1;
+       */
+       if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0)
+               return 1;
+       consoles_left = num_consoles;
+       for (considx = 0; considx < num_consoles; considx++) {
+               if (strcmp(cons[considx].name, "/dev/tty0") == 0)
+                       strcpy(cons[considx].name, "/dev/tty1");
+               if (strcmp(cons[considx].name, "/dev/vc/0") == 0)
+                       strcpy(cons[considx].name, "/dev/vc/1");
+
+               if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) {
+                       fprintf(stderr, "bootlogd: %s: %s\n",
+                               cons[considx].name, strerror(errno));
+                       consoles_left--;
+               }
+       }
+       if (!consoles_left)
+               return 1;
 
 
        /*
@@ -700,14 +694,14 @@ int main(int argc, char **argv)
                                                        cons[considx].fd,
                                                        cons[considx].name, 
errno);
                                                if (cons[considx].fd >= 0) 
continue;
-                                               /*      
+                                               /*
                                                 *      If this was the last 
console,
                                                 *      generate a fake signal
                                                 */
                                                if (--consoles_left <= 0) 
got_signal = 1;
                                                break;
-                                       }   /* end of while */
-                               }     /* end of going through all consoles */
+                                       } /* end of while */
+                               } /* end of going through all consoles */
 
                                /*
                                 *      Increment buffer position. Handle
@@ -721,8 +715,8 @@ int main(int argc, char **argv)
                                        inptr = ringbuf;
                                if (outptr >= endptr)
                                        outptr = ringbuf;
-                       }       /* end of got data from read */
-               }      /* end of checking select for new data */
+                       } /* end of got data from read */
+               } /* end of checking select for new data */
 
                /*
                 *      Perhaps we need to open the logfile.
@@ -743,7 +737,7 @@ int main(int argc, char **argv)
                        todo = endptr - outptr;
                if (fp && todo)
                        writelog(fp, (unsigned char *)outptr, todo, 
print_escape_sequence);
-       }    /* end of while waiting for signal */
+       } /* end of while waiting for signal */
 
        if (fp) {
                if (!didnl) fputc('\n', fp);
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]