From 011ee0f3eb159a2a8680708ace0fef2d8d1f0e4c Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Wed, 17 Jun 2015 16:57:50 -0500 Subject: [PATCH] explicit casts, add includes --- cstdlib/math.c | 1 + cstdlib/stdbool.c | 1 + cstdlib/stdio.c | 6 +++--- cstdlib/stdlib.c | 1 + cstdlib/string.c | 5 +++-- cstdlib/time.c | 2 +- cstdlib/unistd.c | 2 +- expression.c | 2 +- lex.c | 14 +++++++------- picoc.h | 2 +- platform.h | 2 +- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/cstdlib/math.c b/cstdlib/math.c index 0738596..2c0b6e3 100644 --- a/cstdlib/math.c +++ b/cstdlib/math.c @@ -1,4 +1,5 @@ /* */ +#include #include "../interpreter.h" diff --git a/cstdlib/stdbool.c b/cstdlib/stdbool.c index 3a25805..ae6b0f9 100644 --- a/cstdlib/stdbool.c +++ b/cstdlib/stdbool.c @@ -1,4 +1,5 @@ /* */ +#include #include "../interpreter.h" diff --git a/cstdlib/stdio.c b/cstdlib/stdio.c index 87bf4d3..456944a 100644 --- a/cstdlib/stdio.c +++ b/cstdlib/stdio.c @@ -1,10 +1,10 @@ /* */ - +#include #include #include "../interpreter.h" -#define MAX_FORMAT 80 -#define MAX_SCANF_ARGS 10 +#define MAX_FORMAT (80) +#define MAX_SCANF_ARGS (10) static int Stdio_ZeroValue = 0; static int EOFValue = EOF; diff --git a/cstdlib/stdlib.c b/cstdlib/stdlib.c index 44200de..d3374ed 100644 --- a/cstdlib/stdlib.c +++ b/cstdlib/stdlib.c @@ -1,4 +1,5 @@ /* */ +#include #include "../interpreter.h" diff --git a/cstdlib/string.c b/cstdlib/string.c index d394214..873e04f 100644 --- a/cstdlib/string.c +++ b/cstdlib/string.c @@ -1,4 +1,5 @@ /* */ +#include #include "../interpreter.h" @@ -176,13 +177,13 @@ void StringStrxfrm(struct ParseState *Parser, struct Value *ReturnValue, void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { - ReturnValue->Val->Pointer = strdup(Param[0]->Val->Pointer); + ReturnValue->Val->Pointer = (void*)strdup(Param[0]->Val->Pointer); } void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { - ReturnValue->Val->Pointer = strtok_r(Param[0]->Val->Pointer, + ReturnValue->Val->Pointer = (void*)strtok_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer); } #endif diff --git a/cstdlib/time.c b/cstdlib/time.c index a06ca9e..91bee8d 100644 --- a/cstdlib/time.c +++ b/cstdlib/time.c @@ -82,7 +82,7 @@ void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue, void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { - ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, + ReturnValue->Val->Pointer = (void*)gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer); } diff --git a/cstdlib/unistd.c b/cstdlib/unistd.c index 2f129c6..b7c18db 100644 --- a/cstdlib/unistd.c +++ b/cstdlib/unistd.c @@ -192,7 +192,7 @@ void UnistdGetpagesize(struct ParseState *Parser, struct Value *ReturnValue, void UnistdGetpass(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { - ReturnValue->Val->Pointer = getpass(Param[0]->Val->Pointer); + ReturnValue->Val->Pointer = (void*)getpass(Param[0]->Val->Pointer); } #if 0 diff --git a/expression.c b/expression.c index a44823a..1584e2c 100644 --- a/expression.c +++ b/expression.c @@ -749,7 +749,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, /* pointer prefix arithmetic */ int Size = TypeSize(TopValue->Typ->FromType, 0, true); struct Value *StackValue; - void *ResultPtr; + void *ResultPtr = 0; if (Op != TokenUnaryNot && TopValue->Val->Pointer == NULL) ProgramFail(Parser, "a. invalid use of a NULL pointer"); if (!TopValue->IsLValue) diff --git a/lex.c b/lex.c index 933c887..243b728 100644 --- a/lex.c +++ b/lex.c @@ -54,13 +54,13 @@ struct ReservedWord { static struct ReservedWord ReservedWords[] = { /* wrf, when optimizations are set escaping certain chars is required or they disappear */ - {"\#define", TokenHashDefine}, - {"\#else", TokenHashElse}, - {"\#endif", TokenHashEndif}, - {"\#if", TokenHashIf}, - {"\#ifdef", TokenHashIfdef}, - {"\#ifndef", TokenHashIfndef}, - {"\#include", TokenHashInclude}, + {"#define", TokenHashDefine}, + {"#else", TokenHashElse}, + {"#endif", TokenHashEndif}, + {"#if", TokenHashIf}, + {"#ifdef", TokenHashIfdef}, + {"#ifndef", TokenHashIfndef}, + {"#include", TokenHashInclude}, {"auto", TokenAutoType}, {"break", TokenBreak}, {"case", TokenCase}, diff --git a/picoc.h b/picoc.h index 0274613..24413bd 100644 --- a/picoc.h +++ b/picoc.h @@ -6,7 +6,7 @@ /* picoc version number */ #ifdef VER -/* VER is the git hash number, obtained via the Makefile */ +/* VER, the git hash number, and TAG are obtained via the Makefile */ #define PICOC_VERSION TAG " r" VER #else #define PICOC_VERSION "v2.2" diff --git a/platform.h b/platform.h index 44c602d..627ed37 100644 --- a/platform.h +++ b/platform.h @@ -50,7 +50,7 @@ #define ALIGN_TYPE double #else /* the default data type to use for alignment */ -#define ALIGN_TYPE void * +#define ALIGN_TYPE void* #endif #define GLOBAL_TABLE_SIZE (97) /* global variable table */