zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/2] Fix incompatible-pointer-types bugs
       [not found] <cover.1702244907.git.nvinson234@gmail.com>
@ 2023-12-10 21:49 ` Nicholas Vinson
  2023-12-10 21:49 ` [PATCH 2/2] Fix incompatible-pointer-types configure test bugs Nicholas Vinson
  1 sibling, 0 replies; 2+ messages in thread
From: Nicholas Vinson @ 2023-12-10 21:49 UTC (permalink / raw)
  To: zsh-workers; +Cc: Nicholas Vinson

Fix incompatible-pointer-types in fallback code.

When the flag -Werror=incompatible-pointer-types is passed to gcc, the
fallback code will fail to compile due to incompatible pointer types.

Beginning with gcc-14, -Werror=incompatible-pointer-typees will default
to enabled. See:
https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3F
https://inbox.sourceware.org/gcc-patches/cover.1700473918.git.fweimer@redhat.com/
for details.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 Src/Modules/termcap.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
index af4009a3a..28b48c24c 100644
--- a/Src/Modules/termcap.c
+++ b/Src/Modules/termcap.c
@@ -42,18 +42,21 @@
 #ifdef HAVE_TGETENT
 
 #ifndef HAVE_BOOLCODES
-static char *boolcodes[] = {
+static const char * const zboolcodes[] = {
     "bw", "am", "ut", "cc", "xs", "YA", "YF", "YB", "xt", "xn", "eo",
     "gn", "hc", "HC", "km", "YC", "hs", "hl", "in", "YG", "da", "db",
     "mi", "ms", "nx", "xb", "NP", "ND", "NR", "os", "5i", "YD", "YE",
     "es", "hz", "ul", "xo", NULL};
+#   define BOOLCODES zboolcodes
+#else
+#   define BOOLCODES boolcodes
 #endif
 
 /**/
 static int
-ztgetflag(char *s)
+ztgetflag(const char *s)
 {
-    char **b;
+    const char * const *b;
 
     /* ncurses can tell if an existing boolean capability is *
      * off, but other curses variants can't, so we fudge it. *
@@ -63,7 +66,7 @@ ztgetflag(char *s)
     case -1:
 	break;
     case 0:
-	for (b = (char **)boolcodes; *b; ++b)
+	for (b = BOOLCODES; *b; ++b)
 	    if (s[0] == (*b)[0] && s[1] == (*b)[1])
 		return 0;
 	break;
@@ -201,18 +204,22 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
 {
     Param pm = NULL;
     int num;
-    char **capcode, *tcstr, buf[2048], *u;
+    char *tcstr, buf[2048], *u;
+    const char * const *capcode;
 
 #ifndef HAVE_NUMCODES
-    static char *numcodes[] = {
+    static const char * const znumcodes[] = {
 	"co", "it", "lh", "lw", "li", "lm", "sg", "ma", "Co", "pa", "MW",
 	"NC", "Nl", "pb", "vt", "ws", "Yo", "Yp", "Ya", "BT", "Yc", "Yb",
 	"Yd", "Ye", "Yf", "Yg", "Yh", "Yi", "Yk", "Yj", "Yl", "Ym", "Yn",
 	NULL};
+#   define NUMCODES znumcodes
+#else
+#   define NUMCODES numcodes
 #endif
 
 #ifndef HAVE_STRCODES
-    static char *zstrcodes[] = {
+    static const char * const zstrcodes[] = {
 	"ac", "bt", "bl", "cr", "ZA", "ZB", "ZC", "ZD", "cs", "rP", "ct",
 	"MC", "cl", "cb", "ce", "cd", "ch", "CC", "CW", "cm", "do", "ho",
 	"vi", "le", "CM", "ve", "nd", "ll", "up", "vs", "ZE", "dc", "dl",
@@ -249,6 +256,9 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
 	"S1", "Yy", "S2", "S4", "S3", "S5", "Gm", "Km", "Mi", "S6", "xl",
 	"RQ", "S7", "s0", "s1", "s2", "s3", "AB", "AF", "Yz", "ML", "YZ",
 	"MT", "Xh", "Xl", "Xo", "Xr", "Xt", "Xv", "sA", "sL", NULL};
+#   define STRCODES zstrcodes
+#else
+#   define STRCODES strcodes
 #endif
 
     pm = (Param) hcalloc(sizeof(struct param));
@@ -257,7 +267,7 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
     pm->node.flags = PM_READONLY | PM_SCALAR;
     pm->gsu.s = &nullsetscalar_gsu;
 
-    for (capcode = (char **)boolcodes; *capcode; capcode++) {
+    for (capcode = BOOLCODES; *capcode; capcode++) {
 	if ((num = ztgetflag(*capcode)) != -1) {
 	    pm->u.str = num ? dupstring("yes") : dupstring("no");
 	    pm->node.nam = dupstring(*capcode);
@@ -268,7 +278,7 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
     pm->node.flags = PM_READONLY | PM_INTEGER;
     pm->gsu.i = &nullsetinteger_gsu;
 
-    for (capcode = (char **)numcodes; *capcode; capcode++) {
+    for (capcode = NUMCODES; *capcode; capcode++) {
 	if ((num = tgetnum(*capcode)) != -1) {
 	    pm->u.val = num;
 	    pm->node.nam = dupstring(*capcode);
@@ -279,13 +289,7 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
     pm->node.flags = PM_READONLY | PM_SCALAR;
     pm->gsu.s = &nullsetscalar_gsu;
 
-    for (capcode = (char **)
-#ifdef HAVE_STRCODES
-	     strcodes
-#else
-	     zstrcodes
-#endif
-	     ; *capcode; capcode++) {
+    for (capcode = STRCODES; *capcode; capcode++) {
 	if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
 	    tcstr != (char *)-1) {
 	    pm->u.str = dupstring(tcstr);
-- 
2.43.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Fix incompatible-pointer-types configure test bugs
       [not found] <cover.1702244907.git.nvinson234@gmail.com>
  2023-12-10 21:49 ` [PATCH 1/2] Fix incompatible-pointer-types bugs Nicholas Vinson
@ 2023-12-10 21:49 ` Nicholas Vinson
  1 sibling, 0 replies; 2+ messages in thread
From: Nicholas Vinson @ 2023-12-10 21:49 UTC (permalink / raw)
  To: zsh-workers; +Cc: Nicholas Vinson

When the flag -Werror=incompatible-pointer-types is passed to gcc, the
configure tests will fail to compile due to incompatible pointer types.
This will prevent configure from properly detecting features.

Beginning with gcc-14, -Werror=incompatible-pointer-typees will default
to enabled. See:
https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3F
https://inbox.sourceware.org/gcc-patches/cover.1700473918.git.fweimer@redhat.com/
for details.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 configure.ac | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9cb6e032b..64844f550 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1768,27 +1768,27 @@ if test x$zsh_cv_path_term_header != xnone; then
   fi
 
   AC_MSG_CHECKING(if boolcodes is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no])
   AC_MSG_RESULT($boolcodes)
 
   AC_MSG_CHECKING(if numcodes is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no])
   AC_MSG_RESULT($numcodes)
 
   AC_MSG_CHECKING(if strcodes is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no])
   AC_MSG_RESULT($strcodes)
 
   AC_MSG_CHECKING(if boolnames is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no])
   AC_MSG_RESULT($boolnames)
 
   AC_MSG_CHECKING(if numnames is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no])
   AC_MSG_RESULT($numnames)
 
   AC_MSG_CHECKING(if strnames is available)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[const char * const *test = strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no])
   AC_MSG_RESULT($strnames)
 
   dnl There are apparently defective terminal library headers on some
-- 
2.43.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-10 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1702244907.git.nvinson234@gmail.com>
2023-12-10 21:49 ` [PATCH 1/2] Fix incompatible-pointer-types bugs Nicholas Vinson
2023-12-10 21:49 ` [PATCH 2/2] Fix incompatible-pointer-types configure test bugs Nicholas Vinson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).