Commit 1acf50d1 authored by Alessandro Rubini's avatar Alessandro Rubini

general: cleanup prototypes

This adds -Wstrict-prototypes -Wmissing-prototypes and takes actions
accordingly.

Some of the solutions are ugly, especially in the bare architectures,
but I prefer to be warned if I take dangerous paths wrt prototypes while
writing further code.

I'm upset by those two not being included in -Wall, as they used to.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 824041b0
...@@ -46,7 +46,8 @@ all: $(TARGET).o ...@@ -46,7 +46,8 @@ all: $(TARGET).o
# CFLAGS to use. Both this Makefile (later) and app-makefile may grow CFLAGS # CFLAGS to use. Both this Makefile (later) and app-makefile may grow CFLAGS
CFLAGS = $(USER_CFLAGS) CFLAGS = $(USER_CFLAGS)
CFLAGS += -Wall -O2 -ggdb -Iinclude -fno-common CFLAGS += -Wall -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -O2 -ggdb -Iinclude -fno-common
CFLAGS += -DPPSI_VERSION=\"$(VERSION)\" CFLAGS += -DPPSI_VERSION=\"$(VERSION)\"
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables # to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
......
...@@ -18,12 +18,30 @@ struct sel_arg_struct { ...@@ -18,12 +18,30 @@ struct sel_arg_struct {
void *tvp; void *tvp;
}; };
extern int write(int fd, const void *buf, int count);
extern void exit(int exitval);
extern int time(long *t);
extern int select(struct sel_arg_struct *as);
extern int ioctl(int fd, int cmd, void *arg);
extern int socket(int domain, int type, int proto);
extern int bind(int fd, const struct bare_sockaddr *addr, int addrlen);
extern int recv(int fd, void *pkt, int plen, int flags);
extern int send(int fd, void *pkt, int plen, int flags);
extern int shutdown(int fd, int flags);
extern int close(int fd);
extern int setsockopt(int fd, int level, int optname, const void *optval,
int optlen);
extern int gettimeofday(void *tv, void *z);
extern int settimeofday(void *tv, void *z);
extern int adjtimex(void *tv);
extern int clock_gettime(int clock, void *t);
/* /*
* The following lines use defines from Torvalds (linux-2.4.0: see syscalls.h) * The following lines use defines from Torvalds (linux-2.4.0: see syscalls.h)
*/ */
_syscall3(int, write, int, fd, const void *, buf, int, count) _syscall3(int, write, int, fd, const void *, buf, int, count)
_syscall1(int, exit, int, exitcode) _syscall1(void, exit, int, exitcode)
_syscall1(int, time, void *, tz) _syscall1(int, time, long *, t)
_syscall3(int, ioctl, int, fd, int, cmd, void *, arg) _syscall3(int, ioctl, int, fd, int, cmd, void *, arg)
_syscall1(int, select, struct sel_arg_struct *, as) _syscall1(int, select, struct sel_arg_struct *, as)
static _syscall2(int, socketcall, int, call, unsigned long *, args) static _syscall2(int, socketcall, int, call, unsigned long *, args)
......
/* /*
* From: linux-2.4.0::include/asm-i386/unistd.h * From: linux-2.4.0::include/asm-i386/unistd.h
*/ */
extern int bare_errno; extern int bare_errno;
/* /*
* user-visible error numbers are in the range -1 - -4096 * user-visible error numbers are in the range -1 - -4096
*/ */
......
...@@ -21,6 +21,7 @@ int bare_errno; ...@@ -21,6 +21,7 @@ int bare_errno;
/* This routine is jumped to by all the syscall handlers, to stash /* This routine is jumped to by all the syscall handlers, to stash
* an error number into errno. */ * an error number into errno. */
int __syscall_error(void);
int __syscall_error(void) int __syscall_error(void)
{ {
register int err_no __asm__ ("%rcx"); register int err_no __asm__ ("%rcx");
...@@ -37,6 +38,11 @@ int __syscall_error(void) ...@@ -37,6 +38,11 @@ int __syscall_error(void)
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "bare-linux.h" #include "bare-linux.h"
int write(int, const void *, int);
void exit(int);
long time(long *);
int ioctl(int, int, void *);
/* /*
* We depends on syscall.S that does the register passing * We depends on syscall.S that does the register passing
* Usage: long syscall (syscall_number, arg1, arg2, arg3, arg4, arg5, arg6) * Usage: long syscall (syscall_number, arg1, arg2, arg3, arg4, arg5, arg6)
...@@ -50,13 +56,13 @@ int write(int fd, const void *buf, int count) ...@@ -50,13 +56,13 @@ int write(int fd, const void *buf, int count)
0, 0, 0); 0, 0, 0);
} }
int exit(int exitcode) void exit(int exitcode)
{ {
return syscall(__NR_exit, (uint64_t)exitcode, 0, 0, syscall(__NR_exit, (uint64_t)exitcode, 0, 0,
0, 0, 0); 0, 0, 0);
} }
int time(long *t) long time(long *t)
{ {
return syscall(__NR_time, (uint64_t)t, 0, 0, return syscall(__NR_time, (uint64_t)t, 0, 0,
0, 0, 0); 0, 0, 0);
......
...@@ -59,7 +59,7 @@ struct wrs_shm_head *ppsi_head; ...@@ -59,7 +59,7 @@ struct wrs_shm_head *ppsi_head;
* we need to call calloc, to reset all stuff that used to be static, * we need to call calloc, to reset all stuff that used to be static,
* but we'd better have a simple prototype, compatilble with wrs_shm_alloc() * but we'd better have a simple prototype, compatilble with wrs_shm_alloc()
*/ */
void *local_malloc(void *headptr, size_t size) static void *local_malloc(void *headptr, size_t size)
{ {
void *retval = malloc(size); void *retval = malloc(size);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
extern int puts(const char *s);
extern void pp_puts(const char *s); extern void pp_puts(const char *s);
extern int atoi(const char *s); extern int atoi(const char *s);
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
*/ */
extern void ppsi_clear_bss(void);
extern int ppsi_main(int argc, char **argv);
extern void bare_main_loop(struct pp_instance *ppi); extern void bare_main_loop(struct pp_instance *ppi);
extern struct pp_network_operations bare_net_ops; extern struct pp_network_operations bare_net_ops;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* All code from uClibc-0.9.32. LGPL V2.1 * All code from uClibc-0.9.32. LGPL V2.1
*/ */
#include <ppsi/lib.h> #include <ppsi/lib.h>
#include <stdlib.h>
size_t strnlen(const char *s, size_t max);
/* Architectures declare pp_puts: map puts (used by pp_printf) to it */ /* Architectures declare pp_puts: map puts (used by pp_printf) to it */
int puts(const char *s) int puts(const char *s)
......
...@@ -205,7 +205,7 @@ static int wr_handle_followup(struct pp_instance *ppi, ...@@ -205,7 +205,7 @@ static int wr_handle_followup(struct pp_instance *ppi,
return 1; /* the caller returns too */ return 1; /* the caller returns too */
} }
int wr_pack_announce(struct pp_instance *ppi) static int wr_pack_announce(struct pp_instance *ppi)
{ {
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if (WR_DSPOR(ppi)->wrConfig != NON_WR && if (WR_DSPOR(ppi)->wrConfig != NON_WR &&
...@@ -216,7 +216,7 @@ int wr_pack_announce(struct pp_instance *ppi) ...@@ -216,7 +216,7 @@ int wr_pack_announce(struct pp_instance *ppi)
return PP_ANNOUNCE_LENGTH; return PP_ANNOUNCE_LENGTH;
} }
void wr_unpack_announce(void *buf, MsgAnnounce *ann) static void wr_unpack_announce(void *buf, MsgAnnounce *ann)
{ {
int msg_len = htons(*(UInteger16 *) (buf + 2)); int msg_len = htons(*(UInteger16 *) (buf + 2));
......
...@@ -260,7 +260,7 @@ slave: ...@@ -260,7 +260,7 @@ slave:
} }
/* Find Ebest, 9.3.2.2 */ /* Find Ebest, 9.3.2.2 */
void bmc_update_ebest(struct pp_globals *ppg) static void bmc_update_ebest(struct pp_globals *ppg)
{ {
int i, best; int i, best;
struct pp_instance *ppi, *ppi_best; struct pp_instance *ppi, *ppi_best;
......
...@@ -78,12 +78,12 @@ static int bare_time_adjust(struct pp_instance *ppi, long offset_ns, ...@@ -78,12 +78,12 @@ static int bare_time_adjust(struct pp_instance *ppi, long offset_ns,
return ret; return ret;
} }
int bare_time_adjust_offset(struct pp_instance *ppi, long offset_ns) static int bare_time_adjust_offset(struct pp_instance *ppi, long offset_ns)
{ {
return bare_time_adjust(ppi, offset_ns, 0); return bare_time_adjust(ppi, offset_ns, 0);
} }
int bare_time_adjust_freq(struct pp_instance *ppi, long freq_ppb) static int bare_time_adjust_freq(struct pp_instance *ppi, long freq_ppb)
{ {
return bare_time_adjust(ppi, 0, freq_ppb); return bare_time_adjust(ppi, 0, freq_ppb);
} }
......
...@@ -64,7 +64,7 @@ struct wrs_socket { ...@@ -64,7 +64,7 @@ struct wrs_socket {
timeout_t dmtd_update_tmo; timeout_t dmtd_update_tmo;
}; };
static uint64_t get_tics() static uint64_t get_tics(void)
{ {
struct timezone tz = {0, 0}; struct timezone tz = {0, 0};
struct timeval tv; struct timeval tv;
...@@ -285,7 +285,7 @@ drop: ...@@ -285,7 +285,7 @@ drop:
return ret; return ret;
} }
int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len, static int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
struct pp_channel *ch1, *ch2; struct pp_channel *ch1, *ch2;
...@@ -437,7 +437,7 @@ static void poll_tx_timestamp(struct pp_instance *ppi, void *pkt, int len, ...@@ -437,7 +437,7 @@ static void poll_tx_timestamp(struct pp_instance *ppi, void *pkt, int len,
} }
} }
int wrs_net_send(struct pp_instance *ppi, void *pkt, int len, static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr) TimeInternal *t, int chtype, int use_pdelay_addr)
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment