mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
chardev/char-mux: make boolean bit check instead of find_next_bit()
This patch simplifies (and makes less confusing) bit checks by replacing `find_next_bit()` calls with boolean AND operation. Resolves: Coverity CID 1563776 Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Reviewed-by: "Marc-André Lureau" <marcandre.lureau@redhat.com> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com> Cc: qemu-devel@nongnu.org Message-ID: <20241129103239.464061-3-r.peniaev@gmail.com>
This commit is contained in:
parent
188df56eab
commit
e6214fd6d4
1 changed files with 4 additions and 7 deletions
|
@ -336,15 +336,12 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
|
||||||
|
|
||||||
bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
|
bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
|
||||||
{
|
{
|
||||||
unsigned int bit;
|
if (!(d->mux_bitset & (1ul << tag))) {
|
||||||
|
|
||||||
bit = find_next_bit(&d->mux_bitset, MAX_MUX, tag);
|
|
||||||
if (bit != tag) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->mux_bitset &= ~(1ul << bit);
|
d->mux_bitset &= ~(1ul << tag);
|
||||||
d->backends[bit] = NULL;
|
d->backends[tag] = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +350,7 @@ void mux_set_focus(Chardev *chr, unsigned int focus)
|
||||||
{
|
{
|
||||||
MuxChardev *d = MUX_CHARDEV(chr);
|
MuxChardev *d = MUX_CHARDEV(chr);
|
||||||
|
|
||||||
assert(find_next_bit(&d->mux_bitset, MAX_MUX, focus) == focus);
|
assert(d->mux_bitset & (1ul << focus));
|
||||||
|
|
||||||
if (d->focus != -1) {
|
if (d->focus != -1) {
|
||||||
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
|
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue