Opened 14 years ago
Closed 14 years ago
Last modified 14 years ago
#10478 closed Patch - Bug Fix (fixed)
Commercial flagging array initialization issue
| Reported by: | Owned by: | cpinkham | |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.25 |
| Component: | MythTV - Mythcommflag | Version: | Master Head |
| Severity: | medium | Keywords: | |
| Cc: | Ticket locked: | no |
Description
clang detected in mythtv/programs/mythcommflag/ClassicCommDetector.cpp a warning of the form "warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it?" from the following code fragment:
memset(sc_histogram, 0, sizeof(sc_histogram));
My guess from reading the code is that the intent was to zero the entire array (and not just the size of the pointer) more or less as:
memset(sc_histogram, 0, sizeof(*sc_histogram)*(seconds+1));
(patch attached)
However, depending on what memory was allocated (and what its state was) this could substantially change (improve/worsen) commercial detection results. I presume that the SME for commercial flagging needs to carefully evaluate with their test cases the results of this proposed change.
Thanks.
Gary
Attachments (1)
Change History (5)
by , 14 years ago
| Attachment: | ClassicCommDetector_cpp.diff added |
|---|
comment:1 by , 14 years ago
| Component: | MythTV - General → MythTV - Mythcommflag |
|---|---|
| Milestone: | unknown → 0.25 |
| Owner: | set to |
| Version: | Unspecified → Master Head |
comment:2 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:3 by , 14 years ago
The patch as modified still will only zero the first int of sc_histogram due to the (presumably) extra sizeof operand.
Did you perhaps mean to write:
memset(sc_histogram, 0, (seconds+1)*sizeof(int));
rather than:
memset(sc_histogram, 0, sizeof((seconds+1)*sizeof(int)));
comment:4 by , 14 years ago
Fix a stupid brain-o
Thanks again to Gary for finding this.
Refs #10478
Branch: master Changeset: 4c93463cabb5f26ab2ae773b355b3860895c1563

Fix initialization of histograms
Based on a patch from Gary Buhrmaster <gary.buhrmaster@…>
Fixes #10478