Project

General

Profile

Feature #2001 ยป 0039-rgbcolor.c-Replace-parameter-checking-fc_asserts-wit.patch

Marko Lindqvist, 05/14/2026 04:50 PM

View differences:

common/rgbcolor.c
****************************************************************************/
struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor)
{
fc_assert_ret_val(prgbcolor != nullptr, nullptr);
return rgbcolor_new(prgbcolor->r, prgbcolor->g, prgbcolor->b);
}
......
****************************************************************************/
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);
......
char colorpath[256];
va_list args;
fc_assert_ret_val(file != nullptr, FALSE);
fc_assert_ret_val(*prgbcolor == nullptr, FALSE);
va_start(args, path);
......
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);
......
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);
......
char hex2[16];
fc_assert_ret_val(*prgbcolor == nullptr, FALSE);
fc_assert_ret_val(hex != nullptr, FALSE);
if (hex[0] == '#') {
hex++;
common/rgbcolor.h
}
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);
    (1-1/1)