Alan Coopersmith (99141f27) at 02 Mar 00:57
xlsfonts 1.0.8
Signed-off-by
in commits-Wincompatible-pointer-types
warning from gcc (issue #1) reallocarray()
if availableAlan Coopersmith (d20bea49) at 02 Mar 00:55
xlsfonts 1.0.8
Signed-off-by
in commits-Wincompatible-pointer-types
warning from gcc (issue #1) reallocarray()
if availableI think that it would be good to release new version because of this change.
Checks for it in either libc or libbsd
Alan Coopersmith (71d8e89f) at 24 Jan 21:07
Use reallocarray() if available
Checks for it in either libc or libbsd
Modern C compilers are becoming stricter with a variety of changes over the last year or so.
GCC 14 in particular (to be released in ~April 2024) fails to build xlsfonts-1.0.7 like:
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -O3 -pipe -march=native -fno-diagnostics-color -c -o xlsfonts.o xlsfonts.c
xlsfonts.c: In function ‘get_list’:
xlsfonts.c:204:23: error: assignment to ‘char **’ from incompatible pointer type ‘const char **’ [-Wincompatible-pointer-types]
204 | fonts = &pattern;
| ^
Originally reported downstream in Gentoo at https://bugs.gentoo.org/919204.
This can be emulated with -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion
on an older GCC or Clang.
Fix warning that gcc 14 will make into an error
Also includes: gitlab CI: stop requiring Signed-off-by in commits
Alan Coopersmith (2b9d8f5b) at 17 Jan 17:17
Fix -Wincompatible-pointer-types warning from gcc (issue #1)
... and 1 more commit
alanc/xlsfonts@2b9d8f5b is what I think the more complete fix would look like. I can change this MR to cover that change if you think it's better. (Besides the reduced code sharing, this is also going to make it more complex if anyone ever decides we need to free all this memory before exiting - but given this is a "print info and then immediately exit" sort of program, that's just added work for little benefit.)
And because fonts
is passed to XFreeFontNames()
and XFreeFontInfo()
, which don't take const pointers since they're freeing them. I think a more complete fix would make the open_instead_of_list
stop using the same font
pointer as the other case, and thus re-use less of it's code.
As for the larger question, we've avoided changing the char **
to const char **
in our prototypes because compilers won't auto-convert, thus it would be an instant API break for all existing source code. We could possibly take a route similar to what libXt has done, where the consumers opt in by setting a #define before including the header, but no one has put in the effort for that.
Shouldn't we be changing fonts
here to be char const **
instead of changing the references?
Are we doing it this way because XListFontsWithInfo and XListFonts declare their return types as char **
? Should we instead consider fixing that prototype? Yeah, that would have ramifications for all clients, but the alternative is that all clients that want to address this have warts to workaround the missing const
in our prototypes.
Thanks, this lgtm and it also fixes the reported issue.
Fix warning that gcc 14 will make into an error
Also includes: gitlab CI: stop requiring Signed-off-by in commits
Modern C compilers are becoming stricter with a variety of changes over the last year or so.
GCC 14 in particular (to be released in ~April 2024) fails to build xlsfonts-1.0.7 like:
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -O3 -pipe -march=native -fno-diagnostics-color -c -o xlsfonts.o xlsfonts.c
xlsfonts.c: In function ‘get_list’:
xlsfonts.c:204:23: error: assignment to ‘char **’ from incompatible pointer type ‘const char **’ [-Wincompatible-pointer-types]
204 | fonts = &pattern;
| ^
Originally reported downstream in Gentoo at https://bugs.gentoo.org/919204.
This can be emulated with -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion
on an older GCC or Clang.
Try to answer the question "How is this different from fslsfonts?" as raised in https://lists.x.org/archives/xorg/2022-September/061099.html
Alan Coopersmith (314d802f) at 17 Sep 15:19
man page: emphasize this program is for querying an X server
Try to answer the question "How is this different from fslsfonts?" as raised in https://lists.x.org/archives/xorg/2022-September/061099.html