From 18195b4d056681c5c4fa5210cd9c022a6186dfd1 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 12 Jun 2019 15:59:06 +0200 Subject: [PATCH] mescc: Mes C Library: Fix compile warnings. * include/stdlib.h (abort): Add prototype. --- include/stdlib.h | 1 + lib/posix/execl.c | 2 +- lib/stdio/vfprintf.c | 8 ++++---- lib/stdio/vsnprintf.c | 2 +- lib/stdlib/__exit.c | 4 +++- lib/stdlib/abort.c | 4 +++- lib/stdlib/mbstowcs.c | 2 ++ lib/string/bzero.c | 9 ++++++++- lib/string/index.c | 6 +++++- lib/string/rindex.c | 4 ++++ lib/string/strcspn.c | 2 +- lib/string/strpbrk.c | 2 +- lib/stub/frexp.c | 2 +- 13 files changed, 35 insertions(+), 13 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index 391d0446..592a387b 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -36,6 +36,7 @@ typedef int (*comparison_fn_t) (void const *, void const *); #include #include +void abort (void); double atof (char const *s); int atoi (char const *s); int atexit (void (*function) (void)); diff --git a/lib/posix/execl.c b/lib/posix/execl.c index bae7a066..ae651510 100644 --- a/lib/posix/execl.c +++ b/lib/posix/execl.c @@ -38,7 +38,7 @@ execl (char const *file_name, char const *arg, ...) va_start (ap, arg); argv[i++] = (char *)file_name; - arg = va_arg (ap, char const *); + arg = (char *) va_arg (ap, char const *); while (arg) { argv[i++] = arg; diff --git a/lib/stdio/vfprintf.c b/lib/stdio/vfprintf.c index 00abe7a6..119e41ae 100644 --- a/lib/stdio/vfprintf.c +++ b/lib/stdio/vfprintf.c @@ -33,7 +33,7 @@ vfprintf (FILE * f, char const *format, va_list ap) if (*p != '%') { count++; - fputc (*p++, fd); + fputc (*p++, f); } else { @@ -88,7 +88,7 @@ vfprintf (FILE * f, char const *format, va_list ap) { case '%': { - fputc (*p, fd); + fputc (*p, f); count++; break; } @@ -96,7 +96,7 @@ vfprintf (FILE * f, char const *format, va_list ap) { char _c; _c = va_arg (ap, long); - fputc (_c, fd); + fputc (_c, f); break; } case 'd': @@ -108,7 +108,7 @@ vfprintf (FILE * f, char const *format, va_list ap) { long d = va_arg (ap, long); int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10; - char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); + char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); if (c == 'X') strupr (s); int length = strlen (s); diff --git a/lib/stdio/vsnprintf.c b/lib/stdio/vsnprintf.c index 1e3ba4f1..2c224bfe 100644 --- a/lib/stdio/vsnprintf.c +++ b/lib/stdio/vsnprintf.c @@ -114,7 +114,7 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap) { long d = va_arg (ap, long); int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10; - char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); + char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); if (c == 'X') strupr (s); int length = strlen (s); diff --git a/lib/stdlib/__exit.c b/lib/stdlib/__exit.c index 4eb7c764..a7f41656 100644 --- a/lib/stdlib/__exit.c +++ b/lib/stdlib/__exit.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,6 +18,8 @@ * along with GNU Mes. If not, see . */ +#include + int __exit (int status) { diff --git a/lib/stdlib/abort.c b/lib/stdlib/abort.c index bc93a329..85151442 100644 --- a/lib/stdlib/abort.c +++ b/lib/stdlib/abort.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,6 +18,8 @@ * along with GNU Mes. If not, see . */ +#include + void abort (void) { diff --git a/lib/stdlib/mbstowcs.c b/lib/stdlib/mbstowcs.c index 40dca931..a948544d 100644 --- a/lib/stdlib/mbstowcs.c +++ b/lib/stdlib/mbstowcs.c @@ -18,7 +18,9 @@ * along with GNU Mes. If not, see . */ +#include #include +#include #if !__MESC__ typedef char wchar_t[]; diff --git a/lib/string/bzero.c b/lib/string/bzero.c index 54329d67..24de4266 100644 --- a/lib/string/bzero.c +++ b/lib/string/bzero.c @@ -21,8 +21,15 @@ #include #include +#if BZERO_INT int +#else +void +#endif bzero (void *block, size_t size) { - return (int) (long) memset (block, 0, size); +#if BZERO_INT + return (int) (long) +#endif + memset (block, 0, size); } diff --git a/lib/string/index.c b/lib/string/index.c index 9904211b..797b86b0 100644 --- a/lib/string/index.c +++ b/lib/string/index.c @@ -20,8 +20,12 @@ #include +#if INDEX_INT int +#else +char * +#endif index (char const *s, int c) { - return (int) (long) strchr (s, c); + return strchr (s, c); } diff --git a/lib/string/rindex.c b/lib/string/rindex.c index 848fae70..41097cc0 100644 --- a/lib/string/rindex.c +++ b/lib/string/rindex.c @@ -20,7 +20,11 @@ #include +#if INDEX_INT int +#else +char * +#endif rindex (char const *s, int c) { return strrchr (s, c); diff --git a/lib/string/strcspn.c b/lib/string/strcspn.c index 4a4ed5e2..e54bf77b 100644 --- a/lib/string/strcspn.c +++ b/lib/string/strcspn.c @@ -23,7 +23,7 @@ size_t strcspn (char const *string, char const *stopset) { - char *p = string; + char *p = (char *) string; while (*p) if (strchr (stopset, *p)) break; diff --git a/lib/string/strpbrk.c b/lib/string/strpbrk.c index 92b0cdb8..57583ee3 100644 --- a/lib/string/strpbrk.c +++ b/lib/string/strpbrk.c @@ -23,7 +23,7 @@ char * strpbrk (char const *string, char const *stopset) { - char *p = string; + char *p = (char *) string; while (*p) if (strchr (stopset, *p)) break; diff --git a/lib/stub/frexp.c b/lib/stub/frexp.c index f26e1aea..7d73724c 100644 --- a/lib/stub/frexp.c +++ b/lib/stub/frexp.c @@ -20,7 +20,7 @@ #include -int +double frexp (int x) { static int stub = 0;