swaywm / swaybg

Wallpaper tool for Wayland compositors
MIT License
490 stars 31 forks source link

main.c: fix build against gcc-14 (-Walloc-size) #61

Closed trofi closed 10 months ago

trofi commented 10 months ago

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);
      |                                ^
emersion commented 10 months ago

Thanks!