clang-tidy: readability-else-after-return
authorColin Clark <colin.clark@cclark.uk>
Sat, 3 Feb 2024 14:48:24 +0000 (14:48 +0000)
committerColin Clark <colin.clark@cclark.uk>
Sat, 3 Feb 2024 14:48:24 +0000 (14:48 +0000)
- Fix warnings identified by this flag
- Remove the exclude from .clang-tidy file

36 files changed:
.clang-tidy
scripts/lua-test.sh
src/bar-gps.cc
src/cache-maint.cc
src/collect-io.cc
src/collect.cc
src/color-man.cc
src/dupe.cc
src/exif-common.cc
src/filedata.cc
src/image-load-gdk.cc
src/image-load-heif.cc
src/image-load-psd.cc
src/image-load-tiff.cc
src/image-overlay.cc
src/image.cc
src/jpeg-parser.cc
src/layout.cc
src/lua.cc
src/metadata.cc
src/misc.cc
src/osd.cc
src/pan-view/pan-view-filter.cc
src/preferences.cc
src/print.cc
src/remote.cc
src/renderer-tiles.cc
src/search.cc
src/slideshow.cc
src/ui-fileops.cc
src/ui-misc.cc
src/ui-tabcomp.cc
src/view-dir-tree.cc
src/view-dir.cc
src/view-file/view-file.cc
src/zonedetect.cc

index af037ae..94f0a7b 100644 (file)
@@ -46,7 +46,6 @@ Checks: >
   -modernize-use-trailing-return-type,
   -performance-no-int-to-ptr,
   -readability-braces-around-statements,
-  -readability-else-after-return,
   -readability-function-cognitive-complexity,
   -readability-identifier-length,
   -readability-implicit-bool-conversion,
index 29bc31b..4e1feb5 100755 (executable)
@@ -26,7 +26,7 @@
 ##
 ## Create a basic image and run all lua built-in functions on it.
 ## The image file and the Lua test file are created within this script.
-set -x
+
 if [ -z "$XDG_CONFIG_HOME" ]
 then
        config_home="$HOME/.config"
index a0d2951..203fa29 100644 (file)
@@ -872,12 +872,14 @@ static gboolean bar_pane_gps_map_keypress_cb(GtkWidget *, GdkEventButton *bevent
                gtk_menu_popup_at_pointer(GTK_MENU(menu), nullptr);
                return TRUE;
                }
-       else if (bevent->button == MOUSE_BUTTON_MIDDLE)
+
+       if (bevent->button == MOUSE_BUTTON_MIDDLE)
                {
                bar_pane_gps_map_centreing(pgd);
                return TRUE;
                }
-       else if (bevent->button == MOUSE_BUTTON_LEFT)
+
+       if (bevent->button == MOUSE_BUTTON_LEFT)
                {
                clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
                geo_coords = g_strdup_printf("%lf %lf",
@@ -891,10 +893,8 @@ static gboolean bar_pane_gps_map_keypress_cb(GtkWidget *, GdkEventButton *bevent
 
                return TRUE;
                }
-       else
-               {
-               return FALSE;
-               }
+
+       return FALSE;
 }
 #endif
 
index f73236d..f7cf7c4 100644 (file)
@@ -765,7 +765,7 @@ static gboolean cache_manager_render_file(CacheOpsData *cd)
 
                return (!success);
                }
-       else if (cd->list_dir)
+       if (cd->list_dir)
                {
                FileData *fd;
 
@@ -1434,7 +1434,7 @@ static gboolean cache_manager_sim_file(CacheOpsData *cd)
 
                return FALSE;
                }
-       else if (cd->list_dir)
+       if (cd->list_dir)
                {
                FileData *fd;
 
index e0c1933..4093734 100644 (file)
@@ -194,12 +194,10 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C
                                g_string_append(extended_filename_buffer, buf);
                                continue;
                                }
-                       else
-                               {
-                               /* end of extended filename found */
-                               g_string_append_len(extended_filename_buffer, buf, p - buf);
-                               reading_extended_filename = FALSE;
-                               }
+
+                       /* end of extended filename found */
+                       g_string_append_len(extended_filename_buffer, buf, p - buf);
+                       reading_extended_filename = FALSE;
                        }
 
                if (extended_filename_buffer->len > 0)
index 61bea6d..e3fd820 100644 (file)
@@ -180,8 +180,8 @@ static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
 
        if (options->file_sort.case_sensitive)
                return strcmp(cia->fd->collate_key_name, cib->fd->collate_key_name);
-       else
-               return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
+
+       return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
 }
 
 GList *collection_list_sort(GList *list, SortType method)
@@ -575,8 +575,8 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
                while (*ptr != '\n' && *ptr != '\0') ptr++;
                if (*ptr == '\0')
                        break;
-               else
-                       while (*ptr == '\n') ptr++;
+
+               while (*ptr == '\n') ptr++;
 
                info = static_cast<CollectInfo *>(g_list_nth_data(cd->list, item_number));
                if (!info) continue;
@@ -1191,7 +1191,8 @@ static void collection_close_save_cb(GenericDialog *gd, gpointer data)
                collection_dialog_save_close(cw->cd);
                return;
                }
-       else if (!collection_save(cw->cd, cw->cd->path))
+
+       if (!collection_save(cw->cd, cw->cd->path))
                {
                gchar *buf;
                buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
index e9be69b..63dacd4 100644 (file)
@@ -724,16 +724,12 @@ static guchar *nclx_to_lcms_profile(const struct heif_color_profile_nclx *nclx,
                        cmsCloseProfile(profile);
                        return static_cast<guchar *>(data);
                        }
-               else
-                       {
-                       cmsCloseProfile(profile);
-                       return nullptr;
-                       }
-               }
-       else
-               {
+
+               cmsCloseProfile(profile);
                return nullptr;
                }
+
+       return nullptr;
 }
 
 guchar *heif_color_profile(FileData *fd, guint *profile_len)
@@ -788,20 +784,18 @@ guchar *heif_color_profile(FileData *fd, guint *profile_len)
 
                return static_cast<guchar *>(data);
                }
-       else
-               {
-               error_code = heif_image_handle_get_nclx_color_profile(handle, &nclxcp);
-               if (error_code.code)
-                       {
-                       log_printf("warning: heif reader error: %s\n", error_code.message);
-                       heif_context_free(ctx);
-                       heif_nclx_color_profile_free(nclxcp);
-                       return nullptr;
-                       }
 
-               profile = nclx_to_lcms_profile(nclxcp, profile_len);
+       error_code = heif_image_handle_get_nclx_color_profile(handle, &nclxcp);
+       if (error_code.code)
+               {
+               log_printf("warning: heif reader error: %s\n", error_code.message);
+               heif_context_free(ctx);
+               heif_nclx_color_profile_free(nclxcp);
+               return nullptr;
                }
 
+       profile = nclx_to_lcms_profile(nclxcp, profile_len);
+
        heif_context_free(ctx);
        heif_nclx_color_profile_free(nclxcp);
 
index 7137347..f03ed75 100644 (file)
@@ -351,7 +351,8 @@ static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdo
 
                        return;
                        }
-               else if (force ||
+
+               if (force ||
                         value == 0.0 ||
                         dw->setup_count == 0 ||
                         dw->setup_time_count == 0 ||
@@ -1509,15 +1510,10 @@ static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble
                                {
                                return TRUE;
                                }
-                       else
-                               {
-                               return FALSE;
-                               }
-                       }
-               else
-                       {
+
                        return FALSE;
                        }
+               return FALSE;
                }
        if (mask & DUPE_MATCH_NAME_CI_CONTENT)
                {
@@ -1531,15 +1527,11 @@ static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble
                                {
                                return TRUE;
                                }
-                       else
-                               {
-                               return FALSE;
-                               }
-                       }
-               else
-                       {
+
                        return FALSE;
                        }
+               return FALSE;
+               
                }
        if (mask & DUPE_MATCH_SIZE)
                {
@@ -1817,10 +1809,8 @@ static gint dupe_match_sort_cb(gconstpointer a, gconstpointer b, gpointer data)
                    {
                        return -1;
                        }
-               else
-                       {
-                       return strcmp(di1->md5sum, di2->md5sum);
-                       }
+
+               return strcmp(di1->md5sum, di2->md5sum);
                }
        if (mask & DUPE_MATCH_DIM)
                {
@@ -2813,14 +2803,12 @@ static gboolean dupe_files_add_queue_cb(gpointer data)
                {
                return TRUE;
                }
-       else
-               {
-               dw->add_files_queue_id = 0;
-               dupe_destroy_list_cache(dw);
-               g_idle_add(dupe_check_start_cb, dw);
-               gtk_widget_set_sensitive(dw->controls_box, TRUE);
-               return FALSE;
-               }
+
+       dw->add_files_queue_id = 0;
+       dupe_destroy_list_cache(dw);
+       g_idle_add(dupe_check_start_cb, dw);
+       gtk_widget_set_sensitive(dw->controls_box, TRUE);
+       return FALSE;
 }
 
 static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
@@ -2881,10 +2869,8 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
                        {
                        return;
                        }
-               else
-                       {
-                       work = work->next;
-                       }
+
+               work = work->next;
                }
 
        if (dw->second_list)
@@ -2897,10 +2883,8 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
                                {
                                return;
                                }
-                       else
-                               {
-                               work = work->next;
-                               }
+
+                       work = work->next;
                        }
                }
 
index 1fcfb6a..8ebc379 100644 (file)
@@ -1213,10 +1213,8 @@ gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat)
                        page_n_of_m = g_strdup_printf("[%d/%d]", fd->page_num + 1, fd->page_total);
                        return page_n_of_m;
                        }
-               else
-                       {
-                       return nullptr;
-                       }
+
+               return nullptr;
                }
        return g_strdup("");
 }
index c990c27..5e032c7 100644 (file)
@@ -332,7 +332,8 @@ static void file_data_set_path(FileData *fd, const gchar *path)
                file_data_set_collate_keys(fd);
                return;
                }
-       else if (strcmp(fd->name, ".") == 0)
+
+       if (strcmp(fd->name, ".") == 0)
                {
                g_free(fd->path);
                fd->path = remove_level_from_path(path);
@@ -2965,11 +2966,11 @@ static gboolean file_data_perform_delete(FileData *fd)
 {
        if (isdir(fd->path) && !islink(fd->path))
                return rmdir_utf8(fd->path);
-       else
-               if (options->file_ops.safe_delete_enable)
-                       return file_util_safe_unlink(fd->path);
-               else
-                       return unlink_file(fd->path);
+
+       if (options->file_ops.safe_delete_enable)
+               return file_util_safe_unlink(fd->path);
+
+       return unlink_file(fd->path);
 }
 
 gboolean file_data_perform_ci(FileData *fd)
index 62e0f33..f532e68 100644 (file)
@@ -35,11 +35,10 @@ static gchar* image_loader_gdk_get_format_name(gpointer loader)
                {
                return gdk_pixbuf_format_get_name(format);
                }
-       else
-               {
-               return nullptr;
-               }
+
+       return nullptr;
 }
+
 static gchar** image_loader_gdk_get_format_mime_types(gpointer loader)
 {
        return gdk_pixbuf_format_get_mime_types(gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader)));
index 0996aff..5abc3c5 100644 (file)
@@ -66,44 +66,42 @@ static gboolean image_loader_heif_load(gpointer loader, const guchar *buf, gsize
                heif_context_free(ctx);
                return FALSE;
                }
-       else
-               {
-               page_total = heif_context_get_number_of_top_level_images(ctx);
-               ld->page_total = page_total;
 
-               std::vector<heif_item_id> IDs(page_total);
+       page_total = heif_context_get_number_of_top_level_images(ctx);
+       ld->page_total = page_total;
+
+       std::vector<heif_item_id> IDs(page_total);
 
-               /* get list of all (top level) image IDs */
-               heif_context_get_list_of_top_level_image_IDs(ctx, IDs.data(), page_total);
+       /* get list of all (top level) image IDs */
+       heif_context_get_list_of_top_level_image_IDs(ctx, IDs.data(), page_total);
 
-               error_code = heif_context_get_image_handle(ctx, IDs[ld->page_num], &handle);
-               if (error_code.code)
-                       {
-                       log_printf("warning:  heif reader error: %s\n", error_code.message);
-                       heif_context_free(ctx);
-                       return FALSE;
-                       }
+       error_code = heif_context_get_image_handle(ctx, IDs[ld->page_num], &handle);
+       if (error_code.code)
+               {
+               log_printf("warning:  heif reader error: %s\n", error_code.message);
+               heif_context_free(ctx);
+               return FALSE;
+               }
 
-               // decode the image and convert colorspace to RGB, saved as 24bit interleaved
-               error_code = heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_24bit, nullptr);
-               if (error_code.code)
-                       {
-                       log_printf("warning: heif reader error: %s\n", error_code.message);
-                       heif_context_free(ctx);
-                       return FALSE;
-                       }
+       // decode the image and convert colorspace to RGB, saved as 24bit interleaved
+       error_code = heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_24bit, nullptr);
+       if (error_code.code)
+               {
+               log_printf("warning: heif reader error: %s\n", error_code.message);
+               heif_context_free(ctx);
+               return FALSE;
+               }
 
-               data = heif_image_get_plane(img, heif_channel_interleaved, &stride);
+       data = heif_image_get_plane(img, heif_channel_interleaved, &stride);
 
-               height = heif_image_get_height(img,heif_channel_interleaved);
-               width = heif_image_get_width(img,heif_channel_interleaved);
-               alpha = heif_image_handle_has_alpha_channel(handle);
-               heif_image_handle_release(handle);
+       height = heif_image_get_height(img,heif_channel_interleaved);
+       width = heif_image_get_width(img,heif_channel_interleaved);
+       alpha = heif_image_handle_has_alpha_channel(handle);
+       heif_image_handle_release(handle);
 
-               ld->pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, alpha, 8, width, height, stride, free_buffer, img);
+       ld->pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, alpha, 8, width, height, stride, free_buffer, img);
 
-               ld->area_updated_cb(loader, 0, 0, width, height, ld->data);
-               }
+       ld->area_updated_cb(loader, 0, 0, width, height, ld->data);
 
        heif_context_free(ctx);
 
index 114f5bd..a26cef2 100644 (file)
@@ -213,16 +213,18 @@ skip_block (PsdContext* context, const guchar** data, guint* size)
                        return FALSE;
                }
        }
-       if (*size < context->bytes_to_skip) {
+
+       if (*size < context->bytes_to_skip)
+               {
                *data += *size;
                context->bytes_to_skip -= *size;
                *size = 0;
                return FALSE;
-       } else {
-               *size -= context->bytes_to_skip;
-               *data += context->bytes_to_skip;
-               return TRUE;
-       }
+               }
+
+       *size -= context->bytes_to_skip;
+       *data += context->bytes_to_skip;
+       return TRUE;
 }
 
 /*
@@ -233,33 +235,42 @@ decompress_line(const guchar* src, guint line_length, guchar* dest)
 {
        guint16 bytes_read = 0;
        int k;
-       while (bytes_read < line_length) {
+       while (bytes_read < line_length)
+               {
                gchar byte = src[bytes_read];
                ++bytes_read;
 
-               if (byte == -128) {
+               if (byte == -128)
+                       {
                        continue;
-               } else if (byte > -1) {
+                       }
+
+               if (byte > -1)
+                       {
                        gint count = byte + 1;
 
                        /* copy next count bytes */
-                       for (k = 0; k < count; ++k) {
+                       for (k = 0; k < count; ++k)
+                               {
                                *dest = src[bytes_read];
                                ++dest;
                                ++bytes_read;
+                               }
                        }
-               } else {
+               else
+                       {
                        gint count = -byte + 1;
 
                        /* copy next byte count times */
                        guchar next_byte = src[bytes_read];
                        ++bytes_read;
-                       for (k = 0; k < count; ++k) {
+                       for (k = 0; k < count; ++k)
+                               {
                                *dest = next_byte;
                                ++dest;
+                               }
                        }
                }
-       }
 }
 
 static void
index 2148af0..2195fb3 100644 (file)
@@ -163,14 +163,12 @@ static gboolean image_loader_tiff_load (gpointer loader, const guchar *buf, gsiz
                DEBUG_1("Failed to open TIFF image");
                return FALSE;
                }
-       else
-               {
-               do
-                       {
-                       dircount++;
-                       } while (TIFFReadDirectory(tiff));
-               lt->page_total = dircount;
-               }
+
+       do      {
+               dircount++;
+               } while (TIFFReadDirectory(tiff));
+
+       lt->page_total = dircount;
 
     if (!TIFFSetDirectory(tiff, lt->page_num))
                {
index 83976d8..1883637 100644 (file)
@@ -210,16 +210,14 @@ void image_osd_toggle(ImageWindow *imd)
                image_osd_set(imd, static_cast<OsdShowFlags>(OSD_SHOW_INFO | OSD_SHOW_STATUS));
                return;
                }
+
+       if (show & OSD_SHOW_HISTOGRAM)
+               {
+               image_osd_set(imd, OSD_SHOW_NOTHING);
+               }
        else
                {
-               if (show & OSD_SHOW_HISTOGRAM)
-                       {
-                       image_osd_set(imd, OSD_SHOW_NOTHING);
-                       }
-               else
-                       {
-                       image_osd_set(imd, static_cast<OsdShowFlags>(show | OSD_SHOW_HISTOGRAM));
-                       }
+               image_osd_set(imd, static_cast<OsdShowFlags>(show | OSD_SHOW_HISTOGRAM));
                }
 }
 
index 3bf37db..e668261 100644 (file)
@@ -985,7 +985,7 @@ static gboolean image_read_ahead_check(ImageWindow *imd)
                imd->read_ahead_fd = nullptr;
                return TRUE;
                }
-       else if (imd->read_ahead_fd->pixbuf)
+       if (imd->read_ahead_fd->pixbuf)
                {
                image_change_pixbuf(imd, imd->read_ahead_fd->pixbuf, image_zoom_get(imd), FALSE);
 
@@ -1216,11 +1216,9 @@ static gboolean image_scroll_cb(GtkWidget *, GdkEventScroll *event, gpointer dat
                                }
                        return TRUE;
                        }
-               else
-                       {
-                       imd->func_scroll(imd, event, imd->data_scroll);
-                       return TRUE;
-                       }
+
+               imd->func_scroll(imd, event, imd->data_scroll);
+               return TRUE;
                }
 
        return FALSE;
index f7e8f45..96e0b3d 100644 (file)
@@ -81,8 +81,8 @@ guint16 tiff_byte_get_int16(const guchar *f, TiffByteOrder bo)
 
        if (bo == TIFF_BYTE_ORDER_INTEL)
                return GUINT16_FROM_LE(align_buf);
-       else
-               return GUINT16_FROM_BE(align_buf);
+
+       return GUINT16_FROM_BE(align_buf);
 }
 
 guint32 tiff_byte_get_int32(const guchar *f, TiffByteOrder bo)
@@ -93,8 +93,8 @@ guint32 tiff_byte_get_int32(const guchar *f, TiffByteOrder bo)
 
        if (bo == TIFF_BYTE_ORDER_INTEL)
                return GUINT32_FROM_LE(align_buf);
-       else
-               return GUINT32_FROM_BE(align_buf);
+
+       return GUINT32_FROM_BE(align_buf);
 }
 
 #pragma GCC diagnostic push
index 588ef14..a3353b5 100644 (file)
@@ -1860,7 +1860,8 @@ static void layout_grid_setup(LayoutWindow *lw)
 
                return;
                }
-       else if (lw->tools)
+
+       if (lw->tools)
                {
                layout_tools_geometry_sync(lw);
                gq_gtk_widget_destroy(lw->tools);
index b03b048..5279a2a 100644 (file)
@@ -259,13 +259,12 @@ static int lua_exif_get_datum(lua_State *L)
                        lua_pushnumber(L, datetime);
                        return 1;
                        }
-               else
-                       {
-                       lua_pushnil(L);
-                       return 1;
-                       }
+
+               lua_pushnil(L);
+               return 1;
                }
-       else if (strcmp(key, "Exif.Photo.DateTimeDigitized") == 0)
+
+       if (strcmp(key, "Exif.Photo.DateTimeDigitized") == 0)
                {
                memset(&tm, 0, sizeof(tm));
                if (value && strptime(value, "%Y:%m:%d %H:%M:%S", &tm))
@@ -274,11 +273,9 @@ static int lua_exif_get_datum(lua_State *L)
                        lua_pushnumber(L, datetime);
                        return 1;
                        }
-               else
-                       {
-                       lua_pushnil(L);
-                       return 1;
-                       }
+
+               lua_pushnil(L);
+               return 1;
                }
        lua_pushstring(L, value);
        return 1;
index 84f319f..06f1793 100644 (file)
@@ -845,14 +845,12 @@ gboolean metadata_append_string(FileData *fd, const gchar *key, const char *valu
                {
                return metadata_write_string(fd, key, value);
                }
-       else
-               {
-               gchar *new_string = g_strconcat(str, value, NULL);
-               gboolean ret = metadata_write_string(fd, key, new_string);
-               g_free(str);
-               g_free(new_string);
-               return ret;
-               }
+
+       gchar *new_string = g_strconcat(str, value, NULL);
+       gboolean ret = metadata_write_string(fd, key, new_string);
+       g_free(str);
+       g_free(new_string);
+       return ret;
 }
 
 gboolean metadata_write_GPS_coord(FileData *fd, const gchar *key, gdouble value)
@@ -916,16 +914,14 @@ gboolean metadata_append_list(FileData *fd, const gchar *key, const GList *value
                {
                return metadata_write_list(fd, key, values);
                }
-       else
-               {
-               gboolean ret;
-               list = g_list_concat(list, string_list_copy(values));
-               list = remove_duplicate_strings_from_list(list);
 
-               ret = metadata_write_list(fd, key, list);
-               g_list_free_full(list, g_free);
-               return ret;
-               }
+       gboolean ret;
+       list = g_list_concat(list, string_list_copy(values));
+       list = remove_duplicate_strings_from_list(list);
+
+       ret = metadata_write_list(fd, key, list);
+       g_list_free_full(list, g_free);
+       return ret;
 }
 
 /**
@@ -997,8 +993,8 @@ gchar *find_string_in_list(GList *list, const gchar *string)
 {
        if (options->metadata.keywords_case_sensitive)
                return find_string_in_list_utf8case(list, string);
-       else
-               return find_string_in_list_utf8nocase(list, string);
+
+       return find_string_in_list_utf8nocase(list, string);
 }
 
 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b')
@@ -1205,10 +1201,8 @@ gboolean keyword_same_parent(GtkTreeModel *keyword_tree, GtkTreeIter *a, GtkTree
                {
                return keyword_compare(keyword_tree, &parent_a, &parent_b) == 0;
                }
-       else
-               {
-               return (!valid_pa && !valid_pb); /* both are toplevel */
-               }
+
+       return (!valid_pa && !valid_pb); /* both are toplevel */
 }
 
 gboolean keyword_exists(GtkTreeModel *keyword_tree, GtkTreeIter *parent_ptr, GtkTreeIter *sibling, const gchar *name, gboolean exclude_sibling, GtkTreeIter *result)
index cb1dddf..053efbf 100644 (file)
@@ -126,8 +126,8 @@ gchar *expand_tilde(const gchar *filename)
 
        if (slash)
                return g_build_filename(home, G_DIR_SEPARATOR_S, slash + 1, NULL);
-       else
-               return g_build_filename(home, G_DIR_SEPARATOR_S, NULL);
+
+       return g_build_filename(home, G_DIR_SEPARATOR_S, NULL);
 #endif
 }
 
index e0074d9..9a03b46 100644 (file)
@@ -459,10 +459,8 @@ void osd_template_insert(GHashTable *vars, const gchar *keyword, const gchar *va
                g_hash_table_insert(vars, const_cast<gchar *>(keyword), const_cast<gchar *>(value));
                return;
                }
-       else
-               {
-               g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(value));
-               }
+
+       g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(value));
 
        if (flags & OSDT_FREE) g_free(const_cast<gchar *>(value));
 }
index d715a89..35ff195 100644 (file)
@@ -319,13 +319,11 @@ static gboolean pan_view_list_contains_kw_pattern(GList *haystack, PanViewFilter
                        }
                return FALSE;
                }
-       else
-               {
-               // regex compile failed; fall back to exact string match.
-               GList *found_elem = g_list_find_custom(haystack, filter->keyword, reinterpret_cast<GCompareFunc>(g_strcmp0));
-               if (found_elem && found_kw) *found_kw = static_cast<gchar *>(found_elem->data);
-               return !!found_elem;
-               }
+
+       // regex compile failed; fall back to exact string match.
+       GList *found_elem = g_list_find_custom(haystack, filter->keyword, reinterpret_cast<GCompareFunc>(g_strcmp0));
+       if (found_elem && found_kw) *found_kw = static_cast<gchar *>(found_elem->data);
+       return !!found_elem;
 }
 
 gboolean pan_filter_fd_list(GList **fd_list, GList *filter_elements, gint filter_classes)
index 8dd98fe..ce9b73d 100644 (file)
@@ -3095,7 +3095,8 @@ static gboolean keywords_find_file(gpointer data)
 
                return (G_SOURCE_CONTINUE);
                }
-       else if (kfd->list_dir)
+
+       if (kfd->list_dir)
                {
                FileData *fd;
 
index 323cb63..9073943 100644 (file)
@@ -485,10 +485,8 @@ static gboolean paginate_cb(GtkPrintOperation *, GtkPrintContext *, gpointer dat
                {
                return TRUE;
                }
-       else
-               {
-               return FALSE;
-               }
+
+       return FALSE;
 }
 
 gchar *form_image_text(const gchar *template_string, FileData *fd, PrintWindow *pw, gint page_nr, gint total)
index d333256..451b5be 100644 (file)
@@ -1755,7 +1755,8 @@ static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **
                                if (offset) *offset = text + strlen(remote_commands[i].opt_s);
                                return &remote_commands[i];
                                }
-                       else if (remote_commands[i].opt_l &&
+
+                       if (remote_commands[i].opt_l &&
                                 strncmp(remote_commands[i].opt_l, text, strlen(remote_commands[i].opt_l)) == 0)
                                {
                                if (offset) *offset = text + strlen(remote_commands[i].opt_l);
index 40d8dc0..9a3fb81 100644 (file)
@@ -1928,8 +1928,7 @@ static void rt_scroll(void *renderer, gint x_off, gint y_off)
                rt_queue(rt, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
                return;
                }
-       else
-               {
+
                gint x1, y1;
                gint x2, y2;
                cairo_t *cr;
@@ -1991,7 +1990,6 @@ static void rt_scroll(void *renderer, gint x_off, gint y_off)
                                    rt->x_scroll, y_off > 0 ? rt->y_scroll + (pr->vis_height - h) : rt->y_scroll,
                                    pr->vis_width, h, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
                        }
-               }
 }
 
 static void renderer_area_changed(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h)
index 4947948..f35cd43 100644 (file)
@@ -1841,11 +1841,9 @@ static gboolean search_file_do_extra(SearchData *sd, FileData *fd, gint *match,
                                {
                                return TRUE;
                                }
-                       else
-                               {
-                               image_loader_free(sd->img_loader);
-                               sd->img_loader = nullptr;
-                               }
+
+                       image_loader_free(sd->img_loader);
+                       sd->img_loader = nullptr;
                        }
                }
 
index 0cf242d..924e1c6 100644 (file)
@@ -178,8 +178,8 @@ gboolean slideshow_should_continue(SlideShowData *ss)
                {
                if (g_list_length(ss->cd->list) == ss->slide_count)
                        return TRUE;
-               else
-                       return FALSE;
+
+               return FALSE;
                }
 
        dir_fd = ss->lw->dir_fd;
index 7e52832..a22b860 100644 (file)
@@ -887,7 +887,8 @@ void parse_out_relatives(gchar *path)
                                s = p;
                                continue;
                                }
-                       else if (path[p] == '.' && (path[p+1] == G_DIR_SEPARATOR || path[p+1] == '\0'))
+
+                       if (path[p] == '.' && (path[p+1] == G_DIR_SEPARATOR || path[p+1] == '\0'))
                                {
                                /* /../ or /.., remove previous part, ie. /a/b/../ becomes /a/ */
                                s = p + 1;
index 771d3b0..5c9bb1c 100644 (file)
@@ -1388,14 +1388,14 @@ gchar *text_widget_text_pull(GtkWidget *text_widget)
 
                return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
                }
-       else if (GTK_IS_ENTRY(text_widget))
+
+       if (GTK_IS_ENTRY(text_widget))
                {
                return g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(text_widget)));
                }
-       else
-               {
-               return nullptr;
-               }
+
+       return nullptr;
+       
 
 }
 
@@ -1417,14 +1417,14 @@ gchar *text_widget_text_pull_selected(GtkWidget *text_widget)
 
                return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
                }
-       else if (GTK_IS_ENTRY(text_widget))
+
+       if (GTK_IS_ENTRY(text_widget))
                {
                return g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(text_widget)));
                }
-       else
-               {
-               return nullptr;
-               }
+
+       return nullptr;
+       
 }
 
 static gint simple_sort_cb(gconstpointer a, gconstpointer b)
index 50b9059..69ad7be 100644 (file)
@@ -405,15 +405,13 @@ static gboolean tab_completion_do(TabCompData *td)
                        g_free(entry_dir);
                        return home_exp;
                        }
-               else
-                       {
-                       gchar *buf = g_strconcat(entry_dir, G_DIR_SEPARATOR_S, NULL);
-                       gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
-                       gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
-                       g_free(buf);
-                       g_free(entry_dir);
-                       return TRUE;
-                       }
+
+               gchar *buf = g_strconcat(entry_dir, G_DIR_SEPARATOR_S, NULL);
+               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+               gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
+               g_free(buf);
+               g_free(entry_dir);
+               return TRUE;
                }
 
        ptr = const_cast<gchar *>(filename_from_path(entry_dir));
@@ -463,52 +461,51 @@ static gboolean tab_completion_do(TabCompData *td)
                                g_free(entry_dir);
                                return TRUE;
                                }
-                       else
-                               {
-                               gsize c = strlen(entry_file);
-                               gboolean done = FALSE;
-                               auto test_file = static_cast<gchar *>(poss->data);
 
-                               while (!done)
+                       gsize c = strlen(entry_file);
+                       gboolean done = FALSE;
+                       auto test_file = static_cast<gchar *>(poss->data);
+
+                       while (!done)
+                               {
+                               list = poss;
+                               if (!list) done = TRUE;
+                               while (list && !done)
                                        {
-                                       list = poss;
-                                       if (!list) done = TRUE;
-                                       while (list && !done)
+                                       auto file = static_cast<gchar *>(list->data);
+                                       if (strlen(file) < c || strncmp(test_file, file, c) != 0)
                                                {
-                                               auto file = static_cast<gchar *>(list->data);
-                                               if (strlen(file) < c || strncmp(test_file, file, c) != 0)
-                                                       {
-                                                       done = TRUE;
-                                                       }
-                                               list = list->next;
+                                               done = TRUE;
                                                }
-                                       c++;
+                                       list = list->next;
                                        }
-                               c -= 2;
-                               if (c > 0)
-                                       {
-                                       gchar *file;
-                                       gchar *buf;
-                                       file = g_strdup(test_file);
-                                       file[c] = '\0';
-                                       buf = g_build_filename(entry_dir, file, NULL);
-                                       gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
-                                       gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
+                               c++;
+                               }
+                       c -= 2;
+                       if (c > 0)
+                               {
+                               gchar *file;
+                               gchar *buf;
+                               file = g_strdup(test_file);
+                               file[c] = '\0';
+                               buf = g_build_filename(entry_dir, file, NULL);
+                               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+                               gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
 
 #ifdef TAB_COMPLETION_ENABLE_POPUP_MENU
 
-                                       poss = g_list_sort(poss, simple_sort);
-                                       tab_completion_popup_list(td, poss);
+                               poss = g_list_sort(poss, simple_sort);
+                               tab_completion_popup_list(td, poss);
 
 #endif
 
-                                       g_free(file);
-                                       g_free(buf);
-                                       g_list_free(poss);
-                                       g_free(entry_dir);
-                                       return TRUE;
-                                       }
+                               g_free(file);
+                               g_free(buf);
+                               g_list_free(poss);
+                               g_free(entry_dir);
+                               return TRUE;
                                }
+
                        g_list_free(poss);
                        }
                }
index 662c420..d30db2b 100644 (file)
@@ -997,28 +997,23 @@ static gint vdtree_sort_cb(GtkTreeModel *store, GtkTreeIter *a, GtkTreeIter *b,
                        {
                        return strcmp(nda->fd->collate_key_name_natural, ndb->fd->collate_key_name_natural);
                        }
-               else
-                       {
-                       return strcmp(nda->fd->collate_key_name_nocase_natural, ndb->fd->collate_key_name_nocase_natural);
-                       }
+
+               return strcmp(nda->fd->collate_key_name_nocase_natural, ndb->fd->collate_key_name_nocase_natural);
                }
-       else if (vd->layout->options.dir_view_list_sort.method == SORT_TIME)
+
+       if (vd->layout->options.dir_view_list_sort.method == SORT_TIME)
                {
                if (nda->fd->date < ndb->fd->date) return -1;
                if (nda->fd->date > ndb->fd->date) return 1;
                return 0;
                }
-       else
+
+       if (vd->layout->options.dir_view_list_sort.case_sensitive == TRUE)
                {
-               if (vd->layout->options.dir_view_list_sort.case_sensitive == TRUE)
-                       {
-                       return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name);
-                       }
-               else
-                       {
-                       return strcmp(nda->fd->collate_key_name_nocase, ndb->fd->collate_key_name_nocase);
-                       }
+               return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name);
                }
+
+       return strcmp(nda->fd->collate_key_name_nocase, ndb->fd->collate_key_name_nocase);
 }
 
 /*
index 28fd9ce..5a7cb13 100644 (file)
@@ -1085,10 +1085,8 @@ static gboolean vd_dnd_drop_motion(GtkWidget *, GdkDragContext *context, gint x,
                gdk_drag_status(context, GDK_ACTION_DEFAULT, time);
                return TRUE;
                }
-       else
-               {
-               gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time);
-               }
+
+       gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time);
 
        vd_dnd_drop_update(vd, x, y);
 
index 683245e..cfc8f24 100644 (file)
@@ -1563,12 +1563,10 @@ gboolean vf_stars_cb(gpointer data)
                        {
                        return G_SOURCE_CONTINUE;
                        }
-               else
-                       {
-                       vf->stars_filedata = nullptr;
-                       vf->stars_id = 0;
-                       return G_SOURCE_REMOVE;
-                       }
+
+               vf->stars_filedata = nullptr;
+               vf->stars_id = 0;
+               return G_SOURCE_REMOVE;
                }
 
        return G_SOURCE_REMOVE;
index 6ec9808..fae1cf6 100644 (file)
@@ -618,7 +618,7 @@ static ZDLookupResult ZDPointInPolygon(const ZoneDetect *library, uint32_t polyg
         int result = ZDReaderGetPoint(&reader, &pointLat, &pointLon);
         if(result < 0) {
             return ZD_LOOKUP_PARSE_ERROR;
-        } else if(result == 0) {
+        } if(result == 0) {
             break;
         }
 
@@ -740,9 +740,9 @@ static ZDLookupResult ZDPointInPolygon(const ZoneDetect *library, uint32_t polyg
 
     if(winding == -4) {
         return ZD_LOOKUP_IN_ZONE;
-    } else if(winding == 4) {
+    } if(winding == 4) {
         return ZD_LOOKUP_IN_EXCLUDED_ZONE;
-    } else if(winding == 0) {
+    } if(winding == 0) {
         return ZD_LOOKUP_NOT_IN_ZONE;
     }
 
@@ -921,7 +921,7 @@ ZoneDetectResult *ZDLookup(const ZoneDetect *library, float lat, float lon, floa
                 const ZDLookupResult lookupResult = ZDPointInPolygon(library, library->dataOffset + polygonIndex, latFixedPoint, lonFixedPoint, (safezone) ? &distanceSqrMin : nullptr);
                 if(lookupResult == ZD_LOOKUP_PARSE_ERROR) {
                     break;
-                } else if(lookupResult != ZD_LOOKUP_NOT_IN_ZONE) {
+                } if(lookupResult != ZD_LOOKUP_NOT_IN_ZONE) {
                     auto newResults = static_cast<ZoneDetectResult *>(realloc(results, sizeof(ZoneDetectResult) * (numResults + 2)));
 
                     if(newResults) {