[Bugs] [Bug 1615083] New: generate_file_traditional() needlessly memset an array before writing into it
bugzilla at redhat.com
bugzilla at redhat.com
Sun Aug 12 07:28:20 UTC 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1615083
Bug ID: 1615083
Summary: generate_file_traditional() needlessly memset an array
before writing into it
Product: GlusterFS
Version: mainline
Component: stripe
Severity: medium
Assignee: bugs at gluster.org
Reporter: ykaul at redhat.com
CC: bugs at gluster.org
Description of problem:
See the following code:
max_ret = 0;
for (i = 0; i < finfo->stripe_count; i++) {
memset(buf[i], 0, 4096); <---- here
ret = read(finfo->fd[i], buf[i], 4096);
if (ret > max_ret)
max_ret = ret;
}
for (i = 0; i < max_ret; i++)
for (j = 0; j < finfo->stripe_count; j++)
newbuf[i] |= buf[j][i];
write(target, newbuf, max_ret);
There is no need to memset the whole 4K, we are reading from the file, writing
as much as needed to it.
You should memset (4096 - ret) after reading.
--
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
More information about the Bugs
mailing list