This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - libgfs2: Remove another macro


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=af56981cec36a6d4f813e192821979f5e7f91b68
Commit:        af56981cec36a6d4f813e192821979f5e7f91b68
Parent:        cde167241333b285a48f9de1a46098a8bf902718
Author:        Steven Whitehouse <swhiteho@redhat.com>
AuthorDate:    Mon Jan 26 08:50:30 2009 +0000
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Thu Feb 19 10:59:53 2009 +0100

libgfs2: Remove another macro

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 gfs2/edit/hexedit.h        |   10 ----------
 gfs2/fsck/metawalk.c       |    6 +++++-
 gfs2/libgfs2/buf.c         |    6 +++++-
 gfs2/libgfs2/fs_geometry.c |    6 +++++-
 gfs2/libgfs2/fs_ops.c      |   26 ++++++++++++++++++++------
 gfs2/libgfs2/gfs1.c        |    7 ++++++-
 gfs2/libgfs2/libgfs2.h     |   14 ++------------
 gfs2/mkfs/main_grow.c      |    8 +++++---
 8 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index a3c0830..768a6d6 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -237,16 +237,6 @@ EXTERN enum dsp_mode dmode INIT(HEX_MODE);
 
 /*  Memory macros  */
 
-#define type_zalloc(ptr, type, count) \
-{ \
-  (ptr) = (type *)malloc(sizeof(type) * (count)); \
-  if ((ptr)) \
-    memset((char *)(ptr), 0, sizeof(type) * (count)); \
-  else \
-    die("unable to allocate memory on line %d of file %s\n", \
-	__LINE__, __FILE__); \
-}
-
 #define type_alloc(ptr, type, count) \
 { \
   (ptr) = (type *)malloc(sizeof(type) * (count)); \
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 9915d8d..8006291 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -62,7 +62,11 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
 {
 	struct gfs2_inode *ip, *sysip;
 
-	zalloc(ip, sizeof(struct gfs2_inode));
+	ip = calloc(1, sizeof(struct gfs2_inode));
+	if (ip == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 	gfs2_dinode_in(&ip->i_di, bh->b_data);
 	ip->i_bh = bh;
 	ip->i_sbd = sdp;
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index ee43188..7187492 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -107,7 +107,11 @@ struct gfs2_buffer_head *bget_generic(struct buf_list *bl, uint64_t num,
 		if (bh)
 			return bh;
 	}
-	zalloc(bh, sizeof(struct gfs2_buffer_head) + sdp->bsize);
+	bh = calloc(1, sizeof(struct gfs2_buffer_head) + sdp->bsize);
+	if (bh == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 
 	bh->b_count = 1;
 	bh->b_blocknr = num;
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 3840cd9..5bbb5f0 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -97,7 +97,11 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified)
 
 	log_info("\nNew resource groups:\n");
 	for (; rgrp < nrgrp; rgrp++) {
-		zalloc(rl, sizeof(struct rgrp_list));
+		rl = calloc(1, sizeof(struct rgrp_list));
+		if (rl == NULL) {
+			fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+			exit(-1);
+		}
 
 		if (rgrp) {
 			rl->start = rlast->start + rlast->length;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index ad6b555..29af6d4 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -22,7 +22,11 @@ struct gfs2_inode *inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
 {
 	struct gfs2_inode *ip;
 
-	zalloc(ip, sizeof(struct gfs2_inode));
+	ip = calloc(1, sizeof(struct gfs2_inode));
+	if (ip == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 	gfs2_dinode_in(&ip->i_di, bh->b_data);
 	ip->i_bh = bh;
 	ip->i_sbd = sdp;
@@ -273,8 +277,11 @@ struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block)
 	uint64_t b = block;
 	unsigned int i;
 
-	zalloc(mp, sizeof(struct metapath));
-
+	mp = calloc(1, sizeof(struct metapath));
+	if (mp == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 	for (i = ip->i_di.di_height; i--;)
 		mp->mp_list[i] = do_div(b, sdp->sd_inptrs);
 
@@ -752,8 +759,11 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t index, uint64_t leaf
 
 	start = (index & ~(len - 1));
 
-	zalloc(lp, half_len * sizeof(uint64_t));
-
+	lp = calloc(1, half_len * sizeof(uint64_t));
+	if (lp == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 	count = gfs2_readi(dip, (char *)lp, start * sizeof(uint64_t),
 		      half_len * sizeof(uint64_t));
 	if (count != half_len * sizeof(uint64_t))
@@ -831,7 +841,11 @@ static void dir_double_exhash(struct gfs2_inode *dip)
 	int x;
 	int count;
 
-	zalloc(buf, 3 * sdp->sd_hash_bsize);
+	buf = calloc(1, 3 * sdp->sd_hash_bsize);
+	if (buf == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 
 	for (block = dip->i_di.di_size >> sdp->sd_hash_bsize_shift; block--;) {
 		count = gfs2_readi(dip, (char *)buf,
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index c518e5a..c2ad8de 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -363,7 +363,12 @@ struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
 	struct gfs_dinode gfs1_dinode;
 	struct gfs2_inode *ip;
 
-	zalloc(ip, sizeof(struct gfs2_inode));
+	ip = calloc(1, sizeof(struct gfs2_inode));
+	if (ip == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
+
 	gfs_dinode_in(&gfs1_dinode, bh->b_data);
 	memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
 	       sizeof(struct gfs2_meta_header));
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index c54501c..c04918b 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -48,30 +48,20 @@ static __inline__ __attribute__((deprecated)) void do_lseek(int fd, off_t off)
 	strerror(errno),__LINE__, __FILE__);
 }
 
-static __inline__ __attribute__((deprecated)) void do_read(int fd, char *buf, size_t len)
+static __inline__ __attribute__((deprecated)) void do_read(int fd, void *buf, size_t len)
 {
   if (read(fd, buf, len) < 0)
     die("bad read: %s on line %d of file %s\n",
 	strerror(errno), __LINE__, __FILE__);
 }
 
-static __inline__ __attribute__((deprecated)) void do_write(int fd, const char *buf, size_t len)
+static __inline__ __attribute__((deprecated)) void do_write(int fd, const void *buf, size_t len)
 {
   if (write(fd, buf, len) != len)
     die("bad write: %s on line %d of file %s\n",
 	strerror(errno), __LINE__, __FILE__);
 }
 
-#define zalloc(ptr, size) \
-do { \
-	(ptr) = malloc((size)); \
-	if ((ptr)) \
-		memset((ptr), 0, (size)); \
-	else \
-		die("unable to allocate memory on line %d of file %s\n", \
-		    __LINE__, __FILE__); \
-} while (0)
-
 #define DIV_RU(x, y) (((x) + (y) - 1) / (y))
 
 static __inline__ uint64_t do_div_i(uint64_t *num, unsigned int den)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index e929ebd..f363b54 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -193,9 +193,11 @@ void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
 		rg++;
 	log_info("%d new rindex entries.\n", rg);
 	writelen = rg * sizeof(struct gfs2_rindex);
-	zalloc(buf, writelen);
-	if (!buf)
-		die("Unable to allocate memory for buffers.\n");
+	buf = calloc(1, writelen);
+	if (buf == NULL) {
+		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
+		exit(-1);
+	}
 	/* Now add the new rg entries to the rg index.  Here we     */
 	/* need to use the gfs2 kernel code rather than the libgfs2 */
 	/* code so we have a live update while mounted.             */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]