Bug 1615083
| Summary: | generate_file_traditional() needlessly memset an array before writing into it | ||
|---|---|---|---|
| Product: | [Community] GlusterFS | Reporter: | Yaniv Kaul <ykaul> |
| Component: | stripe | Assignee: | bugs <bugs> |
| Status: | CLOSED EOL | QA Contact: | |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | mainline | CC: | bugs |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-09-18 08:38:33 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Not planning to work any more on the component: https://lists.gluster.org/pipermail/gluster-users/2018-July/034400.html |
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.