Skip to content
Browse files

Compile with -Wall and fix all the warnings it reports.

Also, add a Makefile rule for emacs flymake-mode
  • Loading branch information...
1 parent 4318efc commit 0dc815132fd5fa936b8d4e2ea845e28966a1eef7 @nelhage committed Jul 3, 2008
Showing with 21 additions and 14 deletions.
  1. +5 −2 Makefile
  2. +2 −4 bconsole.c
  3. +1 −1 bconsole.h
  4. +10 −7 bemu.c
  5. +3 −0 bemu.h
View
7 Makefile
@@ -1,4 +1,4 @@
-CFLAGS=-m32 -O2 -g
+CFLAGS=-m32 -O2 -g -Wall
ASFLAGS=-m32
LDFLAGS=-m32
@@ -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
View
6 bconsole.c
@@ -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");
@@ -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) {
View
2 bconsole.h
@@ -5,6 +5,6 @@ void console_open(bool interrupt);
void console_close();
void beta_wrchr(int chr);
-int beta_rdchr()
+int beta_rdchr();
#endif
View
17 bemu.c
@@ -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,
@@ -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)) {
@@ -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;
@@ -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) {
View
3 bemu.h
@@ -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__)
@@ -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.
Something went wrong with that request. Please try again.