Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'glyph' may be used uninitialized in 'kmscon_font_pango_render' (src/font_pango.c) #49

Closed
Infinidoge opened this issue Jun 27, 2022 · 3 comments

Comments

@Infinidoge
Copy link

Infinidoge commented Jun 27, 2022

I'm working to update the Nixpkgs version of kmscon (see NixOS/nixpkgs#178749), and I ran into an interesting warning thrown by the compiler:

[16/85] Compiling C object src/mod-pango.so.p/font_pango.c.o
FAILED: src/mod-pango.so.p/font_pango.c.o 
gcc -Isrc/mod-pango.so.p -Isrc -I../src -Iexternal -I../external -I/nix/store/fd9xgi1wnr21cf6r4g4wg0r1x3q1sfmp-libtsm-4.0.2//ni
x/store/fd9xgi1wnr21cf6r4g4wg0r1x3q1sfmp-libtsm-4.0.2/include -I/nix/store/h3rq434kc322x4jmzfzijfvvw4dn28q9-pango-1.50.7-dev/in
clude/pango-1.0 -I/nix/store/00gc9zv7daj8dx5nnv22klw8y09df1dp-fontconfig-2.13.94-dev/include -I/nix/store/0iyadd7k48mwx2g21rms1
4y6a8k13ca7-freetype-2.12.1-dev/include/freetype2 -I/nix/store/92p7s7grpcwx8jlbnjc7vhw2kqggr6xv-glib-2.72.1-dev/include -I/nix/store/92p7s7grpcwx8jlbnjc7vhw2kqggr6xv-glib-2.72.1-dev/include/glib-2.0 -I/nix/store/rk79fi264q6bc5mmvcabajh9kvqr7018-glib-2.72.1/lib/glib-2.0/include -I/nix/store/k1prvgi3vr3ln80wgh37ckaihwwg1w5a-harfbuzz-3.3.2-dev/include/harfbuzz -I/nix/store/ak01zssa4jdsswn6gixaxzdw6kjiqc3l-libxkbcommon-1.4.0-dev/include -I/nix/store/vb5r08wxkarnl9sqnz2888w99lvfwhzn-libglvnd-1.4.0-dev/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=gnu99 -O0 -ffast-math -fno-strict-aliasing -ffunction-sections -fdata-sections -fstack-protector -fvisibility=hidden -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -include /build/source/build/config.h -fPIC -pthread -MD -MQ src/mod-pango.so.p/font_pango.c.o -MF src/mod-pango.so.p/font_pango.c.o.d -o src/mod-pango.so.p/font_pango.c.o -c ../src/font_pango.c
../src/font_pango.c: In function 'kmscon_font_pango_render':
../src/font_pango.c:436:14: error: 'glyph' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  436 |         *out = glyph;
      |         ~~~~~^~~~~~~
cc1: all warnings being treated as errors

I don't have much experience with writing/debugging C code, so I was unsure if this was a nonissue, or if the code should be edited to remove the compiler warning. (Adding -Wno-error=maybe-uninitialized works to suppress the error, however.)

@Aetf
Copy link
Owner

Aetf commented Jun 27, 2022

I believe it's a false positive. glyph is initialized by get_glyph in

ret = get_glyph(font->data, &glyph, id, ch, len, &font->attr);
.

@Aetf Aetf closed this as completed Jun 27, 2022
@Infinidoge
Copy link
Author

Yeah thought so, will stick with the -Wno-error flag then. Out of curiosity, is there a way to signal to the compiler that that area is a known (and accounted for) issue, so as to not blanket-ignore the entire maybe-uninitialized category?

@Aetf
Copy link
Owner

Aetf commented Jun 27, 2022

There are #pragma directives, but I've never used them before... Not sure how portable they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants