From 6362a16bbd9eb9ada2331ddef9d3504dbfb3756b Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sat, 3 Feb 2024 15:43:51 +0000 Subject: [PATCH] clang-tidy: readability-non-const-parameter - Fix warnings identified by this flag - Remove the exclude from .clang-tidy file --- .clang-tidy | 1 - src/cache.cc | 4 ++-- src/cache.h | 2 +- src/exif.h | 2 +- src/exiv2.cc | 2 +- src/image-load-libraw.cc | 2 +- src/image-load-libraw.h | 2 +- src/image-load-psd.cc | 4 ++-- src/layout.cc | 2 +- src/md5-util.cc | 2 +- src/md5-util.h | 2 +- 11 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 86e0bf01..8e25cfc4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -53,7 +53,6 @@ Checks: > -readability-magic-numbers, -readability-misleading-indentation, -readability-named-parameter, - -readability-non-const-parameter, -readability-qualified-auto, -readability-simplify-boolean-expr, -readability-suspicious-call-argument, diff --git a/src/cache.cc b/src/cache.cc index 91f6198c..118123bd 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -200,7 +200,7 @@ static gboolean cache_sim_read_skipline(FILE *f, gint s) return FALSE; } -static gboolean cache_sim_read_comment(FILE *f, gchar *buf, gint s, CacheData *cd) +static gboolean cache_sim_read_comment(FILE *f, const gchar *buf, gint s, CacheData *cd) { if (!f || !buf || !cd) return FALSE; @@ -494,7 +494,7 @@ void cache_sim_data_set_date_unused(CacheData *cd, time_t date) } #pragma GCC diagnostic pop -void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]) +void cache_sim_data_set_md5sum(CacheData *cd, const guchar digest[16]) { gint i; diff --git a/src/cache.h b/src/cache.h index 3771fe68..27de211e 100644 --- a/src/cache.h +++ b/src/cache.h @@ -70,7 +70,7 @@ gboolean cache_sim_data_save(CacheData *cd); CacheData *cache_sim_data_load(const gchar *path); void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h); -void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]); +void cache_sim_data_set_md5sum(CacheData *cd, const guchar digest[16]); void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd); gint cache_sim_data_filled(ImageSimilarityData *sd); diff --git a/src/exif.h b/src/exif.h index 56e4e1b5..f32e733f 100644 --- a/src/exif.h +++ b/src/exif.h @@ -167,7 +167,7 @@ void exif_set_image_comment(FileData* fd, const gchar* comment); /*raw support */ guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, gint requested_height); -void exif_free_preview(guchar *buf); +void exif_free_preview(const guchar *buf); gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat format); gchar *metadata_lua_info(FileData *fd, const gchar *key, MetadataFormat format); diff --git a/src/exiv2.cc b/src/exiv2.cc index e16d89b7..b41db975 100644 --- a/src/exiv2.cc +++ b/src/exiv2.cc @@ -1235,7 +1235,7 @@ guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, } } -void exif_free_preview(guchar *buf) +void exif_free_preview(const guchar *buf) { delete[] static_cast(buf); } diff --git a/src/image-load-libraw.cc b/src/image-load-libraw.cc index ab14e0f4..f30d4e73 100644 --- a/src/image-load-libraw.cc +++ b/src/image-load-libraw.cc @@ -47,7 +47,7 @@ struct UnmapData static GList *libraw_unmap_list = nullptr; -void libraw_free_preview(guchar *buf) +void libraw_free_preview(const guchar *buf) { GList *work = libraw_unmap_list; diff --git a/src/image-load-libraw.h b/src/image-load-libraw.h index 30e5578f..9e4da258 100644 --- a/src/image-load-libraw.h +++ b/src/image-load-libraw.h @@ -22,7 +22,7 @@ #define IMAGE_LOAD_RAW_H guchar *libraw_get_preview(ImageLoader *il, guint *data_len); -void libraw_free_preview(guchar *buf); +void libraw_free_preview(const guchar *buf); #endif diff --git a/src/image-load-psd.cc b/src/image-load-psd.cc index a26cef22..6fb9e5fe 100644 --- a/src/image-load-psd.cc +++ b/src/image-load-psd.cc @@ -138,13 +138,13 @@ struct PsdContext static guint16 -read_uint16 (guchar* buf) +read_uint16 (const guchar* buf) { return (buf[0] << 8) | buf[1]; } static guint32 -read_uint32 (guchar* buf) +read_uint32 (const guchar* buf) { return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; } diff --git a/src/layout.cc b/src/layout.cc index a3353b59..43c6bf5d 100644 --- a/src/layout.cc +++ b/src/layout.cc @@ -815,7 +815,7 @@ void layout_status_update_all(LayoutWindow *lw) layout_util_status_update_write(lw); } -static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand) +static GtkWidget *layout_status_label(const gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand) { GtkWidget *label; GtkWidget *frame; diff --git a/src/md5-util.cc b/src/md5-util.cc index bc8c374e..5d089f72 100644 --- a/src/md5-util.cc +++ b/src/md5-util.cc @@ -136,7 +136,7 @@ gchar *md5_get_string_from_file(const gchar *path) * and assumes a NULL terminated string. */ -gchar *md5_digest_to_text(guchar digest[16]) +gchar *md5_digest_to_text(const guchar digest[16]) { static gchar hex_digits[] = "0123456789abcdef"; gchar *result; diff --git a/src/md5-util.h b/src/md5-util.h index 3dcab297..92df16f7 100644 --- a/src/md5-util.h +++ b/src/md5-util.h @@ -63,7 +63,7 @@ gchar *md5_get_string_from_file(const gchar *path); * @headerfile md5_digest_to_text * convert digest to a NULL terminated text string, in ascii encoding */ -gchar *md5_digest_to_text(guchar digest[16]); +gchar *md5_digest_to_text(const guchar digest[16]); /** * @headerfile md5_digest_from_text -- 2.20.1