summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbiere <cbiere@2592e710-e01b-42a5-8df0-11608a6cc53d>2011-01-18 04:35:08 +0000
committercbiere <cbiere@2592e710-e01b-42a5-8df0-11608a6cc53d>2011-01-18 04:35:08 +0000
commit2982d579211a4d80bba3faa974d1eabb5a811705 (patch)
tree454ee164650b024d17726cb4be0dc12cb4f961f2
parent4f7eb90be70e59bbee6123be2414f94fb9c5ca22 (diff)
Fixed many units to make compiling with GCC flag -Werror possible.
Replaced exit() with return in main() due to missing #include <stdlib.h>. Added "(void) variable;" to silence warning about unused variable. Fixed Csym for GCC again (see FIXME tag). Added FIXME regarding VAL_EAGAIN. Added #define _GNU_SOURCE for pread() and pwrite() to get prototypes on GLIBC. Removed blunt cc output redirections because you can't fix what you can't see. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@79 2592e710-e01b-42a5-8df0-11608a6cc53d
-rw-r--r--mcon/U/Csym.U14
-rw-r--r--mcon/U/abortsig.U3
-rw-r--r--mcon/U/byteorder.U2
-rw-r--r--mcon/U/ccflags.U3
-rw-r--r--mcon/U/d_access.U9
-rw-r--r--mcon/U/d_const.U11
-rw-r--r--mcon/U/d_memalign.U7
-rw-r--r--mcon/U/d_open3.U6
-rw-r--r--mcon/U/d_pread.U1
-rw-r--r--mcon/U/d_pwrite.U1
-rw-r--r--mcon/U/d_sigsetjmp.U8
-rw-r--r--mcon/U/d_volatile.U15
-rw-r--r--mcon/U/i_time.U8
-rw-r--r--mcon/U/i_varhdr.U3
-rw-r--r--mcon/U/models.U6
-rw-r--r--mcon/U/nblock_io.U19
-rw-r--r--mcon/U/orderlib.U2
-rw-r--r--mcon/U/prototype.U5
18 files changed, 80 insertions, 43 deletions
diff --git a/mcon/U/Csym.U b/mcon/U/Csym.U
index e7c7c4b..ff944ea 100644
--- a/mcon/U/Csym.U
+++ b/mcon/U/Csym.U
@@ -79,9 +79,19 @@ yes)
?X:
?X: Lastly, gcc 3.4 otimizes &missing == 0 away, so we use + 2 instead now.
?X: The GNU folks like to do weird things, don't they? -- RAM, 2004-06-05
+?X
+?X: The above was invalid because main returns an int not a pointer.
+?X: Using != or == does not work because GCC complains the pointer will
+?X: never be NULL if the function exists. It is a warning meant to prevent
+?X: using an address of a function by accident instead of calling it.
+?X: However, &missing > 0 is indeed silently optimized away.
+?X
+?X: FIXME: There must be a test whether non-existing functions are found!
?X:
- echo "extern char $1$tdc; int main() { return &$1$tc + 2; }" > t.c;
- if $cc $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
+?X:. -- cbiere, 2011-01-18
+?X:
+ echo "extern char $1$tdc; int main(void) { return (unsigned long) &$1$tc > 2; }" > t.c;
+ if $cc $ccflags $ldflags -o t t.c $libs;
then tval=true;
else tval=false;
fi;
diff --git a/mcon/U/abortsig.U b/mcon/U/abortsig.U
index a13f30f..7723b7e 100644
--- a/mcon/U/abortsig.U
+++ b/mcon/U/abortsig.U
@@ -38,8 +38,9 @@ case "$abortsig" in
for signal in SIGIOT SIGILL SIGABRT; do
case "$abortsig" in
'') $cat >abort.c <<EOP
+/* FIXME: Missing #include <stdlib.h>*/
#include <signal.h>
-caught() { exit(0); }
+caught() { exit(0); } /* FIXME: Use _exit() or _Exit() in signal handler */
int main()
{
#ifdef $signal
diff --git a/mcon/U/byteorder.U b/mcon/U/byteorder.U
index a337080..03665d0 100644
--- a/mcon/U/byteorder.U
+++ b/mcon/U/byteorder.U
@@ -63,7 +63,7 @@ int main()
for (i = 0; i < sizeof(long); i++)
printf("%c", u.c[i]+'0');
printf("\n");
- exit(0);
+ return 0;
}
EOCP
xxx_prompt=y
diff --git a/mcon/U/ccflags.U b/mcon/U/ccflags.U
index 876af98..be37f52 100644
--- a/mcon/U/ccflags.U
+++ b/mcon/U/ccflags.U
@@ -373,8 +373,7 @@ and I got the following output:
EOM
$cat > try.c <<'EOF'
-#include <stdio.h>
-int main() { exit(0); }
+int main() { return 0; }
EOF
dflt=y
?X: Use "sh -c" to avoid error messages tagged with leading "Configure:".
diff --git a/mcon/U/d_access.U b/mcon/U/d_access.U
index 503ee2a..9834199 100644
--- a/mcon/U/d_access.U
+++ b/mcon/U/d_access.U
@@ -61,8 +61,13 @@ case "$d_access" in
#ifdef I_UNISTD
#include <unistd.h>
#endif
-int main() {
- exit(R_OK);
+int main(void) {
+ static int mode;
+ mode |= R_OK;
+ mode |= W_OK;
+ mode |= X_OK;
+ mode |= F_OK;
+ return mode ? 0 : 1;
}
EOCP
: check sys/file.h first, no particular reason here
diff --git a/mcon/U/d_const.U b/mcon/U/d_const.U
index 4801d09..f146b87 100644
--- a/mcon/U/d_const.U
+++ b/mcon/U/d_const.U
@@ -47,13 +47,16 @@ $cat >const.c <<'EOCP'
?X: handle typedefs properly if they're declared const. To guard
?X: against this, boost up the test by using an explicit typedef...
typedef struct spug { int drokk; } spug;
-int main()
+int main(void)
{
- const char *foo;
- const spug y;
+ static const char *foo;
+ static const spug y;
+ (void) foo;
+ (void) y;
+ return 0;
}
EOCP
-if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
+if $cc -c $ccflags const.c; then
val="$define"
echo "Yup, it does."
else
diff --git a/mcon/U/d_memalign.U b/mcon/U/d_memalign.U
index 3adbb69..e814653 100644
--- a/mcon/U/d_memalign.U
+++ b/mcon/U/d_memalign.U
@@ -10,7 +10,7 @@
?RCS:
?RCS: $Log: d_memalign.U,v $
?RCS:
-?MAKE:d_memalign: Trylink cat i_stdlib
+?MAKE:d_memalign: Trylink cat i_stdlib i_malloc
?MAKE: -pick add $@ %<
?S:d_memalign:
?S: This variable conditionally defines the HAS_MEMALIGN symbol, which
@@ -25,10 +25,15 @@
?LINT:set d_memalign
: see if memalign exists
$cat >try.c <<EOC
+#define _GNU_SOURCE
#$i_stdlib I_STDLIB
#ifdef I_STDLIB
#include <stdlib.h>
#endif
+#$i_malloc I_MALLOC
+#ifdef I_MALLOC
+#include <malloc.h>
+#endif
int main(void)
{
static size_t align, size;
diff --git a/mcon/U/d_open3.U b/mcon/U/d_open3.U
index 6828112..ee56f45 100644
--- a/mcon/U/d_open3.U
+++ b/mcon/U/d_open3.U
@@ -48,12 +48,12 @@ $cat >open3.c <<'EOCP'
#ifdef I_SYS_FILE
#include <sys/file.h>
#endif
-int main() {
+int main(void) {
if(O_RDONLY);
#ifdef O_TRUNC
- exit(0);
+ return 0;
#else
- exit(1);
+ return 1;
#endif
}
EOCP
diff --git a/mcon/U/d_pread.U b/mcon/U/d_pread.U
index e4f5afd..72edba4 100644
--- a/mcon/U/d_pread.U
+++ b/mcon/U/d_pread.U
@@ -25,6 +25,7 @@
?LINT:set d_pread
: see if pread exists
$cat >try.c <<EOC
+#define _GNU_SOURCE
#include <sys/types.h>
#$i_unistd I_UNISTD
#ifdef I_UNISTD
diff --git a/mcon/U/d_pwrite.U b/mcon/U/d_pwrite.U
index ed00afc..c568c06 100644
--- a/mcon/U/d_pwrite.U
+++ b/mcon/U/d_pwrite.U
@@ -25,6 +25,7 @@
?LINT:set d_pwrite
: see if pwrite exists
$cat >try.c <<EOC
+#define _GNU_SOURCE
#include <sys/types.h>
#$i_unistd I_UNISTD
#ifdef I_UNISTD
diff --git a/mcon/U/d_sigsetjmp.U b/mcon/U/d_sigsetjmp.U
index 8a1d474..8ecf709 100644
--- a/mcon/U/d_sigsetjmp.U
+++ b/mcon/U/d_sigsetjmp.U
@@ -65,16 +65,16 @@ case "$d_sigsetjmp" in
#include <setjmp.h>
sigjmp_buf env;
int set = 1;
-int main()
+int main(void)
{
if (sigsetjmp(env,1))
- exit(set);
+ return set;
set = 0;
siglongjmp(env, 1);
- exit(1);
+ return 1;
}
EOP
- if $cc $ccflags $ldflags -o set set.c $libs > /dev/null 2>&1 ; then
+ if $cc $ccflags $ldflags -o set set.c $libs; then
if ./set >/dev/null 2>&1; then
echo "POSIX sigsetjmp found." >&4
val="$define"
diff --git a/mcon/U/d_volatile.U b/mcon/U/d_volatile.U
index f94ca4f..6ef01db 100644
--- a/mcon/U/d_volatile.U
+++ b/mcon/U/d_volatile.U
@@ -41,7 +41,7 @@
echo " "
echo 'Checking to see if your C compiler knows about "volatile"...' >&4
$cat >try.c <<'EOCP'
-int main()
+int main(void)
{
?X:
?X: The following seven lines added by Bill Campbell <billc@sierra.com>
@@ -55,13 +55,18 @@ int main()
char char_var;
};
typedef unsigned short foo_t;
- char *volatile foo;
- volatile int bar;
- volatile foo_t blech;
+ static char *volatile foo;
+ static volatile int bar;
+ static volatile foo_t blech;
foo = foo;
+ (void) goo;
+ (void) foo;
+ (void) bar;
+ (void) blech;
+ return 0;
}
EOCP
-if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
+if $cc -c $ccflags try.c; then
val="$define"
echo "Yup, it does."
else
diff --git a/mcon/U/i_time.U b/mcon/U/i_time.U
index cdf1519..c573fa4 100644
--- a/mcon/U/i_time.U
+++ b/mcon/U/i_time.U
@@ -73,7 +73,7 @@ $cat >try.c <<'EOCP'
#ifdef I_SYSSELECT
#include <sys/select.h>
#endif
-int main()
+int main(void)
{
struct tm foo;
#ifdef S_TIMEVAL
@@ -83,12 +83,12 @@ int main()
struct timezone tzp;
#endif
if (foo.tm_sec == foo.tm_sec)
- exit(0);
+ return 0;
#ifdef S_TIMEVAL
if (bar.tv_sec == bar.tv_sec)
- exit(0);
+ return 0;
#endif
- exit(1);
+ return 1;
}
EOCP
flags=''
diff --git a/mcon/U/i_varhdr.U b/mcon/U/i_varhdr.U
index df6cfe5..e0fd6d1 100644
--- a/mcon/U/i_varhdr.U
+++ b/mcon/U/i_varhdr.U
@@ -109,11 +109,12 @@ va_dcl
p = va_arg(ap, char *);
#endif
va_end(ap);
+ return 0;
}
EOP
$cat > varargs <<EOP
$startsh
-if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
+if $cc -c $ccflags -D\$1 varargs.c; then
echo "true"
else
echo "false"
diff --git a/mcon/U/models.U b/mcon/U/models.U
index b903134..52cdd14 100644
--- a/mcon/U/models.U
+++ b/mcon/U/models.U
@@ -64,11 +64,11 @@ case "$models" in
?X: We may not use Cppsym or we get a circular dependency through cc.
?X: But this should work regardless of which cc we eventually use.
$cat >pdp11.c <<'EOP'
-int main() {
+int main(void) {
#ifdef pdp11
- exit(0);
+ return 0;
#else
- exit(1);
+ return 1;
#endif
}
EOP
diff --git a/mcon/U/nblock_io.U b/mcon/U/nblock_io.U
index 5a5aa04..fef20ac 100644
--- a/mcon/U/nblock_io.U
+++ b/mcon/U/nblock_io.U
@@ -55,6 +55,12 @@
?C:VAL_EAGAIN:
?C: This symbol holds the errno error code set by read() when no data was
?C: present on the non-blocking file descriptor.
+?C:
+?C: FIXME: And who guarantees this isn't e.g. device-dependent?
+?C: If EAGAIN is defined one should expect it.
+?C: If EWOULDBLOCK is defined one should expect it.
+?C: If both are defined one should expect both.
+?C: -- cbiere, 2011-01-18
?C:.
?C:RD_NODATA:
?C: This symbol holds the return code from read() when no data is present
@@ -91,22 +97,22 @@ case "$o_nonblock" in
'')
$cat head.c > try.c
$cat >>try.c <<'EOCP'
-int main() {
+#include <stdio.h>
+int main(void) {
#ifdef O_NONBLOCK
printf("O_NONBLOCK\n");
- exit(0);
+ return 0;
#endif
#ifdef O_NDELAY
printf("O_NDELAY\n");
- exit(0);
+ return 0;
#endif
?X: Stevens "Advanced Programming in the UNIX Environment" page 364 mentions
?X: the FNDELAY symbol, used in 4.33BSD (source: Paul Marquess).
#ifdef FNDELAY
printf("FNDELAY\n");
- exit(0);
#endif
- exit(0);
+ return 0;
}
EOCP
if $cc $ccflags $ldflags -o try try.c >/dev/null 2>&1; then
@@ -132,6 +138,7 @@ case "$eagain" in
#include <errno.h>
#include <sys/types.h>
#include <signal.h>
+#include <stdlib.h>
#define MY_O_NONBLOCK $o_nonblock
extern int errno;
$signal_t blech(x) int x; { exit(3); }
@@ -184,7 +191,7 @@ int main()
close(pu[1]); /* We read from pu[0] */
read(pu[0], buf, 1); /* Wait for parent to signal us we may continue */
close(pd[1]); /* Pipe pd is now fully closed! */
- exit(0); /* Bye bye, thank you for playing! */
+ return 0; /* Bye bye, thank you for playing! */
}
EOCP
if $cc $ccflags $ldflags -o try try.c >/dev/null 2>&1; then
diff --git a/mcon/U/orderlib.U b/mcon/U/orderlib.U
index 0c77e54..1c0feb7 100644
--- a/mcon/U/orderlib.U
+++ b/mcon/U/orderlib.U
@@ -51,7 +51,7 @@ echo "Checking how to generate random libraries on your machine..." >&4
echo 'int bar1() { return bar2(); }' > bar1.c
echo 'int bar2() { return 2; }' > bar2.c
$cat > foo.c <<'EOP'
-int main() { printf("%d\n", bar1()); exit(0); }
+int main() { printf("%d\n", bar1()); return 0; }
EOP
$cc $ccflags -c bar1.c >/dev/null 2>&1
$cc $ccflags -c bar2.c >/dev/null 2>&1
diff --git a/mcon/U/prototype.U b/mcon/U/prototype.U
index ec65247..f254e2c 100644
--- a/mcon/U/prototype.U
+++ b/mcon/U/prototype.U
@@ -102,10 +102,9 @@
echo " "
echo "Checking out function prototypes..." >&4
$cat >prototype.c <<'EOCP'
-int main(int argc, char *argv[]) {
- exit(0);}
+int main(int argc, char *argv[]) { (void) argc; (void) argv; return 0; }
EOCP
-if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
+if $cc $ccflags -c prototype.c; then
echo "Your C compiler appears to support function prototypes."
val="$define"
else