clang-tidy: simplify booleans
authorRosen Penev <rosenp@gmail.com>
Thu, 29 Jun 2023 22:19:32 +0000 (15:19 -0700)
committerColin Clark <colin.clark@cclark.uk>
Sat, 8 Jul 2023 10:06:57 +0000 (11:06 +0100)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
src/cache-maint.cc
src/exif.cc
src/filedata.cc
src/history-list.cc
src/image-load.cc
src/image.cc
src/metadata.cc
src/pixbuf-renderer.cc
src/search.cc

index d504d18..cf1a613 100644 (file)
@@ -149,7 +149,7 @@ static gboolean isempty(const gchar *path)
                {
                gchar *name = dir->d_name;
 
-               if (!(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) )
+               if (name[0] != '.' || (name[1] != '\0' && (name[1] != '.' || name[2] != '\0')) )
                        {
                        closedir(dp);
                        return FALSE;
index 47f719e..7936592 100644 (file)
@@ -889,12 +889,12 @@ static gint exif_parse_IFD_entry(ExifData *exif, guchar *tiff, guint offset,
                 * FIXME: what exactly is this test trying to do?
                 * ok, so this test is to allow the case of swapped signed/unsigned mismatch to leak through?
                 */
-               if (!(marker->format == EXIF_FORMAT_RATIONAL_UNSIGNED && format == EXIF_FORMAT_RATIONAL) &&
-                   !(marker->format == EXIF_FORMAT_RATIONAL && format == EXIF_FORMAT_RATIONAL_UNSIGNED) &&
+               if ((marker->format != EXIF_FORMAT_RATIONAL_UNSIGNED || format != EXIF_FORMAT_RATIONAL) &&
+                   (marker->format != EXIF_FORMAT_RATIONAL || format != EXIF_FORMAT_RATIONAL_UNSIGNED) &&
                        /* short fits into a long so allow this mismatch
                         * as well (some tags allowed to be unsigned short _or_ unsigned long)
                         */
-                   !(marker->format == EXIF_FORMAT_LONG_UNSIGNED && format == EXIF_FORMAT_SHORT_UNSIGNED) )
+                   (marker->format != EXIF_FORMAT_LONG_UNSIGNED || format != EXIF_FORMAT_SHORT_UNSIGNED) )
                        {
                        if (format < EXIF_FORMAT_COUNT)
                                {
index 42903ae..3a045ef 100644 (file)
@@ -1417,7 +1417,7 @@ static gboolean filelist_read_real(const gchar *dir_path, GList **files, GList *
                                {
                                /* we ignore the .thumbnails dir for cleanliness */
                                if (dirs &&
-                                   !(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) &&
+                                   (name[0] != '.' || (name[1] != '\0' && (name[1] != '.' || name[2] != '\0'))) &&
                                    strcmp(name, GQ_CACHE_LOCAL_THUMB) != 0 &&
                                    strcmp(name, GQ_CACHE_LOCAL_METADATA) != 0 &&
                                    strcmp(name, THUMB_FOLDER_LOCAL) != 0)
index bd3517d..da97cd8 100644 (file)
@@ -311,11 +311,11 @@ gboolean history_list_save(const gchar *path)
                list_count = g_list_position(hd->list, g_list_last(hd->list)) + 1;
                while (work && secsave_errno == SS_ERR_NONE)
                        {
-                       if ((!(strcmp(hd->key, "path_list") == 0 && list_count > options->open_recent_list_maxsize))
+                       if ((strcmp(hd->key, "path_list") != 0 || list_count <= options->open_recent_list_maxsize)
                                        &&
-                                       (!(strcmp(hd->key, "recent") == 0 && (!isfile(static_cast<const gchar *>(work->data)))))
+                                       (strcmp(hd->key, "recent") != 0 || !(!isfile(static_cast<const gchar *>(work->data))))
                                        &&
-                                       (!(strcmp(hd->key, "image_list") == 0 && list_count > options->recent_folder_image_list_maxsize)))
+                                       (strcmp(hd->key, "image_list") != 0 || list_count <= options->recent_folder_image_list_maxsize))
                                {
                                secure_fprintf(ssi, "\"%s\"\n", static_cast<gchar *>(work->data));
                                }
index 0c177d9..b6619d8 100644 (file)
@@ -1020,7 +1020,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                                {
                                /* Both exiv2 and libraw sometimes return a pointer to a file
                                 * section that is not a jpeg */
-                               if (!(il->mapped_file[0] == 0xFF && il->mapped_file[1] == 0xD8))
+                               if (il->mapped_file[0] != 0xFF || il->mapped_file[1] != 0xD8)
                                        {
                                        il->mapped_file = nullptr;
                                        }
@@ -1040,7 +1040,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                                {
                                /* Both exiv2 and libraw sometimes return a pointer to a file
                                 * section that is not a jpeg */
-                               if (!(il->mapped_file[0] == 0xFF && il->mapped_file[1] == 0xD8))
+                               if (il->mapped_file[0] != 0xFF || il->mapped_file[1] != 0xD8)
                                        {
                                        il->mapped_file = nullptr;
                                        }
index 245ba10..76faafe 100644 (file)
@@ -673,7 +673,7 @@ void image_alter_orientation(ImageWindow *imd, FileData *fd_n, AlterType type)
                        }
                }
 
-       if (imd->image_fd == fd_n && !(options->metadata.write_orientation && !options->image.exif_rotate_enable))
+       if (imd->image_fd == fd_n && (!options->metadata.write_orientation || options->image.exif_rotate_enable))
                {
                imd->orientation = orientation;
                pixbuf_renderer_set_orientation(reinterpret_cast<PixbufRenderer *>(imd->pr), orientation);
index 126b13c..dc7c24b 100644 (file)
@@ -1241,7 +1241,7 @@ gboolean keyword_exists(GtkTreeModel *keyword_tree, GtkTreeIter *parent_ptr, Gtk
 
        while (TRUE)
                {
-               if (!(exclude_sibling && sibling && keyword_compare(keyword_tree, &iter, sibling) == 0))
+               if (!exclude_sibling || !sibling || keyword_compare(keyword_tree, &iter, sibling) != 0)
                        {
                        if (options->metadata.keywords_case_sensitive)
                                {
index 97ec4fa..2994986 100644 (file)
@@ -1002,10 +1002,10 @@ static gboolean pr_source_tile_visible(PixbufRenderer *pr, SourceTile *st)
        x2 = pr->x_scroll + pr->vis_width;
        y2 = pr->y_scroll + pr->vis_height;
 
-       return !(static_cast<gdouble>(st->x) * pr->scale > static_cast<gdouble>(x2) ||
-                static_cast<gdouble>(st->x + pr->source_tile_width) * pr->scale < static_cast<gdouble>(x1) ||
-                static_cast<gdouble>(st->y) * pr->scale > static_cast<gdouble>(y2) ||
-                static_cast<gdouble>(st->y + pr->source_tile_height) * pr->scale < static_cast<gdouble>(y1));
+       return static_cast<gdouble>(st->x) * pr->scale <= static_cast<gdouble>(x2) &&
+                static_cast<gdouble>(st->x + pr->source_tile_width) * pr->scale >= static_cast<gdouble>(x1) &&
+                static_cast<gdouble>(st->y) * pr->scale <= static_cast<gdouble>(y2) &&
+                static_cast<gdouble>(st->y + pr->source_tile_height) * pr->scale >= static_cast<gdouble>(y1);
 }
 
 static SourceTile *pr_source_tile_new(PixbufRenderer *pr, gint x, gint y)
index 0d9f89e..cb58691 100644 (file)
@@ -2704,9 +2704,9 @@ static void search_start_cb(GtkWidget *UNUSED(widget), gpointer data)
                        sd->search_lat = 1000;
                        sd->search_lon = 1000;
                        sscanf(entry_text," %lf  %lf ", &sd->search_lat, &sd->search_lon );
-                       if (!(entry_text != nullptr && !g_strstr_len(entry_text, -1, "Error") &&
-                                               sd->search_lat >= -90 && sd->search_lat <= 90 &&
-                                               sd->search_lon >= -180 && sd->search_lon <= 180))
+                       if (entry_text == nullptr || g_strstr_len(entry_text, -1, "Error") ||
+                                               sd->search_lat < -90 || sd->search_lat > 90 ||
+                                               sd->search_lon < -180 || sd->search_lon > 180)
                                {
                                file_util_warning_dialog(_(
                                                "Entry does not contain a valid lat/long value"),