mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
*: Use fprintf between qemu_log_trylock/unlock
Inside qemu_log, we perform qemu_log_trylock/unlock, which need not be done if we have already performed the lock beforehand. Always check the result of qemu_log_trylock -- only checking qemu_loglevel_mask races with the acquisition of the lock on the logfile. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-10-richard.henderson@linaro.org>
This commit is contained in:
parent
6fef222971
commit
78b548583e
9 changed files with 162 additions and 132 deletions
|
@ -77,18 +77,21 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg)
|
|||
{
|
||||
int i;
|
||||
FILE *logfile = qemu_log_trylock();
|
||||
qemu_log("[cansocketcan]: %03X [%01d] %s %s",
|
||||
msg->can_id & QEMU_CAN_EFF_MASK,
|
||||
msg->can_dlc,
|
||||
msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF",
|
||||
msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT");
|
||||
|
||||
for (i = 0; i < msg->can_dlc; i++) {
|
||||
qemu_log(" %02X", msg->data[i]);
|
||||
if (logfile) {
|
||||
fprintf(logfile, "[cansocketcan]: %03X [%01d] %s %s",
|
||||
msg->can_id & QEMU_CAN_EFF_MASK,
|
||||
msg->can_dlc,
|
||||
msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF",
|
||||
msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT");
|
||||
|
||||
for (i = 0; i < msg->can_dlc; i++) {
|
||||
fprintf(logfile, " %02X", msg->data[i]);
|
||||
}
|
||||
fprintf(logfile, "\n");
|
||||
qemu_log_flush();
|
||||
qemu_log_unlock(logfile);
|
||||
}
|
||||
qemu_log("\n");
|
||||
qemu_log_flush();
|
||||
qemu_log_unlock(logfile);
|
||||
}
|
||||
|
||||
static void can_host_socketcan_read(void *opaque)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue