From cb24450dcb58c6cf144ac5c8ee3558e941e55dc9 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 14 May 2026 16:48:48 +0300
Subject: [PATCH 39/39] rgbcolor.c: Replace parameter checking fc_asserts with
 nonnull attributes

See RM #2001

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/rgbcolor.c | 10 ----------
 common/rgbcolor.h | 18 ++++++++++++------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/common/rgbcolor.c b/common/rgbcolor.c
index 23f91dc9a0..0018430a19 100644
--- a/common/rgbcolor.c
+++ b/common/rgbcolor.c
@@ -50,8 +50,6 @@ struct rgbcolor *rgbcolor_new(int r, int g, int b)
 ****************************************************************************/
 struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor)
 {
-  fc_assert_ret_val(prgbcolor != nullptr, nullptr);
-
   return rgbcolor_new(prgbcolor->r, prgbcolor->g, prgbcolor->b);
 }
 
@@ -61,8 +59,6 @@ struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor)
 ****************************************************************************/
 bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2)
 {
-  fc_assert_ret_val(c1 != nullptr && c2 != nullptr, FALSE);
-
   /* No check of cached 'color' member -- if values are equal, it should be
    * equivalent */
   return (c1->r == c2->r && c1->g == c2->g && c1->b == c2->b);
@@ -94,7 +90,6 @@ bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor,
   char colorpath[256];
   va_list args;
 
-  fc_assert_ret_val(file != nullptr, FALSE);
   fc_assert_ret_val(*prgbcolor == nullptr, FALSE);
 
   va_start(args, path);
@@ -124,9 +119,6 @@ void rgbcolor_save(struct section_file *file,
   char colorpath[256];
   va_list args;
 
-  fc_assert_ret(file != nullptr);
-  fc_assert_ret(prgbcolor != nullptr);
-
   va_start(args, path);
   fc_vsnprintf(colorpath, sizeof(colorpath), path, args);
   va_end(args);
@@ -142,7 +134,6 @@ void rgbcolor_save(struct section_file *file,
 bool rgbcolor_to_hex(const struct rgbcolor *prgbcolor, char *hex,
                      size_t hex_len)
 {
-  fc_assert_ret_val(prgbcolor != nullptr, FALSE);
   /* Needs a length greater than 7 ('#' + 6 hex digites and '\0'). */
   fc_assert_ret_val(hex_len > 7, FALSE);
 
@@ -165,7 +156,6 @@ bool rgbcolor_from_hex(struct rgbcolor **prgbcolor, const char *hex)
   char hex2[16];
 
   fc_assert_ret_val(*prgbcolor == nullptr, FALSE);
-  fc_assert_ret_val(hex != nullptr, FALSE);
 
   if (hex[0] == '#') {
     hex++;
diff --git a/common/rgbcolor.h b/common/rgbcolor.h
index c4027f30ce..dc87c27700 100644
--- a/common/rgbcolor.h
+++ b/common/rgbcolor.h
@@ -64,20 +64,26 @@ struct rgbcolor {
   }
 
 struct rgbcolor *rgbcolor_new(int r, int g, int b);
-struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor);
-bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2);
+struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor)
+  fc__attribute((nonnull(1)));
+bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2)
+  fc__attribute((nonnull(1, 2)));
 void rgbcolor_destroy(struct rgbcolor *prgbcolor);
 
 bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor,
                    char *path, ...)
-                   fc__attribute((__format__ (__printf__, 3, 4)));
+                   fc__attribute((__format__ (__printf__, 3, 4)))
+                   fc__attribute((nonnull(1)));
 void rgbcolor_save(struct section_file *file,
                    const struct rgbcolor *prgbcolor, char *path, ...)
-                   fc__attribute((__format__ (__printf__, 3, 4)));
+                   fc__attribute((__format__ (__printf__, 3, 4)))
+                   fc__attribute((nonnull(1, 2)));
 
 bool rgbcolor_to_hex(const struct rgbcolor *prgbcolor, char *hex,
-                     size_t hex_len);
-bool rgbcolor_from_hex(struct rgbcolor **prgbcolor, const char *hex);
+                     size_t hex_len)
+  fc__attribute((nonnull(1)));
+bool rgbcolor_from_hex(struct rgbcolor **prgbcolor, const char *hex)
+  fc__attribute((nonnull(1, 2)));
 
 int rgbcolor_brightness_score(struct rgbcolor *prgbcolor);
 
-- 
2.53.0

