Make use of the swap macro and remove unnecessary variable _buf_. This makes the code easier to read and maintain. Also, reduces the stack usage. This code was detected with the help of Coccinelle. Link: http://lkml.kernel.org/r/20180209175316.GA18720@embeddedgus
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1360,8 +1360,6 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) · 1359 unmodified lines | ||
| 1360 | 1360 | void |
| 1361 | 1361 | update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) |
| 1362 | 1362 | { |
| 1363 | − struct ring_buffer *buf; | |
| 1364 | − | |
| 1365 | 1363 | if (tr->stop_count) |
| 1366 | 1364 | return; |
| 1367 | 1365 | |
| @@ -1375,9 +1373,7 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) · 7 unmodified lines | ||
| 1375 | 1373 | |
| 1376 | 1374 | arch_spin_lock(&tr->max_lock); |
| 1377 | 1375 | |
| 1378 | − buf = tr->trace_buffer.buffer; | |
| 1379 | − tr->trace_buffer.buffer = tr->max_buffer.buffer; | |
| 1380 | − tr->max_buffer.buffer = buf; | |
| 1376 | + swap(tr->trace_buffer.buffer, tr->max_buffer.buffer); | |
| 1381 | 1377 | |
| 1382 | 1378 | __update_max_tr(tr, tsk, cpu); |
| 1383 | 1379 | arch_spin_unlock(&tr->max_lock); |