Bug 452219
Summary: | memset used with constant zero length parameter | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Harald Hoyer <harald> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED WONTFIX | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | low | Docs Contact: | |
Priority: | low | ||
Version: | 9 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2008-06-20 11:07:23 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Harald Hoyer
2008-06-20 10:29:07 UTC
ok, -O2 seems to create the size==0 case. I'm afraid there is nothing we can do about this. If-conversion merges the two size != 0 checks and so at the __warn_memset_zero_len () check size will be constant 0, as the if (size > 0) else branch jumps directly to it. To avoid the warning, just stick the memset under if (size > 0), i.e. if (size > 0) { if ((pt = malloc(size)) == NULL) { fprintf(...); return NULL; } memset(pt, 0, size); } return pt; or better yet just use calloc, that's more efficient anyway in many cases. this code snippet was from cdrtools.. I shall not rewrite it :) |