Skip to content

Commit

Permalink
Enable -Wmissing-prototypes and fix problems detected
Browse files Browse the repository at this point in the history
  • Loading branch information
mkozlowski committed Jul 26, 2023
1 parent 50d40c4 commit a159b66
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ifeq ("$(origin LD)", "default")
undefine LD
endif

CFLAGS = -Wall -Werror
CFLAGS = -Wall -Werror -Wmissing-prototypes
# memcr CFLAGS
MCFLAGS = $(CFLAGS) -g
# parasite CFLAGS
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <sys/user.h>
#include <assert.h>

#include "cpu.h"
#include "../cpu.h"

void set_cpu_regs(struct registers *regs, unsigned long *pc, unsigned long arg0, unsigned long arg1)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <sys/user.h>
#include <assert.h>

#include "cpu.h"
#include "../cpu.h"

void set_cpu_regs(struct registers *regs, unsigned long *pc, unsigned long arg0, unsigned long arg1)
{
Expand Down
2 changes: 2 additions & 0 deletions arch/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#error unsupported arch
#endif

#include "syscall.h"

ssize_t sys_read(int fd, void *buf, size_t count)
{
return syscall3(__NR_read, fd, (unsigned long)buf, count);
Expand Down
2 changes: 1 addition & 1 deletion arch/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ssize_t sys_read(int fd, void *buf, size_t count);
ssize_t sys_write(int fd, const void *buf, size_t count);
int sys_close(int fd);
int sys_mprotect(unsigned long addr, size_t len, int prot);
int sys_mprotect(unsigned long addr, size_t len, unsigned long prot);
int sys_madvise(unsigned long addr, size_t len, int advice);
int sys_socket(int family, int type, int protocol);
int sys_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <sys/user.h>
#include <assert.h>

#include "cpu.h"
#include "../cpu.h"

void set_cpu_regs(struct registers *regs, unsigned long *pc, unsigned long arg0, unsigned long arg1)
{
Expand Down
5 changes: 2 additions & 3 deletions arch/x86_64/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#define _GNU_SOURCE
#include <signal.h>
#include <sys/mman.h>
#include <sched.h>
#include <linux/sched.h>

void __attribute__((used)) container(void)
static void __attribute__((used)) container(void)
{
/*
* Upon completion, each blob triggers debug trap to pass the
Expand Down
10 changes: 10 additions & 0 deletions libencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ static int block_size;
static unsigned char key[16];
static unsigned char iv[16];

/*
* Prototypes matching memcr.
*/
int lib__open(const char *pathname, int flags, mode_t mode);
int lib__close(int fd);
int lib__read(int fd, void *buf, size_t count);
int lib__write(int fd, const void *buf, size_t count);
int lib__init(int enable, const char *arg);
int lib__fini(void);


int lib__open(const char *pathname, int flags, mode_t mode)
{
Expand Down
8 changes: 4 additions & 4 deletions memcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ static int setup_parasite_args(pid_t pid, void *base)
}


void *parasite_watch_thread(void *ptr)
static void *parasite_watch_thread(void *ptr)
{
int ret;
unsigned long pid = (unsigned long)ptr;
Expand All @@ -1785,7 +1785,7 @@ void *parasite_watch_thread(void *ptr)
return NULL;
}

int parasite_watch(pid_t pid)
static int parasite_watch(pid_t pid)
{
int ret;
pthread_t id;
Expand Down Expand Up @@ -2225,7 +2225,7 @@ static void restore_procedure_service(int cd, struct service_command svc_cmd)
}
}

void register_signal_handlers()
static void register_signal_handlers(void)
{
struct sigaction sigchld_action, sigpipe_action;

Expand Down Expand Up @@ -2437,7 +2437,7 @@ static void usage(const char *name, int status)
exit(status);
}

void die(const char *fmt, ...)
static void die(const char *fmt, ...)
{
va_list ap;

Expand Down
2 changes: 2 additions & 0 deletions parasite.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

static int finish;

void service(unsigned int cmd, void *args);

#if VERBOSE == 1
static char *long_to_str(long v)
{
Expand Down

0 comments on commit a159b66

Please sign in to comment.