[Cluster-devel] cluster/cman/qdisk disk.c proc.c

pcaulfield at sourceware.org pcaulfield at sourceware.org
Tue Sep 11 12:38:10 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-09-11 12:38:09

Modified files:
	cman/qdisk     : disk.c proc.c 

Log message:
	Allow it to build with -O2

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/disk.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/proc.c.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- cluster/cman/qdisk/disk.c	2006/06/23 16:05:33	1.4
+++ cluster/cman/qdisk/disk.c	2007/09/11 12:38:08	1.5
@@ -377,7 +377,7 @@
 static int
 diskRawRead(int fd, char *buf, int len)
 {
-	char *alignedBuf;
+	void *alignedBuf;
 	int readret;
 	int extraLength;
 	int readlen;
@@ -447,7 +447,7 @@
 static int
 diskRawWrite(int fd, char *buf, int len)
 {
-	char *alignedBuf;
+	void *alignedBuf;
 	int ret;
 	int extraLength;
 	int writelen;
@@ -546,6 +546,7 @@
 int
 qdisk_read(int fd, __off64_t offset, void *buf, int count)
 {
+	void *hdrbuf;
 	shared_header_t *hdrp;
 	char *data;
 	size_t total;
@@ -563,14 +564,15 @@
 	if (total % 512) 
 		total = total + (512 * !!(total % 512)) - (total % 512);
 
-	hdrp = NULL;
-	rv = posix_memalign((void **)&hdrp, sysconf(_SC_PAGESIZE), total);
+	hdrbuf = NULL;
+	rv = posix_memalign((void **)&hdrbuf, sysconf(_SC_PAGESIZE), total);
 	if (rv < 0)
 		return -1;
 
-	if (hdrp == NULL) 
+	if (hdrbuf == NULL) 
 		return -1;
 
+	hdrp = (shared_header_t *)hdrbuf;
 	data = (char *)hdrp + sizeof(shared_header_t);
 
 	rv = diskRawReadShadow(fd, offset, (char *)hdrp, total);
@@ -588,7 +590,7 @@
 		       count - hdrp->h_length);
 	}
 
-	free(hdrp);
+	free(hdrbuf);
 	return count;
 }
 
@@ -597,6 +599,7 @@
 qdisk_write(int fd, __off64_t offset, const void *buf, int count)
 {
 	size_t maxsize;
+	void *hdrbuf;
 	shared_header_t *hdrp;
 	char *data;
 	size_t total = 0, rv = -1, psz = 512; //sysconf(_SC_PAGESIZE);
@@ -621,12 +624,13 @@
 	if (total % psz) 
 		total = total + (psz * !!(total % psz)) - (total % psz);
 
-	hdrp = NULL;
-	rv = posix_memalign((void **)&hdrp, sysconf(_SC_PAGESIZE), total);
+	hdrbuf = NULL;
+	rv = posix_memalign((void **)&hdrbuf, sysconf(_SC_PAGESIZE), total);
 	if (rv < 0) {
 		perror("posix_memalign");
 		return -1;
 	}
+	hdrp = (shared_header_t *)hdrbuf;
 
 	/* 
 	 * Copy the data into our new buffer
@@ -650,7 +654,7 @@
 	if (rv == -1)
 		perror("diskRawWriteShadow");
 	
-	free((char *)hdrp);
+	free(hdrbuf);
 	if (rv == -1)
 		return -1;
 	return count;
--- cluster/cman/qdisk/proc.c	2006/06/23 16:05:33	1.2
+++ cluster/cman/qdisk/proc.c	2007/09/11 12:38:08	1.3
@@ -100,11 +100,12 @@
 				continue;
 
 			if (print) {
+				time_t timestamp = qh.qh_timestamp;
 				printf("%s:\n", realdev);
 				printf("\tMagic:   %08x\n", qh.qh_magic);
 				printf("\tLabel:   %s\n", qh.qh_cluster);
 				printf("\tCreated: %s",
-				       ctime((time_t *)&qh.qh_timestamp));
+				       ctime((time_t *)&timestamp));
 				printf("\tHost:    %s\n\n", qh.qh_updatehost);
 			}
 




More information about the Cluster-devel mailing list