[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[screen-devel] [PATCH] Fix -Wimplicit-function-declaration -Wimplicit-in
From: |
Arjun Shankar |
Subject: |
[screen-devel] [PATCH] Fix -Wimplicit-function-declaration -Wimplicit-int |
Date: |
Wed, 8 Mar 2023 13:16:19 +0100 |
During configure, several checks involve C fragments that omit relevant
includes or declare main functions without a return type. This commit
fixes the same.
Signed-off-by: Arjun Shankar <arjun@redhat.com>
---
Note that the patch applies to screen-v4. configure.ac has been rewritten
in the current development branch, master.
We ran into these when trying to port Fedora to modern C:
https://fedoraproject.org/wiki/Changes/PortingToModernC
https://fedoraproject.org/wiki/Toolchain/PortingToModernC
---
src/configure.ac | 105 +++++++++++++++++++++++++++++++----------------
1 file changed, 70 insertions(+), 35 deletions(-)
diff --git a/src/configure.ac b/src/configure.ac
index c0f02df..7264c75 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -159,7 +159,7 @@ AC_CHECKING(for POSIX.1)
AC_EGREP_CPP(YES_IS_DEFINED,
[#include <sys/types.h>
#include <unistd.h>
-main () {
+int main () {
#ifdef _POSIX_VERSION
YES_IS_DEFINED;
#endif
@@ -181,7 +181,7 @@ AC_EGREP_CPP(YES_IS_DEFINED,
AC_CHECKING(SVR4)
AC_EGREP_CPP(yes,
-[main () {
+[int main () {
#if defined(SVR4) || defined(__SVR4)
yes;
#endif
@@ -233,6 +233,7 @@ AC_CHECKING(BSD job jontrol)
AC_TRY_LINK(
[#include <sys/types.h>
#include <sys/ioctl.h>
+#include <unistd.h>
], [
#ifdef POSIX
tcsetpgrp(0, 0);
@@ -250,11 +251,12 @@ dnl
dnl **** setresuid(), setreuid(), seteuid() ****
dnl
AC_CHECKING(setresuid)
-AC_TRY_LINK(,[
+AC_TRY_LINK([#define _GNU_SOURCE
+#include <unistd.h>],[
setresuid(0, 0, 0);
], AC_DEFINE(HAVE_SETRESUID))
AC_CHECKING(setreuid)
-AC_TRY_LINK(,[
+AC_TRY_LINK([#include <unistd.h>],[
setreuid(0, 0);
], AC_DEFINE(HAVE_SETREUID))
dnl
@@ -274,7 +276,7 @@ seteuid(0);
dnl execvpe
AC_CHECKING(execvpe)
-AC_TRY_LINK(,[
+AC_TRY_LINK([#include <unistd.h>],[
execvpe(0, 0, 0);
], AC_DEFINE(HAVE_EXECVPE)
CFLAGS="$CFLAGS -D_GNU_SOURCE")
@@ -284,10 +286,10 @@ dnl **** select() ****
dnl
AC_CHECKING(select)
-AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
+AC_TRY_LINK([#include <sys/select.h>],[select(0, 0, 0, 0, 0);],,
LIBS="$LIBS -lnet -lnsl"
AC_CHECKING(select with $LIBS)
-AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
+AC_TRY_LINK([#include <sys/select.h>],[select(0, 0, 0, 0, 0);],,
AC_MSG_ERROR(!!! no select - no screen))
)
dnl
@@ -306,6 +308,7 @@ AC_TRY_RUN([
#include <sys/stat.h>
#include <fcntl.h>
+#include <stdlib.h>
#ifndef O_NONBLOCK
#define O_NONBLOCK O_NDELAY
@@ -316,7 +319,7 @@ AC_TRY_RUN([
char *fin = "/tmp/conftest$$";
-main()
+int main()
{
struct stat stb;
fd_set f;
@@ -377,6 +380,7 @@ AC_TRY_RUN([
#include <sys/stat.h>
#include <fcntl.h>
+#include <stdlib.h>
#ifndef O_NONBLOCK
#define O_NONBLOCK O_NDELAY
@@ -387,7 +391,7 @@ AC_TRY_RUN([
char *fin = "/tmp/conftest$$";
-main()
+int main()
{
struct timeval tv;
fd_set f;
@@ -434,10 +438,13 @@ AC_TRY_RUN([
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
char *son = "/tmp/conftest$$";
-main()
+int main()
{
int s1, s2, l;
struct sockaddr_un a;
@@ -490,10 +497,12 @@ AC_TRY_RUN([
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <stdlib.h>
+#include <string.h>
char *son = "/tmp/conftest$$";
-main()
+int main()
{
int s;
struct stat stb;
@@ -535,6 +544,7 @@ AC_TRY_RUN([
#include <sys/stat.h>
#include <fcntl.h>
+#include <stdlib.h>
char *nam = "/tmp/conftest$$";
@@ -547,7 +557,7 @@ char *nam = "/tmp/conftest$$";
#define S_IFIFO 0010000
#endif
-main()
+int main()
{
fd_set f;
@@ -576,8 +586,11 @@ main()
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
-main()
+int main()
{
int s1, s2, l;
struct sockaddr_un a;
@@ -624,11 +637,14 @@ dnl
dnl **** termcap or terminfo ****
dnl
AC_CHECKING(for tgetent)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],
+tgetent((char *)0, (char *)0);,,
olibs="$LIBS"
LIBS="-lcurses $olibs"
AC_CHECKING(libcurses)
-AC_TRY_LINK(,[
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],[
#ifdef __hpux
__sorry_hpux_libcurses_is_totally_broken_in_10_10();
#else
@@ -637,26 +653,33 @@ tgetent((char *)0, (char *)0);
],,
LIBS="-ltermcap $olibs"
AC_CHECKING(libtermcap)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
LIBS="-ltermlib $olibs"
AC_CHECKING(libtermlib)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
LIBS="-lncursesw $olibs"
AC_CHECKING(libncursesw)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
LIBS="-ltinfow $olibs"
AC_CHECKING(libtinfow)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
LIBS="-lncurses $olibs"
AC_CHECKING(libncurses)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
LIBS="-ltinfo $olibs"
AC_CHECKING(libtinfo)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([#include <curses.h>
+#include <term.h>],tgetent((char *)0, (char *)0);,,
AC_MSG_ERROR(!!! no tgetent - no screen)))))))))
AC_TRY_RUN([
-main()
+#include <stdlib.h>
+int main()
{
exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
}], AC_NOTE(- you use the termcap database),
@@ -679,7 +702,7 @@ if test "$cross_compiling" = no ; then
AC_CHECKING(for SVR4 ptys)
sysvr4ptys=
if test -c /dev/ptmx ; then
-AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
+AC_TRY_LINK([#include
<stdlib.h>],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
sysvr4ptys=1])
fi
fi
@@ -735,7 +758,8 @@ AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
-main()
+#include <stdlib.h>
+int main()
{
struct stat sb;
char *x,*ttyname();
@@ -871,13 +895,13 @@ test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil"
fi
AC_CHECKING(getloadavg)
-AC_TRY_LINK(,[getloadavg((double *)0, 0);],
+AC_TRY_LINK([#include <stdlib.h>],[getloadavg((double *)0, 0);],
AC_DEFINE(LOADAV_GETLOADAVG) load=1,
if test "$cross_compiling" = no && test -f /usr/lib/libkvm.a ; then
olibs="$LIBS"
LIBS="$LIBS -lkvm"
AC_CHECKING(getloadavg with -lkvm)
-AC_TRY_LINK(,[getloadavg((double *)0, 0);],
+AC_TRY_LINK([#include <stdlib.h>],[getloadavg((double *)0, 0);],
AC_DEFINE(LOADAV_GETLOADAVG) load=1, LIBS="$olibs")
fi
)
@@ -923,6 +947,7 @@ else
for av in avenrun _avenrun _Loadavg avenrun _avenrun _Loadavg; do
AC_TRY_RUN([
#include <sys/types.h>
+#include <stdlib.h>
#ifdef NLIST_STRUCT
#include <nlist.h>
#else
@@ -933,7 +958,7 @@ $nlist64
struct nlist nl[2];
-main()
+int main()
{
#if !defined(_AUX_SOURCE) && !defined(AUX)
# ifdef NLIST_NAME_UNION
@@ -1052,6 +1077,8 @@ AC_CHECKING(signal implementation)
AC_TRY_RUN([
#include <sys/types.h>
#include <signal.h>
+#include <stdlib.h>
+#include <signal.h>
#ifndef SIGCLD
#define SIGCLD SIGCHLD
@@ -1070,7 +1097,7 @@ hand()
got++;
}
-main()
+int main()
{
/* on hpux we use sigvec to get bsd signals */
#ifdef __hpux
@@ -1109,10 +1136,10 @@ AC_CHECKING(IRIX sun library)
AC_TRY_LINK(,,,LIBS="$oldlibs")
AC_CHECKING(syslog)
-AC_TRY_LINK(,[closelog();], , [oldlibs="$LIBS"
+AC_TRY_LINK([#include <syslog.h>],[closelog();], , [oldlibs="$LIBS"
LIBS="$LIBS -lbsd"
AC_CHECKING(syslog in libbsd.a)
-AC_TRY_LINK(, [closelog();], AC_NOTE(- found.), [LIBS="$oldlibs"
+AC_TRY_LINK([#include <syslog.h>], [closelog();], AC_NOTE(- found.),
[LIBS="$oldlibs"
AC_NOTE(- bad news: syslog missing.) AC_DEFINE(NOSYSLOG)])])
AC_EGREP_CPP(YES_IS_DEFINED,
@@ -1149,14 +1176,17 @@ AC_CHECKING(getspnam)
AC_TRY_LINK([#include <shadow.h>], [getspnam("x");],AC_DEFINE(SHADOWPW))
AC_CHECKING(getttyent)
-AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT))
+AC_TRY_LINK([#include <ttyent.h>],[getttyent();], AC_DEFINE(GETTTYENT))
AC_CHECKING(fdwalk)
AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL,
NULL);],AC_DEFINE(HAVE_FDWALK))
AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
AC_TRY_RUN([
-main() {
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+int main() {
char buf[10];
strcpy(buf, "abcdefghi");
bcopy(buf, buf + 2, 3);
@@ -1170,8 +1200,10 @@ main() {
}], AC_DEFINE(USEBCOPY),,:)
AC_TRY_RUN([
+#include <stdlib.h>
+#include <string.h>
#define bcopy(s,d,l) memmove(d,s,l)
-main() {
+int main() {
char buf[10];
strcpy(buf, "abcdefghi");
bcopy(buf, buf + 2, 3);
@@ -1188,7 +1220,9 @@ main() {
AC_TRY_RUN([
#define bcopy(s,d,l) memcpy(d,s,l)
-main() {
+#include <string.h>
+#include <stdlib.h>
+int main() {
char buf[10];
strcpy(buf, "abcdefghi");
bcopy(buf, buf + 2, 3);
@@ -1204,7 +1238,8 @@ main() {
AC_SYS_LONG_FILE_NAMES
AC_MSG_CHECKING(for vsprintf)
-AC_TRY_LINK([#include <stdarg.h>],[va_list valist; vsprintf(0,0,valist);],
AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
+AC_TRY_LINK([#include <stdarg.h>
+#include <stdio.h>],[va_list valist; vsprintf(0,0,valist);],
AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
AC_HEADER_DIRENT
--
2.39.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [screen-devel] [PATCH] Fix -Wimplicit-function-declaration -Wimplicit-int,
Arjun Shankar <=