Skip to content

Commit

Permalink
Compile with -Wall and fix all the warnings it reports.
Browse files Browse the repository at this point in the history
Also, add a Makefile rule for emacs flymake-mode
  • Loading branch information
nelhage committed Jul 4, 2008
1 parent 4318efc commit 0dc8151
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CFLAGS=-m32 -O2 -g
CFLAGS=-m32 -O2 -g -Wall
ASFLAGS=-m32
LDFLAGS=-m32

Expand Down Expand Up @@ -34,4 +34,7 @@ TAGS: $(SRCS) $(ASMSRCS) $(HEADERS)

tags: TAGS

.phony: CLEAN tags
check-syntax:
$(CC) $(CCFLAGS) -Wall -Wextra -fsyntax-only $(CHK_SOURCES)

.phony: CLEAN tags check-syntax
6 changes: 2 additions & 4 deletions bconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ static pthread_t console_thread;
static struct termios saved_termios;
static int kbd_char;

void* console_process(void *arg) {
void* console_process(void *arg UNUSED) {
int err;
struct pollfd pollfd = {
.fd = 0,
.events = POLLIN
};
struct timespec timeout = {-1, 0};
while(1) {
err = poll(&pollfd, 1, -1);
if(err < 0) {
if(errno = EINTR) continue;
if(errno == EINTR) continue;
panic("Poll returned error: %s\n", strerror(errno));
}
LOG("Keyboard interrupt!\n");
Expand All @@ -39,7 +38,6 @@ void* console_process(void *arg) {
void console_open(bool interrupt) {
LOG("console_open(%d)", interrupt);
struct termios termios;
sigset_t set;
int flags;
/* Disable echo */
if(tcgetattr(0, &saved_termios) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion bconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ void console_open(bool interrupt);
void console_close();

void beta_wrchr(int chr);
int beta_rdchr()
int beta_rdchr();

#endif
17 changes: 10 additions & 7 deletions bemu.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "bemu.h"

#include <unistd.h>
#include <getopt.h>

#define _GNU_SOURCE
#include <string.h>

#include <sys/time.h>
#include <time.h>

/* Subtract the `struct timeval' values X and Y,
Expand Down Expand Up @@ -61,8 +60,12 @@ void handle_flags(char *optval) {
char *comma;

while(1) {
comma = (char*)strchrnul(optval, ',');
len = comma - optval;
comma = (char*)strchr(optval, ',');
if(comma) {
len = comma - optval;
} else {
len = strlen(optval);
}
if(!strncmp(optval, "clock", len)) {
cpu_options.enable_clock = 1;
} else if(!strncmp(optval, "tty", len)) {
Expand All @@ -71,7 +74,7 @@ void handle_flags(char *optval) {
fprintf(stderr, "Bad option spec: %s\n", optval);
usage();
}
if(!*comma) {
if(!comma) {
break;
}
optval = comma + 1;
Expand Down Expand Up @@ -151,7 +154,7 @@ int main(int argc, char **argv)

if(cpu_options.do_time) {
timeval_subtract(&delta, &end, &start);
printf("Executed in %ds.%dus\n", delta.tv_sec, delta.tv_usec);
printf("Executed in %ds.%dus\n", (int)delta.tv_sec, (int)delta.tv_usec);
}

if(cpu_options.do_dump) {
Expand Down
3 changes: 3 additions & 0 deletions bemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "x86.h"
#include "bt.h"
#include "bclock.h"
#include "bconsole.h"

#ifdef DEBUG
#define LOG(fmt, ...) printf("%s:%d: " fmt "\n", __FILE__, __LINE__, ## __VA_ARGS__)
Expand All @@ -28,4 +29,6 @@
#define panic(fmt, ...) __panic(__FILE__, __LINE__, fmt, ## __VA_ARGS__);
void __panic(char *file, int line, char *fmt, ...) __attribute__((noreturn));

#define UNUSED __attribute__((unused))

#endif

0 comments on commit 0dc8151

Please sign in to comment.