From 278769f2bba229b951d5443837723aee51cc1e6b Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 2 Feb 2018 17:14:27 -0500 Subject: [PATCH] Fix compiler warnings with GCC. --- src/compiler/context.c | 2 +- src/compiler/specials.c | 2 ++ src/core/corelib.c | 2 +- src/core/io.c | 14 +++++++------- src/parser/parse.c | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/compiler/context.c b/src/compiler/context.c index 9ff7ec84..b6065ffd 100644 --- a/src/compiler/context.c +++ b/src/compiler/context.c @@ -91,7 +91,7 @@ static void replonvalue(DstContext *c, Dst value) { /* Handle errors on repl */ static void simpleerror(DstContext *c, enum DstContextErrorType type, Dst err, size_t start, size_t end) { - const char *errtype; + const char *errtype = ""; (void) c; (void) start; (void) end; diff --git a/src/compiler/specials.c b/src/compiler/specials.c index 0db7d1d9..37ebab21 100644 --- a/src/compiler/specials.c +++ b/src/compiler/specials.c @@ -353,6 +353,8 @@ DstSlot dstc_while(DstFopts opts, DstAst *ast, int32_t argn, const Dst *argv) { labelc = dst_v_count(c->buffer); dstc_emit(c, ast, DOP_JUMP_IF_NOT | (condlocal << 8)); dstc_postread(c, cond, condlocal); + } else { + labelc = 0; } /* Compile body */ diff --git a/src/core/corelib.c b/src/core/corelib.c index ea68dc3f..9022a485 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -173,7 +173,7 @@ int dst_core_get(DstArgs args) { } int dst_core_status(DstArgs args) { - const char *status; + const char *status = ""; if (args.n != 1) return dst_throw(args, "expected 1 argument"); if (!dst_checktype(args.v[0], DST_FIBER)) return dst_throw(args, "expected fiber"); switch(dst_unwrap_fiber(args.v[0])->status) { diff --git a/src/core/io.c b/src/core/io.c index efb671d4..28a7cb89 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -84,16 +84,16 @@ static int checkflags(const uint8_t *str, int32_t len) { static IOFile *checkfile(DstArgs args, int32_t n) { IOFile *iof; if (n >= args.n) { - dst_throw(args, "expected core.file"); + *args.ret = dst_cstringv("expected core.file"); return NULL; } if (!dst_checktype(args.v[n], DST_ABSTRACT)) { - dst_throw(args, "expected core.file"); + *args.ret = dst_cstringv("expected core.file"); return NULL; } iof = (IOFile *) dst_unwrap_abstract(args.v[n]); if (dst_abstract_type(iof) != &dst_io_filetype) { - dst_throw(args, "expected core.file"); + *args.ret = dst_cstringv("expected core.file"); return NULL; } return iof; @@ -105,11 +105,11 @@ static DstBuffer *checkbuffer(DstArgs args, int32_t n, int optional) { return dst_buffer(0); } if (n >= args.n) { - dst_throw(args, "expected buffer"); + *args.ret = dst_cstringv("expected buffer"); return NULL; } if (!dst_checktype(args.v[n], DST_BUFFER)) { - dst_throw(args, "expected buffer"); + *args.ret = dst_cstringv("expected buffer"); return NULL; } return dst_unwrap_abstract(args.v[n]); @@ -118,11 +118,11 @@ static DstBuffer *checkbuffer(DstArgs args, int32_t n, int optional) { /* Check char array argument */ static int checkchars(DstArgs args, int32_t n, const uint8_t **str, int32_t *len) { if (n >= args.n) { - dst_throw(args, "expected string/buffer"); + *args.ret = dst_cstringv("expected string/buffer"); return 0; } if (!dst_chararray_view(args.v[n], str, len)) { - dst_throw(args, "expected string/buffer"); + *args.ret = dst_cstringv("expected string/buffer"); return 0; } return 1; diff --git a/src/parser/parse.c b/src/parser/parse.c index f63b3288..89a2f877 100644 --- a/src/parser/parse.c +++ b/src/parser/parse.c @@ -553,7 +553,7 @@ static int cfun_parser(DstArgs args) { flags = 0; } DstParser *p = dst_abstract(&dst_parse_parsertype, sizeof(DstParser)); - dst_parser_init(p, 0); + dst_parser_init(p, flags); return dst_return(args, dst_wrap_abstract(p)); } @@ -561,16 +561,16 @@ static int cfun_parser(DstArgs args) { static DstParser *checkparser(DstArgs args) { DstParser *p; if (args.n == 0) { - dst_throw(args, "expected parse.parser"); + *args.ret = dst_cstringv("expected parse.parser"); return NULL; } if (!dst_checktype(args.v[0], DST_ABSTRACT)) { - dst_throw(args, "expected parse.parser"); + *args.ret = dst_cstringv("expected parse.parser"); return NULL; } p = (DstParser *) dst_unwrap_abstract(args.v[0]); if (dst_abstract_type(p) != &dst_parse_parsertype) { - dst_throw(args, "expected parse.parser"); + *args.ret = dst_cstringv("expected parse.parser"); return NULL; } return p;