Fix compiler warnings with GCC.

This commit is contained in:
Calvin Rose 2018-02-02 17:14:27 -05:00
parent b6d90ed765
commit 278769f2bb
5 changed files with 15 additions and 13 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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) {

View File

@ -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;

View File

@ -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;