clang-tidy: readability-else-after-return
authorColin Clark <[email protected]>
Sat, 3 Feb 2024 14:48:24 +0000 (14:48 +0000)
committerColin Clark <[email protected]>
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 af037ae47d3d4db97162cfdc4046b7625aac7865..94f0a7b6876695ba1168a8f97ad1adc208ae3aa7 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 29bc31b8f6dbaaf214ca56e4a1da1c03343d4b96..4e1feb5085c3851b61a4b43330610097c4056c72 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 a0d29513598d0713e234659fb5d125d45c1080e3..203fa29216986cfc1b736f0181c070773ff9e5f7 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 f73236d442538fec85429021ac40bf324512c8fd..f7cf7c49c5ff20951c7d5a950d42250013d8f89d 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 e0c1933b6414561aebf5a25dbcc6f6b6d3a518f7..40937343ca63e3a6c082afaebb8cc96419f4d7b0 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 61bea6d8a6f614cd5bed7f470b6e1518024c01e5..e3fd82028cc3a086f14af92db7a5ea31b8e7ec4b 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 e9be69bd732ca67fd582b93c7dd23b929f379b12..63dacd454daa8c9899bcadce171991fc3f51ff0b 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 71373479393128123e8b52600cc77d6323dc8c6b..f03ed75f79f4c1b618863f410b331245831e8dde 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 1fcfb6ac4346ceab993c2f0a4dbc145ad455475a..8ebc3796a752968940584d11db58318044ff853e 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 c990c27c0ebeb1854b9063e18efbf2ecc9f78049..5e032c7da104264170346d54b13e5d01cb27c7a7 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 62e0f331f9539463959d5b562d3ac4fd0790bc6b..f532e682fe955769ee9b4caabaf36e5be585b709 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 0996aff6b2061a5925a999dbf9cafae1b5c424f3..5abc3c5f65042eff360a5fb3f84b1c7f4b854c83 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 114f5bd16859cb883b6a59c89c0ac7908b7ae37f..a26cef229793e42dc4d655da8584dc1b76170ad8 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 2148af003183fd74868db955b5bff09ee96d7b8b..2195fb3c71b4d7cb322598d3ebd61aca6a049969 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 83976d8bb39095705155fb7f91f5ce7e3a7747bc..1883637fab207c833aa2172abfdb0bcd61f46e1c 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 3bf37dbd50b062c7d30aeab367b4626504df8e22..e6682618d75ac11deeed8ec61cc68e0a69d4437c 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 f7e8f455259709fa6d7a0e3b10daefbafb63d90e..96e0b3d555177ceedaf30389aa8dcd6e7f00b0c2 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 588ef14ce4ac4b5dcbc8837d7becdb0f42423c48..a3353b5996a43a5768c393bcf437662428e71194 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 b03b048d2ef9a9d7ec8d0268c258c3b84ddbbfae..5279a2a63483ce0dd99ab56e60eb4e472391702d 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 84f319fe9b0bfacb4bd8f69f3c2edd9f707d880b..06f17931c7b75b13a096a321e7d8c86a4b83e6a7 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 cb1dddfd9efb107e5f0b5cae2d53a5e56a7689da..053efbfc1613872e56094cca6f68894f14dd8469 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 e0074d9191a24bb11dd4ea11ca11eba992d1848f..9a03b46ea601cb726fad556608a120b9080e2a24 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 d715a89dc9f1e6f3ce010f9eb5969dd327965c32..35ff1958ca359fc6b2397d3d9aa213e433b2e639 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 8dd98fef4a78cb870e3af409985bf9652d2c4c1b..ce9b73d6d6994f403f0d7f2840a8ad5a2bbd20ce 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 323cb63ca076ff78e84bd6ff6b58371c7ef1426a..9073943365f64460b621adafe6102badb1be7e2f 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 d333256a3447381d9d75173bc33f262bae8190d4..451b5be42e6c950cf0f14db2ed25dec5da2018c7 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 40d8dc0f8f12c632d98cc70897c2fb09bd19df06..9a3fb8149557d55f6f8b62f85e661680098cfd28 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 4947948b3a9ccfc236cf753fd14655a3a5543649..f35cd4319a48bbdf321d9f482ed8ca2bd585722f 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 0cf242df852dfca7984b712ecc4ebf3a942de425..924e1c615f80c2019ebe24a66d0464e9910e98a3 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 7e528329726ef18b7b4a81873092dc59b7ffea5e..a22b8603e7b45f4374ee109a42ba377ccabb5529 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 771d3b0f55c5c03793307825d8d2f3293e2ee58f..5c9bb1c295398043a3a736b33a6d1eff1893fa95 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 50b9059f507903d8ea195559c6785e1964fbfac3..69ad7beb13f7b8c6315a5db4e1289a27185ecffa 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 662c420bcb33cd5fa50eaa0c70b24490dd13daec..d30db2ba591e20d7f67227e7f5e009f82d490355 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 28fd9ceb62535fea1e1558d58ef798dec186e6d7..5a7cb1376d867f84334bf278a771fafc67cb5354 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 683245eeeceaaa2e66d9c973c226b22732fecc32..cfc8f24385db46121db44f7a23468cbb2aead8f8 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 6ec9808d8470feb765d44aebb792f5b7e911722f..fae1cf6108d1dca48ea90edf29d5a3491615386c 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) {