clang-tidy: readability-non-const-parameter
authorColin Clark <colin.clark@cclark.uk>
Sat, 3 Feb 2024 15:43:51 +0000 (15:43 +0000)
committerColin Clark <colin.clark@cclark.uk>
Sat, 3 Feb 2024 15:43:51 +0000 (15:43 +0000)
- Fix warnings identified by this flag
- Remove the exclude from .clang-tidy file

.clang-tidy
src/cache.cc
src/cache.h
src/exif.h
src/exiv2.cc
src/image-load-libraw.cc
src/image-load-libraw.h
src/image-load-psd.cc
src/layout.cc
src/md5-util.cc
src/md5-util.h

index 86e0bf0..8e25cfc 100644 (file)
@@ -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,
index 91f6198..118123b 100644 (file)
@@ -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;
 
index 3771fe6..27de211 100644 (file)
@@ -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);
 
index 56e4e1b..f32e733 100644 (file)
@@ -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);
index e16d89b..b41db97 100644 (file)
@@ -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<Exiv2::byte*>(buf);
 }
index ab14e0f..f30d4e7 100644 (file)
@@ -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;
 
index 30e5578..9e4da25 100644 (file)
@@ -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
 
index a26cef2..6fb9e5f 100644 (file)
@@ -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];
 }
index a3353b5..43c6bf5 100644 (file)
@@ -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;
index bc8c374..5d089f7 100644 (file)
@@ -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;
index 3dcab29..92df16f 100644 (file)
@@ -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