diff options
| author | Harsh Prateek Bora | 2012-07-20 15:22:15 +0200 |
|---|---|---|
| committer | Stefan Hajnoczi | 2012-08-14 11:40:39 +0200 |
| commit | db8894f2090629a2e12b1e7324c4c5c53367e048 (patch) | |
| tree | ab947a4941324c7876c4d3979f3e737e0c6a1eca /trace | |
| parent | trace: drop unused TraceBufferRecord->next_tbuf_idx field (diff) | |
| download | qemu-db8894f2090629a2e12b1e7324c4c5c53367e048.tar.gz qemu-db8894f2090629a2e12b1e7324c4c5c53367e048.tar.xz qemu-db8894f2090629a2e12b1e7324c4c5c53367e048.zip | |
trace: avoid pointer aliasing in trace_record_finish()
Declaring a TraceRecord on the stack works fine. No need for a
uint8_t array and pointer aliasing.
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'trace')
| -rw-r--r-- | trace/simple.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/trace/simple.c b/trace/simple.c index 4fed07f330..8e175ece73 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -269,12 +269,11 @@ static unsigned int write_to_buffer(unsigned int idx, void *dataptr, size_t size void trace_record_finish(TraceBufferRecord *rec) { - uint8_t temp_rec[sizeof(TraceRecord)]; - TraceRecord *record = (TraceRecord *) temp_rec; - read_from_buffer(rec->tbuf_idx, temp_rec, sizeof(TraceRecord)); + TraceRecord record; + read_from_buffer(rec->tbuf_idx, &record, sizeof(TraceRecord)); smp_wmb(); /* write barrier before marking as valid */ - record->event |= TRACE_RECORD_VALID; - write_to_buffer(rec->tbuf_idx, temp_rec, sizeof(TraceRecord)); + record.event |= TRACE_RECORD_VALID; + write_to_buffer(rec->tbuf_idx, &record, sizeof(TraceRecord)); if ((trace_idx - writeout_idx) > TRACE_BUF_FLUSH_THRESHOLD) { flush_trace_file(false); |
