diff options
author | Sergei Trofimovich <slyich@gmail.com> | 2023-11-02 20:04:24 +0000 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-11-02 21:10:40 +0100 |
commit | 435be14610a4b4538adc6a926160ed434ff630fa (patch) | |
tree | 1c40373dbc5a9e86409138eaf638eb2127a8802f /main.c | |
parent | a67361ed48bd63d7f1bda7e61140c64aecc72b9a (diff) | |
download | swaybg-435be14610a4b4538adc6a926160ed434ff630fa.tar.gz swaybg-435be14610a4b4538adc6a926160ed434ff630fa.tar.bz2 |
main.c: fix build against gcc-14 (-Walloc-size)
`gcc-14` added a new `-Walloc-size` warning that makes sure that size of
an individual element matches size of a pointed type:
https://gcc.gnu.org/PR71219
`swaybg` triggers it on `calloc()` calls where member size is used as
`1` (instead of member count):
../main.c:492:32: error: allocation of insufficient size '1' for type 'struct swaybg_output_config' with size '48' [-Werror=alloc-size]
492 | config = calloc(sizeof(struct swaybg_output_config), 1);
| ^
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -455,7 +455,7 @@ static void parse_command_line(int argc, char **argv, "Background Modes:\n" " stretch, fit, fill, center, tile, or solid_color\n"; - struct swaybg_output_config *config = calloc(sizeof(struct swaybg_output_config), 1); + struct swaybg_output_config *config = calloc(1, sizeof(struct swaybg_output_config)); config->output = strdup("*"); config->mode = BACKGROUND_MODE_INVALID; wl_list_init(&config->link); // init for safe removal @@ -489,7 +489,7 @@ static void parse_command_line(int argc, char **argv, // Empty config or merged on top of an existing one destroy_swaybg_output_config(config); } - config = calloc(sizeof(struct swaybg_output_config), 1); + config = calloc(1, sizeof(struct swaybg_output_config)); config->output = strdup(optarg); config->mode = BACKGROUND_MODE_INVALID; wl_list_init(&config->link); // init for safe removal |