zsh-workers
 help / color / mirror / Atom feed
* [PATCH 0/3] Build fixes
@ 2020-12-31  5:41 Felipe Contreras
  2020-12-31  5:41 ` [PATCH 1/3] src: fix build warnings Felipe Contreras
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Felipe Contreras @ 2020-12-31  5:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

There's a couple of warnings I get all the time that I've fixed.

And recently Arch Linux updated autoconf to 2.70, which throws a bunch of errors.

Everything seems to be fixed now, and it works fine on autoconf 2.69 as well.

Felipe Contreras (3):
  src: fix build warnings
  autoconf: remove deprecated functions
  autoconf: prepare for 2.70

 Src/Modules/files.c |   6 ---
 Src/mem.c           |  16 ++-----
 Src/pattern.c       |   2 +-
 Src/utils.c         |   3 +-
 Src/zsh_system.h    |  21 +--------
 aclocal.m4          |   8 ++--
 aczsh.m4            | 104 ++++++++++++++++++++++----------------------
 configure.ac        |   4 +-
 8 files changed, 66 insertions(+), 98 deletions(-)

-- 
2.30.0



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

* [PATCH 1/3] src: fix build warnings
  2020-12-31  5:41 [PATCH 0/3] Build fixes Felipe Contreras
@ 2020-12-31  5:41 ` Felipe Contreras
  2021-01-02 11:22   ` Daniel Shahaf
  2020-12-31  5:41 ` [PATCH 2/3] autoconf: remove deprecated functions Felipe Contreras
  2020-12-31  5:41 ` [PATCH 3/3] autoconf: prepare for 2.70 Felipe Contreras
  2 siblings, 1 reply; 8+ messages in thread
From: Felipe Contreras @ 2020-12-31  5:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

  pattern.c: In function ‘patcomppiece’:
  pattern.c:1253:14: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   1253 |     zrange_t from, to;
        |              ^~~~
  utils.c: In function ‘getkeystring’:
  cc1: warning: function may return address of local variable [-Wreturn-local-addr]
  utils.c:6703:16: note: declared here
   6703 |     char *buf, tmp[1];
        |                ^~~

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Src/pattern.c | 2 +-
 Src/utils.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Src/pattern.c b/Src/pattern.c
index c7c2c8bea..c28f2c9fb 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1250,7 +1250,7 @@ patcomppiece(int *flagp, int paren)
     int hash, count;
     union upat up;
     char *nptr, *str0, *ptr, *patprev;
-    zrange_t from, to;
+    zrange_t from = 0, to;
     char *charstart;
 
     flags = 0;
diff --git a/Src/utils.c b/Src/utils.c
index 5151b89a8..37ae4c854 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -6700,7 +6700,8 @@ ucs4toutf8(char *dest, unsigned int wval)
 mod_export char *
 getkeystring(char *s, int *len, int how, int *misc)
 {
-    char *buf, tmp[1];
+    static char tmp[1];
+    char *buf;
     char *t, *tdest = NULL, *u = NULL, *sstart = s, *tbuf = NULL;
     char svchar = '\0';
     int meta = 0, control = 0, ignoring = 0;
-- 
2.30.0



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

* [PATCH 2/3] autoconf: remove deprecated functions
  2020-12-31  5:41 [PATCH 0/3] Build fixes Felipe Contreras
  2020-12-31  5:41 ` [PATCH 1/3] src: fix build warnings Felipe Contreras
@ 2020-12-31  5:41 ` Felipe Contreras
  2020-12-31  5:41 ` [PATCH 3/3] autoconf: prepare for 2.70 Felipe Contreras
  2 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2020-12-31  5:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

STDC_HEADERS and TIME_WITH_SYS_TIME are deprecated.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Src/Modules/files.c |  6 ------
 Src/mem.c           | 16 ++++------------
 Src/zsh_system.h    | 21 ++-------------------
 configure.ac        |  4 +---
 4 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/Src/Modules/files.c b/Src/Modules/files.c
index 7ebacba6c..a1d6f6bf2 100644
--- a/Src/Modules/files.c
+++ b/Src/Modules/files.c
@@ -32,12 +32,6 @@
 typedef int (*MoveFunc) _((char const *, char const *));
 typedef int (*RecurseFunc) _((char *, char *, struct stat const *, void *));
 
-#ifndef STDC_HEADERS
-extern int link _((const char *, const char *));
-extern int symlink _((const char *, const char *));
-extern int rename _((const char *, const char *));
-#endif
-
 struct recursivecmd;
 
 #include "files.pro"
diff --git a/Src/mem.c b/Src/mem.c
index 5951e57ed..25b2bbce7 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1072,18 +1072,10 @@ zrealloc(void *ptr, size_t size)
 # endif
 #endif
 
-#if defined(_BSD) && !defined(STDC_HEADERS)
-# define FREE_RET_T   int
-# define FREE_ARG_T   char *
-# define FREE_DO_RET
-# define MALLOC_RET_T char *
-# define MALLOC_ARG_T size_t
-#else
-# define FREE_RET_T   void
-# define FREE_ARG_T   void *
-# define MALLOC_RET_T void *
-# define MALLOC_ARG_T size_t
-#endif
+#define FREE_RET_T   void
+#define FREE_ARG_T   void *
+#define MALLOC_RET_T void *
+#define MALLOC_ARG_T size_t
 
 /* structure for building free list in blocks holding small blocks */
 
diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 161b073b4..6f4efce96 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -235,16 +235,8 @@ char *alloca _((size_t));
 # include <errno.h>
 #endif
 
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
+#include <sys/time.h>
+#include <time.h>
 
 /* This is needed by some old SCO unices */
 #if !defined(HAVE_STRUCT_TIMEZONE) && !defined(ZSH_OOT_MODULE)
@@ -279,16 +271,7 @@ struct timespec {
 # include <sys/times.h>
 #endif
 
-#if STDC_HEADERS || HAVE_STRING_H
 # include <string.h>
-/* An ANSI string.h and pre-ANSI memory.h might conflict.  */
-# if !STDC_HEADERS && HAVE_MEMORY_H
-#  include <memory.h>
-# endif /* not STDC_HEADERS and HAVE_MEMORY_H */
-#else   /* not STDC_HEADERS and not HAVE_STRING_H */
-# include <strings.h>
-/* memory.h and strings.h conflict on some systems.  */
-#endif /* not STDC_HEADERS and not HAVE_STRING_H */
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
diff --git a/configure.ac b/configure.ac
index 549cae3d6..c39915528 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ dnl
 AC_INIT
 AC_CONFIG_SRCDIR([Src/zsh.h])
 AC_PREREQ([2.69])
-AC_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS([config.h])
 
 dnl What version of zsh are we building ?
 . ${srcdir}/Config/version.mk
@@ -657,8 +657,6 @@ dnl ------------------
 dnl CHECK HEADER FILES
 dnl ------------------
 AC_HEADER_DIRENT
-AC_HEADER_STDC
-AC_HEADER_TIME
 AC_HEADER_STAT
 AC_HEADER_SYS_WAIT
 
-- 
2.30.0



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

* [PATCH 3/3] autoconf: prepare for 2.70
  2020-12-31  5:41 [PATCH 0/3] Build fixes Felipe Contreras
  2020-12-31  5:41 ` [PATCH 1/3] src: fix build warnings Felipe Contreras
  2020-12-31  5:41 ` [PATCH 2/3] autoconf: remove deprecated functions Felipe Contreras
@ 2020-12-31  5:41 ` Felipe Contreras
  2 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2020-12-31  5:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 aclocal.m4 |   8 ++---
 aczsh.m4   | 104 ++++++++++++++++++++++++++---------------------------
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index e91be3c0d..c26e2d834 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -35,14 +35,14 @@ ac_save_CFLAGS="$CFLAGS"
 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" -Xc
 do
   CFLAGS="$ac_save_CFLAGS $ac_arg"
-  AC_TRY_COMPILE(
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 [#ifndef __STDC__
 choke me
 #endif	
-], [int test (int i, double x);
+]], [[int test (int i, double x);
 struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};],
-[fp_cv_prog_cc_stdc="$ac_arg"; break])
+struct s2 {int (*f) (double a);};]])],
+[fp_cv_prog_cc_stdc="$ac_arg"; break],[])
 done
 CFLAGS="$ac_save_CFLAGS"
 ])
diff --git a/aczsh.m4 b/aczsh.m4
index 40d3b04f2..c04bf9190 100644
--- a/aczsh.m4
+++ b/aczsh.m4
@@ -39,7 +39,7 @@ dnl   before finding the right type.
 dnl
 
 AC_DEFUN(zsh_64_BIT_TYPE,
-[AC_TRY_RUN([
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -50,7 +50,7 @@ main()
   int bar = (int) foo;
   return sizeof($1) != 8;
 }
-], $2="$1", $2=no,
+]])],[$2="$1"],[$2=no],
   [if test x$3 != x ; then
     $2="$1"
   else
@@ -113,11 +113,11 @@ void *zsh_getaddr1()
 };
 ' > conftest1.c
 sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c
-if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
-    AC_TRY_RUN([
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -170,7 +170,7 @@ main()
     if(sym1 != sym2) exit(1);
     exit(0);
 }
-], [zsh_cv_shared_$1=yes],
+]])],[zsh_cv_shared_$1=yes],
 [zsh_cv_shared_$1=no],
 [zsh_cv_shared_$1=no]
 )
@@ -195,11 +195,11 @@ else
 fi
 echo 'int fred () { return 42; }' > conftest1.c
 echo 'int fred () { return 69; }' > conftest2.c
-if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
-    AC_TRY_RUN([
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -242,7 +242,7 @@ main()
     if(!fred1 || !fred2) exit(1);
     exit((*fred1)() != 42 || (*fred2)() != 69);
 }
-], [zsh_cv_sys_dynamic_clash_ok=yes],
+]])],[zsh_cv_sys_dynamic_clash_ok=yes],
 [zsh_cv_sys_dynamic_clash_ok=no],
 [zsh_cv_sys_dynamic_clash_ok=no]
 )
@@ -271,11 +271,11 @@ else
 fi
 echo 'int fred () { return 42; }' > conftest1.c
 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c
-if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
-    AC_TRY_RUN([
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -316,7 +316,7 @@ main()
     if(!barneysym) exit(1);
     exit((*barneysym)() != 69);
 }
-], [zsh_cv_sys_dynamic_rtld_global=yes],
+]])],[zsh_cv_sys_dynamic_rtld_global=yes],
 [zsh_cv_sys_dynamic_rtld_global=no],
 [zsh_cv_sys_dynamic_rtld_global=no]
 )
@@ -341,11 +341,11 @@ else
     us=
 fi
 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest1.c
-if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
     save_ldflags=$LDFLAGS
     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
-    AC_TRY_RUN([
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -386,7 +386,7 @@ main()
 }
 
 int fred () { return 42; }
-], [zsh_cv_sys_dynamic_execsyms=yes],
+]])],[zsh_cv_sys_dynamic_execsyms=yes],
 [zsh_cv_sys_dynamic_execsyms=no],
 [zsh_cv_sys_dynamic_execsyms=no]
 )
@@ -415,11 +415,11 @@ elif
 	us=
     fi
     echo 'extern int fred(); int barney() { return fred() + 27; }' > conftest1.c
-    AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-    AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
+    AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+    AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
     save_ldflags=$LDFLAGS
     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -s"
-    AC_TRY_RUN([
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -460,7 +460,7 @@ main()
 }
 
 int fred () { return 42; }
-], [zsh_cv_sys_dynamic_strip_exe=yes],
+]])],[zsh_cv_sys_dynamic_strip_exe=yes],
 [zsh_cv_sys_dynamic_strip_exe=no],
 [zsh_cv_sys_dynamic_strip_exe=no]
 )
@@ -485,9 +485,9 @@ else
     us=
 fi
 echo 'int fred () { return 42; }' > conftest1.c
-if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
-AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AC_FD_CC); then
-    AC_TRY_RUN([
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdlib.h>
 #ifdef HPUX10DYNAMIC
 #include <dl.h>
@@ -526,7 +526,7 @@ main()
     if(!fredsym) exit(1);
     exit((*fredsym)() != 42);
 }
-], [zsh_cv_sys_dynamic_strip_lib=yes],
+]])],[zsh_cv_sys_dynamic_strip_lib=yes],
 [zsh_cv_sys_dynamic_strip_lib=no],
 [zsh_cv_sys_dynamic_strip_lib=no]
 )
@@ -564,7 +564,7 @@ dnl
 
 AC_DEFUN(zsh_TYPE_EXISTS,
 [AC_CACHE_CHECK([for $2], [zsh_cv_type_exists_[]translit($2, [ ], [_])],
-[AC_TRY_COMPILE([$1], [$2 testvar;],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2 testvar;]])],
 [zsh_cv_type_exists_[]translit($2, [ ], [_])=yes],
 [zsh_cv_type_exists_[]translit($2, [ ], [_])=no])
 ])
@@ -583,7 +583,7 @@ dnl
 
 AC_DEFUN(zsh_STRUCT_MEMBER,
 [AC_CACHE_CHECK([for $3 in $2], [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3],
-[AC_TRY_COMPILE([$1], [$2 testvar; testvar.$3;],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2 testvar; testvar.$3;]])],
 [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=yes],
 [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=no])
 ])
@@ -621,25 +621,25 @@ AC_SUBST(tzsh)dnl
 
 AC_DEFUN(zsh_COMPILE_FLAGS,
     [AC_ARG_ENABLE(cppflags,
-	AC_HELP_STRING([--enable-cppflags=...], [specify C preprocessor flags]),
+	AS_HELP_STRING([--enable-cppflags=...], [specify C preprocessor flags]),
 	if test "$enableval" = "yes"
 	then CPPFLAGS="$1"
 	else CPPFLAGS="$enable_cppflags"
 	fi)
     AC_ARG_ENABLE(cflags,
-	AC_HELP_STRING([--enable-cflags=...], [specify C compiler flags]),
+	AS_HELP_STRING([--enable-cflags=...], [specify C compiler flags]),
 	if test "$enableval" = "yes"
 	then CFLAGS="$2"
 	else CFLAGS="$enable_cflags"
 	fi)
     AC_ARG_ENABLE(ldflags,
-	AC_HELP_STRING([--enable-ldflags=...], [specify linker flags]),
+	AS_HELP_STRING([--enable-ldflags=...], [specify linker flags]),
 	if test "$enableval" = "yes"
 	then LDFLAGS="$3"
 	else LDFLAGS="$enable_ldflags"
 	fi)
     AC_ARG_ENABLE(libs,
-	AC_HELP_STRING([--enable-libs=...], [specify link libraries]),
+	AS_HELP_STRING([--enable-libs=...], [specify link libraries]),
 	if test "$enableval" = "yes"
 	then LIBS="$4"
 	else LIBS="$enable_libs"
@@ -658,10 +658,10 @@ AC_DEFUN([zsh_CHECK_SOCKLEN_T],[
     [zsh_cv_type_socklen_t],
     [zsh_cv_type_socklen_t=
     for zsh_type in socklen_t int "unsigned long" size_t ; do
-      AC_TRY_COMPILE(
-        [#include <sys/types.h>
-         #include <sys/socket.h>],
-        [extern int accept (int, struct sockaddr *, $zsh_type *);],
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+        [[#include <sys/types.h>
+          #include <sys/socket.h>]],
+        [[extern int accept (int, struct sockaddr *, $zsh_type *);]])],
         [zsh_cv_type_socklen_t="$zsh_type"; break],
         []
       )
@@ -680,15 +680,15 @@ AC_DEFUN(zsh_LIMIT_PRESENT,
 [Define to 1 if ]$1[ is present (whether or not as a macro).])
 AC_CACHE_CHECK([for limit $1],
 zsh_cv_have_$1,
-[AC_TRY_COMPILE([
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-#include <sys/resource.h>],
-[$1],
-  zsh_cv_have_$1=yes,
-  zsh_cv_have_$1=no)])
+#include <sys/resource.h>]],
+[[$1]])],
+  [zsh_cv_have_$1=yes],
+  [zsh_cv_have_$1=no])])
 
 if test $zsh_cv_have_$1 = yes; then
   AC_DEFINE(HAVE_$1)
@@ -701,15 +701,15 @@ AC_DEFUN(zsh_LIMITS_EQUAL,
 [Define to 1 if RLIMIT_]$1[ and RLIMIT_]$3[ both exist and are equal.])
 AC_CACHE_CHECK([if RLIMIT_]$1[ and RLIMIT_]$3[ are the same],
 zsh_cv_rlimit_$2_is_$4,
-[AC_TRY_COMPILE([
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-#include <sys/resource.h>],
-[static char x[(RLIMIT_$1 == RLIMIT_$3)? 1 : -1]],
-  zsh_cv_rlimit_$2_is_$4=yes,
-  zsh_cv_rlimit_$2_is_$4=no)])
+#include <sys/resource.h>]],
+[[static char x[(RLIMIT_$1 == RLIMIT_$3)? 1 : -1]]])],
+  [zsh_cv_rlimit_$2_is_$4=yes],
+  [zsh_cv_rlimit_$2_is_$4=no])])
 if test x$zsh_cv_rlimit_$2_is_$4 = xyes; then
   AC_DEFINE(RLIMIT_$1_IS_$3)
 fi])
-- 
2.30.0



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

* Re: [PATCH 1/3] src: fix build warnings
  2020-12-31  5:41 ` [PATCH 1/3] src: fix build warnings Felipe Contreras
@ 2021-01-02 11:22   ` Daniel Shahaf
  2021-01-02 16:41     ` Mikael Magnusson
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Shahaf @ 2021-01-02 11:22 UTC (permalink / raw)
  To: Felipe Contreras, zsh-workers

Felipe Contreras wrote on Thu, 31 Dec 2020 05:41 +00:00:
>   utils.c: In function ‘getkeystring’:
>   cc1: warning: function may return address of local variable [-Wreturn-local-addr]
>   utils.c:6703:16: note: declared here
>    6703 |     char *buf, tmp[1];
>         |                ^~~
> 
> diff --git a/Src/utils.c b/Src/utils.c
> index 5151b89a8..37ae4c854 100644
> --- a/Src/utils.c
> +++ b/Src/utils.c
> @@ -6700,7 +6700,8 @@ ucs4toutf8(char *dest, unsigned int wval)
>  mod_export char *
>  getkeystring(char *s, int *len, int how, int *misc)
>  {
> -    char *buf, tmp[1];
> +    static char tmp[1];
> +    char *buf;

The docstring explicitly promises the returned string will be newly-
allocated from the heap, so this change makes the implementation
inconsistent with the docstring.

No comment on the pattern.c part.


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

* Re: [PATCH 1/3] src: fix build warnings
  2021-01-02 11:22   ` Daniel Shahaf
@ 2021-01-02 16:41     ` Mikael Magnusson
  2021-01-02 18:30       ` Felipe Contreras
  0 siblings, 1 reply; 8+ messages in thread
From: Mikael Magnusson @ 2021-01-02 16:41 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Felipe Contreras, zsh-workers

On 1/2/21, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Felipe Contreras wrote on Thu, 31 Dec 2020 05:41 +00:00:
>>   utils.c: In function ‘getkeystring’:
>>   cc1: warning: function may return address of local variable
>> [-Wreturn-local-addr]
>>   utils.c:6703:16: note: declared here
>>    6703 |     char *buf, tmp[1];
>>         |                ^~~
>>
>> diff --git a/Src/utils.c b/Src/utils.c
>> index 5151b89a8..37ae4c854 100644
>> --- a/Src/utils.c
>> +++ b/Src/utils.c
>> @@ -6700,7 +6700,8 @@ ucs4toutf8(char *dest, unsigned int wval)
>>  mod_export char *
>>  getkeystring(char *s, int *len, int how, int *misc)
>>  {
>> -    char *buf, tmp[1];
>> +    static char tmp[1];
>> +    char *buf;
>
> The docstring explicitly promises the returned string will be newly-
> allocated from the heap, so this change makes the implementation
> inconsistent with the docstring.

If we ever return the address of tmp, bad things are likely to happen
regardless of the static so hopefully that never happens. Returning
the address of a local variable basically means it will be junk
(current hypothetical behavior), whereas returning a static means the
function wouldn't be re-entrant (hypothetical behavior with the
patch). I don't think any reading of "newly allocated from the heap"
would include a location on a popped stack though, so I don't see how
the docstring enters into it at all.

-- 
Mikael Magnusson


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

* Re: [PATCH 1/3] src: fix build warnings
  2021-01-02 16:41     ` Mikael Magnusson
@ 2021-01-02 18:30       ` Felipe Contreras
  2021-01-04  5:14         ` Daniel Shahaf
  0 siblings, 1 reply; 8+ messages in thread
From: Felipe Contreras @ 2021-01-02 18:30 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Daniel Shahaf, Zsh hackers list

On Sat, Jan 2, 2021 at 10:41 AM Mikael Magnusson <mikachu@gmail.com> wrote:

> If we ever return the address of tmp, bad things are likely to happen
> regardless of the static so hopefully that never happens. Returning
> the address of a local variable basically means it will be junk
> (current hypothetical behavior), whereas returning a static means the
> function wouldn't be re-entrant (hypothetical behavior with the
> patch).

Correct, but one is more proper than the other, and it gets rid of the warning.

The best fix is to allocate one byte, especially if it's going to be
freed later on.

-- 
Felipe Contreras


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

* Re: [PATCH 1/3] src: fix build warnings
  2021-01-02 18:30       ` Felipe Contreras
@ 2021-01-04  5:14         ` Daniel Shahaf
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Shahaf @ 2021-01-04  5:14 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Mikael Magnusson, Zsh hackers list

Felipe Contreras wrote on Sat, 02 Jan 2021 12:30 -0600:
> The best fix is to allocate one byte, especially if it's going to be
> freed later on.

Yes, please revise the patch to allocate byte(s) from the heap as
needed.  (See comments at the top of mem.c, and, for instance,
dupstring() v. ztrdup().)


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

end of thread, other threads:[~2021-01-04  5:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31  5:41 [PATCH 0/3] Build fixes Felipe Contreras
2020-12-31  5:41 ` [PATCH 1/3] src: fix build warnings Felipe Contreras
2021-01-02 11:22   ` Daniel Shahaf
2021-01-02 16:41     ` Mikael Magnusson
2021-01-02 18:30       ` Felipe Contreras
2021-01-04  5:14         ` Daniel Shahaf
2020-12-31  5:41 ` [PATCH 2/3] autoconf: remove deprecated functions Felipe Contreras
2020-12-31  5:41 ` [PATCH 3/3] autoconf: prepare for 2.70 Felipe Contreras

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git