clang-tidy: bugprone-macro-parentheses
authorColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 15:28:33 +0000 (15:28 +0000)
committerColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 15:28:33 +0000 (15:28 +0000)
- Fix warnings identified by this flag
- Remove the exclude from .clang-tidy file

.clang-tidy
src/collect-table.cc
src/pixbuf-renderer.cc
src/renderer-tiles.cc
src/search.cc
src/view-dir-list.cc
src/view-dir-tree.cc

index 17b7897..717b72b 100644 (file)
@@ -32,7 +32,6 @@ Checks: >
   -bugprone-implicit-widening-of-multiplication-result,
   -bugprone-incorrect-roundings,
   -bugprone-integer-division,
-  -bugprone-macro-parentheses,
   -bugprone-narrowing-conversions,
   -bugprone-reserved-identifier,
   -bugprone-sizeof-expression,
index c2f4c26..61944d6 100644 (file)
@@ -59,7 +59,7 @@ enum {
        CTABLE_COLUMN_COUNT
 };
 
-#define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
+#define INFO_SELECTED(x) ((x)->flag_mask & SELECTION_SELECTED)
 
 
 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force);
index 89bccd9..ab0372b 100644 (file)
@@ -54,7 +54,7 @@ enum ExifOrientationType {
 
 
 /* default min and max zoom */
-#define PR_ZOOM_MIN -32.0
+#define PR_ZOOM_MIN (-32.0)
 #define PR_ZOOM_MAX 32.0
 
 /* distance to drag mouse to disable image flip */
index dfe4b7f..40d8dc0 100644 (file)
@@ -153,14 +153,14 @@ static void rt_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_tople
 static gint rt_queue_draw_idle_cb(gpointer data);
 
 #define GET_RIGHT_PIXBUF_OFFSET(rt) \
-        (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
-         (!(rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
+        (( ((rt)->stereo_mode & PR_STEREO_RIGHT) && !((rt)->stereo_mode & PR_STEREO_SWAP)) || \
+         (!((rt)->stereo_mode & PR_STEREO_RIGHT) &&  ((rt)->stereo_mode & PR_STEREO_SWAP)) ?  \
+          (rt)->pr->stereo_pixbuf_offset_right : (rt)->pr->stereo_pixbuf_offset_left )
 
 #define GET_LEFT_PIXBUF_OFFSET(rt) \
-        ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
-         ( (rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
+        ((!((rt)->stereo_mode & PR_STEREO_RIGHT) && !((rt)->stereo_mode & PR_STEREO_SWAP)) || \
+         ( ((rt)->stereo_mode & PR_STEREO_RIGHT) &&  ((rt)->stereo_mode & PR_STEREO_SWAP)) ?  \
+          (rt)->pr->stereo_pixbuf_offset_right : (rt)->pr->stereo_pixbuf_offset_left )
 
 
 static void rt_sync_scroll(RendererTiles *rt)
index 2dde8a3..4947948 100644 (file)
@@ -1678,7 +1678,7 @@ static void search_dnd_init(SearchData *sd)
  *-------------------------------------------------------------------
  */
 
-#define MATCH_IS_BETWEEN(val, a, b)  (b > a ? (val >= a && val <= b) : (val >= b && val <= a))
+#define MATCH_IS_BETWEEN(val, a, b)  ((b) > (a) ? ((val) >= (a) && (val) <= (b)) : ((val) >= (b) && (val) <= (a)))
 
 static gboolean search_step_cb(gpointer data);
 
index 1cb86d6..0f70a33 100644 (file)
@@ -33,7 +33,7 @@ struct ViewDirInfoList
        GList *list;
 };
 
-#define VDLIST(_vd_) ((ViewDirInfoList *)(_vd_->info))
+#define VDLIST(_vd_) ((ViewDirInfoList *)((_vd_)->info))
 
 
 /*
index 8cbd73f..662c420 100644 (file)
@@ -34,7 +34,7 @@ struct ViewDirInfoTree
        gint busy_ref;
 };
 
-#define VDTREE(_vd_) ((ViewDirInfoTree *)(_vd_->info))
+#define VDTREE(_vd_) ((ViewDirInfoTree *)((_vd_)->info))
 
 
 struct PathData