From 59e8fa59d590a79207df41a030c96b6bde20cba8 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Fri, 29 Nov 2019 02:18:02 -0700 Subject: [PATCH] compilation errors fixed --- .gitignore | 2 ++ src/gpio.c | 12 +++++++----- src/log.c | 6 +++--- src/log.h | 2 +- src/main.c | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index b25c15b..d5e8893 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *~ +*.o +src/upiwin diff --git a/src/gpio.c b/src/gpio.c index 76f2cc1..02f5e52 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -1,6 +1,8 @@ +#include #include #include #include +#include #include #include "log.h" #include "gpio.h" @@ -62,11 +64,11 @@ static int setup_the_memmap(void) { if ((mem_fd = open("/dev/gpiomem", O_RDWR|O_SYNC)) > 0) { - if ((gpio_map = (unit32_t *)mmap(NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0)) == MAP_FAILED) + if ((gpio_map = (uint32_t *)mmap(NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0)) == MAP_FAILED) { gpio_map = NULL; close(mem_fd); - log(LFATAL, "Unable to map /dev/gpiomem (%d)", errno); + Log(LFATAL, "Unable to map /dev/gpiomem (%d)", errno); return -1; } } @@ -170,7 +172,7 @@ void Gpio_cleanup(void) if (gpio_map) { - munmap(gpio_map, BLOCK_SIZE); + munmap((void *)gpio_map, BLOCK_SIZE); gpio_map = NULL; } if (mem_fd >= 0) @@ -200,13 +202,13 @@ int Gpio_poll_buttons(void) for (ndx = 1, mask = 1; ndx <= 4; ndx++, mask <<= 1) { if (tmp & mask) - log(LDEBUG, "Button %d was released", ndx); + Log(LDEBUG, "Button %d was released", ndx); } tmp = new_state & ~last_state; for (ndx = 1, mask = 1; ndx <= 4; ndx++, mask <<= 1) { if (tmp & mask) - log(LDEBUG, "Button %d was pressed", ndx); + Log(LDEBUG, "Button %d was pressed", ndx); } last_state = new_state; } diff --git a/src/log.c b/src/log.c index 3bfe8dc..de98b14 100644 --- a/src/log.c +++ b/src/log.c @@ -6,7 +6,7 @@ static const char *severities[] = { "FATAL", "ERROR", "WARN ", "INFO ", "DEBUG" }; -void log(int level, const char *format, ...) +void Log(int level, const char *format, ...) { va_list argp; struct timeval tv; @@ -18,8 +18,8 @@ void log(int level, const char *format, ...) vsnprintf(buf, 1024, format, argp); va_end(argp); - gettimeofday(&tv); - localtime_r(&(tv.tv_sec), &tm) + gettimeofday(&tv, NULL); + localtime_r(&(tv.tv_sec), &tm); strftime(timestamp, 32, "%F %T", &tm); printf("%s.%06u %s %s\n", timestamp, tv.tv_usec, severities[level], buf); } diff --git a/src/log.h b/src/log.h index c7eaaf2..8c040b8 100644 --- a/src/log.h +++ b/src/log.h @@ -7,6 +7,6 @@ #define LINFO 3 #define LDEBUG 4 -extern void log(int level, const char *format, ...); +extern void Log(int level, const char *format, ...); #endif /* __LOG_H_INCLUDED */ diff --git a/src/main.c b/src/main.c index 8275d52..0781b05 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; atexit(Gpio_cleanup); - log(LINFO, "System ready."); + Log(LINFO, "System ready."); for (;;) { Gpio_poll_buttons();