-
Notifications
You must be signed in to change notification settings - Fork 343
initialize variables in wlr_surface.c #2736
Conversation
This fixes the following warnings/errors with -Werror set (default): ```ninja -C build ninja: Entering directory `build' [26/47] Compiling C object libwlroots.so.7.p/types_wlr_surface.c.o FAILED: libwlroots.so.7.p/types_wlr_surface.c.o cc -Ilibwlroots.so.7.p -I. -I.. -Iinclude -I../include -Iprotocol -I../protocol -I/usr/include/libdrm -I/usr/include/pixman-1 -I/usr/include/uuid -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -DWLR_USE_UNSTABLE -Wundef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wstrict-prototypes -Wimplicit-fallthrough=2 -Wendif-labels -Wstrict-aliasing=2 -Woverflow -Wmissing-prototypes -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter -fmacro-prefix-map=../= -DHAS_LIBUUID=1 '-DICONDIR="/usr/share/icons"' -fPIC -MD -MQ libwlroots.so.7.p/types_wlr_surface.c.o -MF libwlroots.so.7.p/types_wlr_surface.c.o.d -o libwlroots.so.7.p/types_wlr_surface.c.o -c ../types/wlr_surface.c ../types/wlr_surface.c: In function ‘surface_commit_pending’: ../types/wlr_surface.c:235:55: error: ‘src_width’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 235 | float scale_x = (float)pending->viewport.dst_width / src_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ ../types/wlr_surface.c:233:8: note: ‘src_width’ was declared here 233 | int src_width, src_height; | ^~~~~~~~~ ../types/wlr_surface.c:236:56: error: ‘src_height’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 236 | float scale_y = (float)pending->viewport.dst_height / src_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ ../types/wlr_surface.c:233:19: note: ‘src_height’ was declared here 233 | int src_width, src_height; | ^~~~~~~~~~ ../types/wlr_surface.c: In function ‘wlr_surface_get_effective_damage’: ../types/wlr_surface.c:1293:62: error: ‘src_width’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1293 | float scale_x = (float)surface->current.viewport.dst_width / src_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ ../types/wlr_surface.c:1294:63: error: ‘src_height’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1294 | float scale_y = (float)surface->current.viewport.dst_height / src_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ cc1: all warnings being treated as errors ninja: build stopped: subcommand failed. ```
Maybe it is not a good idea to initialize to 0? |
Hm, this will just cause a division by zero in case the buffer size is not divisible by the scale. I wonder if we should keep the scale check in |
prevent pontential division by 0.
This would have to be answered by someone else I am afraid as I do not know how it all fits together. |
This is preventing wlroots-git from building in the AUR. FWIW I think the warning is just wrong here, initializing these variables is pointless, and one should disable the warning, e.g., by using the proper pragma to turn it off locally here. Because of warnings with false-positives / incorrect diagnostics, it makes little sense to use I think |
If you want to initialize this variables to something, initialize them to some invalid value, e.g., |
NACK. See https://github.com/swaywm/wlroots/wiki/Packaging-recommendations. |
Co-authored-by: gnzlbg <gnzlbg@users.noreply.github.com>
Co-authored-by: gnzlbg <gnzlbg@users.noreply.github.com>
Co-authored-by: gnzlbg <gnzlbg@users.noreply.github.com>
Co-authored-by: gnzlbg <gnzlbg@users.noreply.github.com>
This fixes some build warnings. Closes: swaywm#2740 References: swaywm#2736
See the first commit in #2742. |
fixed with #2742 |
This fixes the following warnings/errors with -Werror set (default):