Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2014 00:19:11 GMT
From:      def@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r269995 - soc2013/def/crashdump-head/sbin/savecore
Message-ID:  <201406250019.s5P0JBst028215@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: def
Date: Wed Jun 25 00:19:10 2014
New Revision: 269995
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269995

Log:
  Style.

Modified:
  soc2013/def/crashdump-head/sbin/savecore/dumpfile.c
  soc2013/def/crashdump-head/sbin/savecore/dumpfile.h
  soc2013/def/crashdump-head/sbin/savecore/savecore.c

Modified: soc2013/def/crashdump-head/sbin/savecore/dumpfile.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/dumpfile.c	Tue Jun 24 23:08:48 2014	(r269994)
+++ soc2013/def/crashdump-head/sbin/savecore/dumpfile.c	Wed Jun 25 00:19:10 2014	(r269995)
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "dumpfile.h"
 
 int
@@ -10,17 +11,13 @@
 	FILE *fp;
 
 	fp = fopen(keyname, "w");
-
 	if (fp == NULL)
 		return (-1);
-
-	if (fwrite(fd->ciphertext, 1, KERNELDUMP_CIPHERTEXT_SIZE, fp)
-		!= KERNELDUMP_CIPHERTEXT_SIZE) {
+	if (fwrite(fd->ciphertext, 1, KERNELDUMP_CIPHERTEXT_SIZE, fp) !=
+	    KERNELDUMP_CIPHERTEXT_SIZE) {
 		fclose(fp);
-
 		return (-1);
 	}
-
 	fclose(fp);
 
 	return (0);
@@ -28,7 +25,7 @@
 
 FILE *
 dopen(const char *fname, const char *mode, const char *keyname,
-	const struct kerneldumpheader *h)
+    const struct kerneldumpheader *h)
 {
 	dumpFile *fd;
 	FILE *fp;
@@ -38,19 +35,15 @@
 		return (NULL);
 
 	fp = fopen(fname, mode);
-
 	if (fp == NULL)
 		return (NULL);
-
 	fd = (dumpFile *)malloc(sizeof(dumpFile));
 	fd->fp = fp;
 	fd->buf_used = 0;
-
 	memcpy(fd->ciphertext, h->ciphertext, KERNELDUMP_CIPHERTEXT_SIZE);
 
 	if (save_key_for(fd, keyname)) {
 		free(fd);
-
 		return (NULL);
 	}
 
@@ -60,11 +53,11 @@
 int
 dwrite(void *cookie, const char *data, int size)
 {
-	dumpFile *fd = (dumpFile *)cookie;
+	dumpFile *fd;
 	int resid, saved;
 
+	fd = (dumpFile *)cookie;
 	saved = 0;
-
 	while (size + fd->buf_used >= DEVBLK_SIZE) {
 		resid = DEVBLK_SIZE - fd->buf_used;
 		memcpy(fd->buf + fd->buf_used, data, resid);
@@ -72,7 +65,6 @@
 
 		if (fwrite(fd->buf, 1, DEVBLK_SIZE, fd->fp) != DEVBLK_SIZE) {
 			fd->buf_used -= resid;
-
 			return (saved);
 		}
 
@@ -81,7 +73,6 @@
 		fd->buf_used = 0;
 		saved += resid;
 	}
-
 	if (size > 0) {
 		memcpy(fd->buf + fd->buf_used, data, size);
 		fd->buf_used += size;
@@ -94,23 +85,19 @@
 int
 dclose(void *cookie)
 {
-	dumpFile *fd = (dumpFile *)cookie;
+	dumpFile *fd;
 	int error;
 
+	fd = (dumpFile *)cookie;
 	if (fd->buf_used > 0) {
 		if (fwrite(fd->buf, 1, fd->buf_used, fd->fp) != 1)
 			return (0);
-
 		fd->buf_used = 0;
 	}
-
 	error = fclose(fd->fp);
-
 	if (error < 0)
 		return (error);
-
 	free(fd);
 
 	return (error);
 }
-

Modified: soc2013/def/crashdump-head/sbin/savecore/dumpfile.h
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/dumpfile.h	Tue Jun 24 23:08:48 2014	(r269994)
+++ soc2013/def/crashdump-head/sbin/savecore/dumpfile.h	Wed Jun 25 00:19:10 2014	(r269995)
@@ -3,19 +3,19 @@
 
 #include <sys/kerneldump.h>
 
-typedef struct _dumpFile {
-	FILE		*fp;
-	char		ciphertext[KERNELDUMP_CIPHERTEXT_SIZE];
 #define	DEVBLK_SIZE	512
-	char		buf[DEVBLK_SIZE];
-	int		buf_used;
+
+typedef struct _dumpFile {
+	FILE	*fp;
+	char	ciphertext[KERNELDUMP_CIPHERTEXT_SIZE];
+	char	buf[DEVBLK_SIZE];
+	int	buf_used;
 } dumpFile;
 
+int save_key_for(dumpFile *fd, const char *keyname);
 FILE *dopen(const char *fname, const char *mode, const char *keyname,
-	const struct kerneldumpheader *h);
+    const struct kerneldumpheader *h);
 int dwrite(void *cookie, const char *data, int size);
 int dclose(void *cookie);
-int save_key_for(dumpFile *fd, const char *keyname);
 
 #endif /* _DUMPFILE_H */
-

Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/savecore.c	Tue Jun 24 23:08:48 2014	(r269994)
+++ soc2013/def/crashdump-head/sbin/savecore/savecore.c	Wed Jun 25 00:19:10 2014	(r269995)
@@ -80,6 +80,7 @@
 #include <syslog.h>
 #include <time.h>
 #include <unistd.h>
+
 #include "dumpfile.h"
 
 /* The size of the buffer used for I/O. */
@@ -89,7 +90,7 @@
 #define	STATUS_GOOD	1
 #define	STATUS_UNKNOWN	2
 
-static int checkfor, compress, clear, force, isencrypted, keep, verbose;	/* flags */
+static int checkfor, compress, clear, encrypted, force, keep, verbose;	/* flags */
 static int nfound, nsaved, nerr;			/* statistics */
 static int maxdumps;
 
@@ -314,7 +315,7 @@
 		}
 		if (compress) {
 			nw = fwrite(buf, 1, wl, fp);
-		} else if (isencrypted) {
+		} else if (encrypted) {
 			nw = fwrite(buf, 1, wl, fp);
 		} else {
 			for (nw = 0; nw < nr; nw = he) {
@@ -631,7 +632,7 @@
 		snprintf(corename, sizeof(corename), "%s.%d.gz",
 		    istextdump ? "textdump.tar" : "vmcore", bounds);
 		fp = zopen(corename, "w");
-	} else if (isencrypted) {
+	} else if (encrypted) {
 		snprintf(corename, sizeof(corename), "%s.%d",
 		    istextdump ? "textdump.tar" : "vmcore", bounds);
 		snprintf(keyname, sizeof(keyname), "key.%d", bounds);
@@ -664,7 +665,8 @@
 	fclose(info);
 
 	syslog(LOG_NOTICE, "writing %score to %s/%s",
-	    compress ? "compressed " : (isencrypted ? "encrypted " : ""), savedir, corename);
+	    compress ? "compressed " : (encrypted ? "encrypted " : ""),
+	    savedir, corename);
 
 	if (istextdump) {
 		if (DoTextdumpFile(fd, dumpsize, lasthd, buf, device,
@@ -744,13 +746,13 @@
 	struct fstab *fsp;
 	int i, ch, error;
 
-	checkfor = compress = clear = force = isencrypted = keep = verbose = 0;
+	checkfor = compress = clear = encrypted = force = keep = verbose = 0;
 	nfound = nsaved = nerr = 0;
 
 	openlog("savecore", LOG_PERROR, LOG_DAEMON);
 	signal(SIGINFO, infohandler);
 
-	while ((ch = getopt(argc, argv, "Ccefkm:vz")) != -1)
+	while ((ch = getopt(argc, argv, "Ccfkm:evz")) != -1)
 		switch(ch) {
 		case 'C':
 			checkfor = 1;
@@ -759,7 +761,7 @@
 			clear = 1;
 			break;
 		case 'e':
-			isencrypted = 1;
+			encrypted = 1;
 			break;
 		case 'f':
 			force = 1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406250019.s5P0JBst028215>