[sheepdog] [PATCH 2/3] dog: remove redundant memset
MORITA Kazutaka
morita.kazutaka at gmail.com
Tue Sep 3 17:03:00 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
dog/common.c | 1 -
dog/trace.c | 6 ++----
dog/vdi.c | 9 ++++++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dog/common.c b/dog/common.c
index 6c45056..ce022ed 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -154,7 +154,6 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
oid = vid_to_vdi_oid(nr);
- memset(&i, 0, sizeof(i));
ret = sd_read_object(oid, &i, SD_INODE_HEADER_SIZE, 0, true);
if (ret != SD_RES_SUCCESS) {
sd_err("Failed to read inode header");
diff --git a/dog/trace.c b/dog/trace.c
index 7c57c7d..33a2513 100644
--- a/dog/trace.c
+++ b/dog/trace.c
@@ -80,7 +80,7 @@ static int trace_read_buffer(void)
struct sd_req hdr;
struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
#define TRACE_BUF_LEN (1024 * 1024 * 20)
- char *buf = xzalloc(TRACE_BUF_LEN);
+ char *buf = xmalloc(TRACE_BUF_LEN);
tfd = open(tracefile, O_CREAT | O_RDWR | O_APPEND | O_TRUNC, 0644);
if (tfd < 0) {
@@ -105,10 +105,8 @@ read_buffer:
}
xwrite(tfd, buf, rsp->data_length);
- if (rsp->data_length == TRACE_BUF_LEN) {
- memset(buf, 0, TRACE_BUF_LEN);
+ if (rsp->data_length == TRACE_BUF_LEN)
goto read_buffer;
- }
free(buf);
return EXIT_SUCCESS;
diff --git a/dog/vdi.c b/dog/vdi.c
index e8f1ce2..211de16 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -614,6 +614,8 @@ static int vdi_clone(int argc, char **argv)
max_idx = count_data_objs(inode);
for (idx = 0; idx < max_idx; idx++) {
+ size_t size;
+
vdi_show_progress(idx * SD_DATA_OBJ_SIZE, inode->vdi_size);
if (inode->data_vdi_id[idx]) {
oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
@@ -622,12 +624,13 @@ static int vdi_clone(int argc, char **argv)
ret = EXIT_FAILURE;
goto out;
}
+ size = SD_DATA_OBJ_SIZE;
} else
- memset(buf, 0, SD_DATA_OBJ_SIZE);
+ size = 0;
oid = vid_to_data_oid(new_vid, idx);
- ret = sd_write_object(oid, 0, buf, SD_DATA_OBJ_SIZE, 0, 0,
- inode->nr_copies, true, true);
+ ret = sd_write_object(oid, 0, buf, size, 0, 0, inode->nr_copies,
+ true, true);
if (ret != SD_RES_SUCCESS) {
ret = EXIT_FAILURE;
goto out;
--
1.7.9.5
More information about the sheepdog
mailing list