stat-file: Protect flags field with atomic operation

Coverity complaint that this field should be protected by
a mutex as other accesses are with the mutex locked.
Use atomic operation. Not in an hot path in any case.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-12-12 17:20:39 +00:00
parent fc1005718f
commit bde8ef5a4e

View File

@ -190,7 +190,7 @@ stat_file_add_counter(RedStatFile *stat_file, StatNodeRef parent, const char *na
return NULL;
}
node = &stat_file->stat->nodes[ref];
node->flags |= SPICE_STAT_NODE_FLAG_VALUE;
__sync_or_and_fetch(&node->flags, SPICE_STAT_NODE_FLAG_VALUE);
return &node->value;
}