提交 db8894f2 编写于 作者: H Harsh Prateek Bora 提交者: Stefan Hajnoczi

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: NHarsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 fd82f015
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册