clang-tidy: do not use else after return

Found with readability-else-after-return

Easier to read.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-10-05 03:13:29 -07:00 committed by Frediano Ziglio
parent 944dc8662e
commit fc9ca6c71a
14 changed files with 84 additions and 91 deletions

View File

@ -142,9 +142,8 @@ static bool is_bitmap_lossy(DisplayChannelClient *dcc, SpiceImage *image, SpiceR
if (dcc_pixmap_cache_hit(dcc, image->descriptor.id, &is_hit_lossy)) {
out_data->type = BITMAP_DATA_TYPE_CACHE;
return is_hit_lossy;
} else {
out_data->type = BITMAP_DATA_TYPE_BITMAP_TO_CACHE;
}
out_data->type = BITMAP_DATA_TYPE_BITMAP_TO_CACHE;
} else {
out_data->type = BITMAP_DATA_TYPE_BITMAP;
}
@ -166,10 +165,9 @@ static bool is_brush_lossy(DisplayChannelClient *dcc, SpiceBrush *brush,
if (brush->type == SPICE_BRUSH_TYPE_PATTERN) {
return is_bitmap_lossy(dcc, brush->u.pattern.pat, NULL,
out_data);
} else {
out_data->type = BITMAP_DATA_TYPE_INVALID;
return FALSE;
}
out_data->type = BITMAP_DATA_TYPE_INVALID;
return FALSE;
}
static RedChannelClient::Pipe::iterator get_pipe_tail(RedChannelClient::Pipe& pipe)
@ -388,11 +386,9 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
stat_inc_counter(display->priv->cache_hits_counter, 1);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_CACHE;
} else {
pixmap_cache_unlocked_set_lossy(dcc->priv->pixmap_cache, simage->descriptor.id,
FALSE);
image.descriptor.flags |= SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME;
}
pixmap_cache_unlocked_set_lossy(dcc->priv->pixmap_cache, simage->descriptor.id, FALSE);
image.descriptor.flags |= SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME;
}
}
@ -460,27 +456,23 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
}
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_BITMAP;
} else {
red_display_add_image_to_pixmap_cache(dcc, simage, &image,
comp_send_data.is_lossy);
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
spice_assert(bitmap_palette_out == NULL);
marshaller_add_compressed(m, comp_send_data.comp_buf,
comp_send_data.comp_buf_size);
if (lzplt_palette_out && comp_send_data.lzplt_palette) {
spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
spice_assert(!comp_send_data.is_lossy || can_lossy);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return (comp_send_data.is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY :
FILL_BITS_TYPE_COMPRESS_LOSSLESS);
}
break;
red_display_add_image_to_pixmap_cache(dcc, simage, &image, comp_send_data.is_lossy);
spice_marshall_Image(m, &image, &bitmap_palette_out, &lzplt_palette_out);
spice_assert(bitmap_palette_out == NULL);
marshaller_add_compressed(m, comp_send_data.comp_buf,
comp_send_data.comp_buf_size);
if (lzplt_palette_out && comp_send_data.lzplt_palette) {
spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
spice_assert(!comp_send_data.is_lossy || can_lossy);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return (comp_send_data.is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY :
FILL_BITS_TYPE_COMPRESS_LOSSLESS);
}
case SPICE_IMAGE_TYPE_QUIC:
red_display_add_image_to_pixmap_cache(dcc, simage, &image, FALSE);

View File

@ -882,7 +882,8 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
* on to the next one. */
now = ring_next(ring, now);
continue;
} else if (sibling->type != TREE_ITEM_TYPE_SHADOW) {
}
if (sibling->type != TREE_ITEM_TYPE_SHADOW) {
/* there is an overlap between the two regions */
/* NOTE: Shadow types represent a source region for a COPY_BITS
* operation, they don't represent a region that will be drawn.

View File

@ -264,9 +264,9 @@ static inline int __get_pixels_num(LzImageType image_type, unsigned int num_line
{
if (IS_IMAGE_TYPE_RGB[image_type]) {
return num_lines * stride / RGB_BYTES_PER_PIXEL[image_type];
} else {
return num_lines * stride * PLT_PIXELS_PER_BYTE[image_type];
}
return num_lines * stride * PLT_PIXELS_PER_BYTE[image_type];
}
static void __glz_dictionary_window_segs_realloc(SharedDictionary *dict)

View File

@ -115,12 +115,14 @@ uint8_t *MainChannelClient::alloc_recv_buf(uint16_t type, uint32_t size)
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
RedChannel *channel = get_channel();
return reds_get_agent_data_buffer(channel->get_server(), this, size);
} else if (size > sizeof(priv->recv_buf)) {
}
if (size > sizeof(priv->recv_buf)) {
/* message too large, caller will log a message and close the connection */
return NULL;
} else {
return priv->recv_buf;
}
return priv->recv_buf;
}
void MainChannelClient::release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg)

View File

@ -258,20 +258,19 @@ int MainChannel::migrate_connect(RedsMigSpice *new_mig_target, int try_seamless)
if (!try_seamless) {
return main_channel_connect_semi_seamless(this);
} else {
RedChannelClient *rcc;
GList *clients = get_clients();
/* just test the first one */
rcc = (RedChannelClient*) g_list_nth_data(clients, 0);
if (!rcc->test_remote_cap(SPICE_MAIN_CAP_SEAMLESS_MIGRATE)) {
return main_channel_connect_semi_seamless(this);
} else {
return main_channel_connect_seamless(this);
}
}
RedChannelClient *rcc;
GList *clients = get_clients();
/* just test the first one */
rcc = (RedChannelClient*) g_list_nth_data(clients, 0);
if (!rcc->test_remote_cap(SPICE_MAIN_CAP_SEAMLESS_MIGRATE)) {
return main_channel_connect_semi_seamless(this);
}
return main_channel_connect_seamless(this);
}
void MainChannel::migrate_cancel_wait()

View File

@ -1020,9 +1020,8 @@ static void mjpeg_encoder_decrease_bit_rate(MJpegEncoder *encoder)
if (now - rate_control->warmup_start_time < MJPEG_WARMUP_TIME) {
spice_debug("during warmup. ignoring");
return;
} else {
rate_control->warmup_start_time = 0;
}
rate_control->warmup_start_time = 0;
}
if (bit_rate_info->num_enc_frames > MJPEG_BIT_RATE_EVAL_MIN_NUM_FRAMES ||

View File

@ -1003,9 +1003,11 @@ static int red_peer_receive(RedStream *stream, uint8_t *buf, uint32_t size)
spice_assert(now == -1);
if (errno == EAGAIN) {
break;
} else if (errno == EINTR) {
}
if (errno == EINTR) {
continue;
} else if (errno != EPIPE) {
}
if (errno != EPIPE) {
g_warning("%s", strerror(errno));
}
return -1;
@ -1214,7 +1216,8 @@ void RedChannelClientPrivate::handle_pong(SpiceMsgPing *ping)
if (latency_monitor.state == PING_STATE_WARMUP) {
latency_monitor.state = PING_STATE_LATENCY;
return;
} else if (latency_monitor.state != PING_STATE_LATENCY) {
}
if (latency_monitor.state != PING_STATE_LATENCY) {
spice_warning("unexpected");
return;
}
@ -1631,10 +1634,9 @@ bool RedChannelClient::wait_outgoing_item(int64_t timeout)
if (blocked) {
spice_warning("timeout");
return FALSE;
} else {
spice_assert(no_item_being_sent());
return TRUE;
}
spice_assert(no_item_being_sent());
return TRUE;
}
bool RedChannelClient::no_item_being_sent() const

View File

@ -510,10 +510,10 @@ bool RedChannel::wait_all_sent(int64_t timeout)
max_pipe_size, blocked);
red_channel_disconnect_if_pending_send(this);
return FALSE;
} else {
spice_assert(red_channel_no_item_being_sent(this));
return TRUE;
}
spice_assert(red_channel_no_item_being_sent(this));
return TRUE;
}
RedsState* RedChannel::get_server()

View File

@ -1095,9 +1095,8 @@ static QXLPHYSICAL red_replay_drawable(SpiceReplay *replay, uint32_t flags)
}
if (flags & QXL_COMMAND_FLAG_COMPAT) {
return QXLPHYSICAL_FROM_PTR(red_replay_compat_drawable(replay, flags));
} else {
return QXLPHYSICAL_FROM_PTR(red_replay_native_drawable(replay, flags));
}
return QXLPHYSICAL_FROM_PTR(red_replay_native_drawable(replay, flags));
}
static QXLUpdateCmd *red_replay_update_cmd(SpiceReplay *replay)

View File

@ -262,9 +262,8 @@ bool red_stream_set_auto_flush(RedStream *s, bool auto_flush)
if (socket_set_cork(s->socket, 1)) {
s->priv->use_cork = false;
return false;
} else {
s->priv->corked = true;
}
s->priv->corked = true;
} else if (s->priv->corked) {
socket_set_cork(s->socket, 0);
s->priv->corked = false;
@ -532,9 +531,8 @@ RedStreamSslStatus red_stream_ssl_accept(RedStream *stream)
ssl_error == SSL_ERROR_WANT_WRITE)) {
if (ssl_error == SSL_ERROR_WANT_READ) {
return RED_STREAM_SSL_STATUS_WAIT_FOR_READ;
} else {
return RED_STREAM_SSL_STATUS_WAIT_FOR_WRITE;
}
return RED_STREAM_SSL_STATUS_WAIT_FOR_WRITE;
}
red_dump_openssl_errors();

View File

@ -4368,9 +4368,8 @@ static int calc_compression_level(RedsState *reds)
if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
(spice_server_get_image_compression(reds) != SPICE_IMAGE_COMPRESSION_QUIC)) {
return 0;
} else {
return 1;
}
return 1;
}
void reds_on_ic_change(RedsState *reds)

View File

@ -497,9 +497,9 @@ static int snd_playback_send_ctl(PlaybackChannelClient *playback_client)
if ((client->client_active = client->active)) {
return snd_playback_send_start(playback_client);
} else {
return snd_playback_send_stop(playback_client);
}
return snd_playback_send_stop(playback_client);
}
static bool snd_record_send_start(RecordChannelClient *record_client)
@ -536,9 +536,9 @@ static int snd_record_send_ctl(RecordChannelClient *record_client)
if ((client->client_active = client->active)) {
return snd_record_send_start(record_client);
} else {
return snd_record_send_stop(record_client);
}
return snd_record_send_stop(record_client);
}
static bool snd_record_send_volume(RecordChannelClient *record_client)

View File

@ -87,9 +87,9 @@ BitmapGradualType bitmap_get_graduality_level(SpiceBitmap *bitmap)
if (score < GRADUAL_MEDIUM_SCORE_TH) {
return BITMAP_GRADUAL_MEDIUM;
} else {
return BITMAP_GRADUAL_LOW;
}
return BITMAP_GRADUAL_LOW;
}
int bitmap_has_extra_stride(SpiceBitmap *bitmap)
@ -97,25 +97,26 @@ int bitmap_has_extra_stride(SpiceBitmap *bitmap)
spice_assert(bitmap);
if (bitmap_fmt_is_rgb(bitmap->format)) {
return ((bitmap->x * bitmap_fmt_get_bytes_per_pixel(bitmap->format)) < bitmap->stride);
} else {
switch (bitmap->format) {
case SPICE_BITMAP_FMT_8BIT:
return (bitmap->x < bitmap->stride);
case SPICE_BITMAP_FMT_4BIT_BE:
case SPICE_BITMAP_FMT_4BIT_LE: {
int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1;
return bytes_width < bitmap->stride;
}
case SPICE_BITMAP_FMT_1BIT_BE:
case SPICE_BITMAP_FMT_1BIT_LE: {
int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3;
return bytes_width < bitmap->stride;
}
default:
spice_error("invalid image type %u", bitmap->format);
return 0;
}
}
switch (bitmap->format) {
case SPICE_BITMAP_FMT_8BIT:
return (bitmap->x < bitmap->stride);
case SPICE_BITMAP_FMT_4BIT_BE:
case SPICE_BITMAP_FMT_4BIT_LE: {
int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1;
return bytes_width < bitmap->stride;
}
case SPICE_BITMAP_FMT_1BIT_BE:
case SPICE_BITMAP_FMT_1BIT_LE: {
int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3;
return bytes_width < bitmap->stride;
}
default:
spice_error("invalid image type %u", bitmap->format);
return 0;
}
return 0;
}

View File

@ -369,7 +369,8 @@ int websocket_read(RedsWebSocket *ws, uint8_t *buf, size_t size, unsigned *flags
websocket_clear_frame(frame);
send_pending_data(ws);
return 0;
} else if (frame->type == BINARY_FRAME || frame->type == TEXT_FRAME) {
}
if (frame->type == BINARY_FRAME || frame->type == TEXT_FRAME) {
rc = 0;
if (frame->expected_len > frame->relayed) {
rc = ws->raw_read(ws->raw_stream, buf,