"Modern C" and the X.Org software

Alan Coopersmith alan.coopersmith at oracle.com
Mon Dec 11 22:29:51 UTC 2023


As folks may have seen from https://lwn.net/Articles/954018/ or elsewhere,
there's efforts underway to make more warnings into errors in gcc & clang,
and as part of those, people are compiling their distros/packages with
flags to turn warnings like this into errors:

   -Wimplicit-function-declaration
   -Wimplicit-int
   -Wint-conversion
   -Wreturn-mismatch (new, previously part of -Wreturn-types)
   -Wdeclaration-missing-parameter-type (new, previously unnamed)
   -Wincompatible-pointer-types

Fortunately, we've had some of these in our default compiler flags from
xorg-macros for over a decade, as long as the compiler seems to support
them - both -Werror=implicit & -Werror=return-type.

Sam James from Gentoo filed bugs for 4 issues found in their testing
over the past week.  I've added the flags and did my own test builds
on Solaris 11.4 using the autoconf-2.72d beta that makes autoconf tests
work with these flags, and found some more myself.  I've also looked
through the Gentoo & Fedora lists at
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/GKCRXZESHSCCEKED2N5GNQ7GH32VSK2X/
https://bugs.gentoo.org/showdependencytree.cgi?id=870412&hide_resolved=1
to see if they'd found any more, and I think we've found all the ones
in the packages we maintain via X.Org.


The fixes I've proposed for these are:

xkbwatch: Fix -Wincompatible-pointer-types warning (issue #2)
https://gitlab.freedesktop.org/xorg/app/xkbutils/-/merge_requests/4

Fix -Wincompatible-pointer-types warning from gcc (issue #1)
https://gitlab.freedesktop.org/xorg/app/xlsfonts/-/merge_requests/6

Fix -Wincompatible-pointer-types warning from gcc (issue #15)
https://gitlab.freedesktop.org/xorg/app/xdm/-/merge_requests/18

Fix -Wincompatible-pointer-types warning (Issue #3)
https://gitlab.freedesktop.org/xorg/util/imake/-/merge_requests/8

Multisink.c: Clear -Werror=incompatible-pointer-types error
https://gitlab.freedesktop.org/xorg/lib/libxaw3d/-/merge_requests/10


I also added -std=gnu23 to my build flags, which found one more issue
due to C23 defining "true" as an rvalue, not an lvalue:

Fix C23 build by renaming variable 'true'
https://gitlab.freedesktop.org/xorg/util/imake/-/merge_requests/8


There were two that I've "fixed" by making the drivers simply not
call xf86DisableRandR in ABI_VIDEODRV_VERSION 24 & later - which may
mean that in the old-style manual rotation configurations attempts
to use RandR will do awful things - but since there were no bugs filed
about use of those config options making the drivers crash trying to
call an unresolvable symbol, I'm guessing no one cares about that:

https://gitlab.freedesktop.org/xorg/driver/xf86-video-nv/-/merge_requests/9
https://gitlab.freedesktop.org/xorg/driver/xf86-video-savage/-/merge_requests/6

(If I'm wrong, someone who does care can submit patches to fix it.)


While I'll probably merge all of the above MR's into git before the holidays,
I don't plan to make any new releases including them until after, so that they
can be released with the final release of autoconf 2.72 (which is planned for
release sometime in the week of Dec. 18 - 22), which has both the fixes for
bugs in autoconf tests caused by these flags and the addition of support for
64-bit time_t in 32-bit programs which some distros/packagers may desire.

-- 
         -Alan Coopersmith-                 alan.coopersmith at oracle.com
          Oracle Solaris Engineering - https://blogs.oracle.com/solaris


More information about the xorg-devel mailing list