[PATCH 4/5] setterm: function screendump coding style fixed

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

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 term-utils/setterm.c |  121 +++++++++++++++++++++++++-------------------------
 1 files changed, 61 insertions(+), 60 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index 3ec9dde..7ed25e6 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -1157,68 +1157,69 @@ perform_sequence(int vcterm) {
 }
 
 static void
-screendump(int vcnum, FILE *F) {
-    char infile[MAXPATHLEN];
-    unsigned char header[4];
-    unsigned int rows, cols;
-    int fd, i, j;
-    char *inbuf, *outbuf, *p, *q;
-
-    sprintf(infile, "/dev/vcsa%d", vcnum);
-    fd = open(infile, O_RDONLY);
-    if (fd < 0 && vcnum == 0) {
-	/* vcsa0 is often called vcsa */
-	sprintf(infile, "/dev/vcsa");
-	fd = open(infile, O_RDONLY);
-    }
-    if (fd < 0) {
-	/* try devfs name - for zero vcnum just /dev/vcc/a */
-	/* some gcc's warn for %.u - add 0 */
-	sprintf(infile, "/dev/vcc/a%.0u", vcnum);
-	fd = open(infile, O_RDONLY);
-    }
-    if (fd < 0) {
+screendump(int vcnum, FILE * F)
+{
+	char infile[MAXPATHLEN];
+	unsigned char header[4];
+	unsigned int rows, cols;
+	int fd, i, j;
+	char *inbuf, *outbuf, *p, *q;
+
 	sprintf(infile, "/dev/vcsa%d", vcnum);
-	goto read_error;
-    }
-    if (read(fd, header, 4) != 4)
-	goto read_error;
-    rows = header[0];
-    cols = header[1];
-    if (rows * cols == 0)
-        goto read_error;
-    inbuf = malloc(rows*cols*2);
-    outbuf = malloc(rows*(cols+1));
-    if(!inbuf || !outbuf) {
-	fputs(_("Out of memory"), stderr);
-	goto error;
-    }
-    if (read(fd, inbuf, rows*cols*2) != rows*cols*2)
-	    goto read_error;
-    p = inbuf;
-    q = outbuf;
-    for(i=0; i<rows; i++) {
-	for(j=0; j<cols; j++) {
-	    *q++ = *p;
-	    p += 2;
+	fd = open(infile, O_RDONLY);
+	if (fd < 0 && vcnum == 0) {
+		/* vcsa0 is often called vcsa */
+		sprintf(infile, "/dev/vcsa");
+		fd = open(infile, O_RDONLY);
+	}
+	if (fd < 0) {
+		/* try devfs name - for zero vcnum just /dev/vcc/a */
+		/* some gcc's warn for %.u - add 0 */
+		sprintf(infile, "/dev/vcc/a%.0u", vcnum);
+		fd = open(infile, O_RDONLY);
+	}
+	if (fd < 0) {
+		sprintf(infile, "/dev/vcsa%d", vcnum);
+		goto read_error;
+	}
+	if (read(fd, header, 4) != 4)
+		goto read_error;
+	rows = header[0];
+	cols = header[1];
+	if (rows * cols == 0)
+		goto read_error;
+	inbuf = malloc(rows * cols * 2);
+	outbuf = malloc(rows * (cols + 1));
+	if (!inbuf || !outbuf) {
+		fputs(_("Out of memory"), stderr);
+		goto error;
+	}
+	if (read(fd, inbuf, rows * cols * 2) != rows * cols * 2)
+		goto read_error;
+	p = inbuf;
+	q = outbuf;
+	for (i = 0; i < rows; i++) {
+		for (j = 0; j < cols; j++) {
+			*q++ = *p;
+			p += 2;
+		}
+		while (j-- > 0 && q[-1] == ' ')
+			q--;
+		*q++ = '\n';
+	}
+	if (fwrite(outbuf, 1, q - outbuf, F) != q - outbuf) {
+		warnx(_("Error writing screendump"));
+		goto error;
 	}
-	while(j-- > 0 && q[-1] == ' ')
-	  q--;
-	*q++ = '\n';
-    }
-    if (fwrite(outbuf, 1, q-outbuf, F) != q-outbuf) {
-	warnx(_("Error writing screendump"));
-	goto error;
-    }
-    close(fd);
-    return;
-
-read_error:
-    warnx(_("Couldn't read %s"), infile);
-error:
-    if (fd >= 0)
-	    close(fd);
-    exit(EXIT_FAILURE);
+	close(fd);
+	return;
+
+      read_error:
+	warnx(_("Couldn't read %s"), infile);
+      error:
+	if (fd >= 0)
+		close(fd);
+	exit(EXIT_FAILURE);
 }
 
 int
-- 
1.7.4.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux