All of lore.kernel.org
 help / color / mirror / Atom feed
From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
Date: 20 Dec 2010 13:57:20 -0000	[thread overview]
Message-ID: <20101220135720.17858.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac at sourceware.org	2010-12-20 13:57:19

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
	
	Use dm_zalloc to obtain zeroed memory block.
	Use dm_free for dm_ allocated memory blocks.
	Test close() for error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1845&r2=1.1846
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26

--- LVM2/WHATS_NEW	2010/12/20 13:53:10	1.1845
+++ LVM2/WHATS_NEW	2010/12/20 13:57:19	1.1846
@@ -1,5 +1,6 @@
 Version 2.02.79 -  
 ===================================
+  Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
   Add checks for allocation errors in config node clonning.
   Fix error path if regex engine cannot be created in _build_matcher().
   Use char* arithmetic in target_version(), _process_all(), _targets().
--- LVM2/daemons/cmirrord/functions.c	2010/10/26 10:14:41	1.25
+++ LVM2/daemons/cmirrord/functions.c	2010/12/20 13:57:19	1.26
@@ -429,13 +429,12 @@
 			block_on_error = 1;
 	}
 
-	lc = malloc(sizeof(*lc));
+	lc = dm_zalloc(sizeof(*lc));
 	if (!lc) {
 		LOG_ERROR("Unable to allocate cluster log context");
 		r = -ENOMEM;
 		goto fail;
 	}
-	memset(lc, 0, sizeof(*lc));
 
 	lc->region_size = region_size;
 	lc->region_count = region_count;
@@ -453,7 +452,7 @@
 	    (duplicate = get_pending_log(lc->uuid, lc->luid))) {
 		LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
 			  SHORT_UUID(lc->uuid), lc->luid);
-		free(lc);
+		dm_free(lc);
 		return -EINVAL;
 	}
 
@@ -511,15 +510,13 @@
 	return 0;
 fail:
 	if (lc) {
-		if (lc->clean_bits)
-			free(lc->clean_bits);
-		if (lc->sync_bits)
-			free(lc->sync_bits);
-		if (lc->disk_buffer)
-			free(lc->disk_buffer);
-		if (lc->disk_fd >= 0)
-			close(lc->disk_fd);
-		free(lc);
+		if (lc->disk_fd >= 0 && close(lc->disk_fd))
+			LOG_ERROR("Close device error, %s: %s",
+				  disk_path, strerror(errno));
+		free(lc->disk_buffer);
+		dm_free(lc->sync_bits);
+		dm_free(lc->clean_bits);
+		dm_free(lc);
 	}
 	return r;
 }
@@ -634,9 +631,9 @@
 		close(lc->disk_fd);
 	if (lc->disk_buffer)
 		free(lc->disk_buffer);
-	free(lc->clean_bits);
-	free(lc->sync_bits);
-	free(lc);
+	dm_free(lc->clean_bits);
+	dm_free(lc->sync_bits);
+	dm_free(lc);
 
 	return 0;
 }



             reply	other threads:[~2010-12-20 13:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 13:57 zkabelac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-08 11:34 LVM2 ./WHATS_NEW daemons/cmirrord/functions.c zkabelac
2011-09-06 18:24 zkabelac
2010-08-30 18:37 jbrassow
2010-08-17 23:56 jbrassow
2010-08-04 18:18 jbrassow
2010-06-18 20:58 jbrassow
2010-01-15 18:48 jbrassow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101220135720.17858.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.