Skip to content

Commit

Permalink
FIX: more fixes trying to lower number of Clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Oct 16, 2018
1 parent d3a9cdf commit ef2c892
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/core/b-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ extern const REBYTE Str_Banner[];
}
}

ASSERT(!CMP_BYTES("end!", Get_Sym_Name(SYM_END_TYPE)), RP_BAD_END_CANON_WORD);
ASSERT(!CMP_BYTES("true", Get_Sym_Name(SYM_TRUE)), RP_BAD_TRUE_CANON_WORD);
ASSERT(!CMP_BYTES("line", BOOT_STR(RS_SCAN,1)), RP_BAD_BOOT_STRING);
ASSERT(!CMP_BYTES(cb_cast("end!"), Get_Sym_Name(SYM_END_TYPE)), RP_BAD_END_CANON_WORD);
ASSERT(!CMP_BYTES(cb_cast("true"), Get_Sym_Name(SYM_TRUE)), RP_BAD_TRUE_CANON_WORD);
ASSERT(!CMP_BYTES(cb_cast("line"), BOOT_STR(RS_SCAN,1)), RP_BAD_BOOT_STRING);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/c-do.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void Trace_Return(REBVAL *word, REBVAL *value)
{
int depth;
CHECK_DEPTH(depth);
Debug_Fmt_(cb_cast(BOOT_STR(RS_TRACE,6)), Get_Word_Name(word));
Debug_Fmt_(BOOT_STR(RS_TRACE,6), Get_Word_Name(word));
Debug_Values(value, 1, 50);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/c-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@
{
REBSER *body;

Debug_Str((REBYTE*)"Begin Task");
Debug_Str("Begin Task");

Init_Task();
body = Clone_Block(VAL_MOD_BODY(task));
OS_TASK_READY(0);
Do_Blk(body, 0);

Debug_Str((REBYTE*)"End Task");
Debug_Str("End Task");
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/d-crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ enum Crash_Msg_Nums {

// "REBOL PANIC #nnn:"
COPY_BYTES(buf, Crash_Msgs[CM_ERROR], CRASH_BUF_SIZE);
APPEND_BYTES(buf, " #", CRASH_BUF_SIZE);
APPEND_BYTES(buf, cb_cast(" #"), CRASH_BUF_SIZE);
Form_Int(buf + LEN_BYTES(buf), id);
APPEND_BYTES(buf, ": ", CRASH_BUF_SIZE);
APPEND_BYTES(buf, cb_cast(": "), CRASH_BUF_SIZE);

// "REBOL PANIC #nnn: put error message here"
// The first few error types only print general error message.
Expand Down
14 changes: 7 additions & 7 deletions src/core/d-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

/***********************************************************************
**
*/ void Dump_Series(REBSER *series, REBYTE *memo)
*/ void Dump_Series(REBSER *series, const char *memo)
/*
***********************************************************************/
{
Expand Down Expand Up @@ -100,7 +100,7 @@
for (tp = str; *tp;) *cp++ = *tp++;

*cp = 0;
Debug_Str(buf);
Debug_Str(cs_cast(buf));
if (cnt >= limit) break;
cp = buf;
}
Expand All @@ -119,7 +119,7 @@
REBYTE *cp;
REBCNT l, n;
REBCNT *bp = (REBCNT*)vp;
REBYTE *type;
const REBYTE *type;

cp = buf;
for (l = 0; l < count; l++) {
Expand All @@ -141,12 +141,12 @@
}
n = 0;
if (IS_WORD((REBVAL*)val) || IS_GET_WORD((REBVAL*)val) || IS_SET_WORD((REBVAL*)val)) {
char * name = Get_Word_Name((REBVAL*)val);
n = snprintf(cp, sizeof(buf) - (cp - buf), " (%s)", name);
const char * name = cs_cast(Get_Word_Name((REBVAL*)val));
n = snprintf(s_cast(cp), sizeof(buf) - (cp - buf), " (%s)", name);
}

*(cp + n) = 0;
Debug_Str(buf);
Debug_Str(s_cast(buf));
cp = buf;
}
}
Expand Down Expand Up @@ -349,7 +349,7 @@ xx*/ void Dump_Bind_Table()
};

DISABLE_GC;
for (n = 0; n < 14; n++) Debug_Fmt(cb_cast(BOOT_STR(RS_DUMP, n)), nums[n]);
for (n = 0; n < 14; n++) Debug_Fmt(BOOT_STR(RS_DUMP, n), nums[n]);
ENABLE_GC;
}

Expand Down
31 changes: 17 additions & 14 deletions src/core/d-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ static REBREQ *Req_SIO;
**
***********************************************************************/
{
Req_SIO->data = b_cast("\n");
// !!! Don't put const literal directly into mutable Req_SIO->data
static REBYTE newline[] = "\n";

Req_SIO->data = newline;
Req_SIO->length = 1;
Req_SIO->actual = 0;

Expand All @@ -83,7 +86,7 @@ static REBREQ *Req_SIO;

/***********************************************************************
**
*/ static void Prin_OS_String(REBYTE *bp, REBINT len, REBOOL uni)
*/ static void Prin_OS_String(const REBYTE *bp, REBINT len, REBOOL uni)
/*
** Print a string, but no line terminator or space.
**
Expand Down Expand Up @@ -141,7 +144,7 @@ static REBREQ *Req_SIO;

/***********************************************************************
**
*/ void Out_Str(REBYTE *bp, REBINT lines)
*/ void Out_Str(const REBYTE *bp, REBINT lines)
/*
***********************************************************************/
{
Expand Down Expand Up @@ -206,18 +209,18 @@ static REBREQ *Req_SIO;
//RESET_SERIES(Trace_Buffer);
}
else {
Out_Str("backtrace not enabled", 1);
Out_Str(cb_cast("backtrace not enabled"), 1);
}
}


/***********************************************************************
**
*/ void Debug_String(REBYTE *bp, REBINT len, REBOOL uni, REBINT lines)
*/ void Debug_String(const REBYTE *bp, REBINT len, REBOOL uni, REBINT lines)
/*
***********************************************************************/
{
REBUNI *up = (REBUNI*)bp;
const REBUNI *up = cast(const REBUNI*, bp);
REBUNI uc;

if (Trace_Limit > 0) {
Expand Down Expand Up @@ -245,19 +248,19 @@ static REBREQ *Req_SIO;
/*
***********************************************************************/
{
Debug_String("", UNKNOWN, 0, 1);
Debug_String(cb_cast(""), UNKNOWN, 0, 1);
}


/***********************************************************************
**
*/ void Debug_Str(REBYTE *str)
*/ void Debug_Str(const char *str)
/*
** Print a string followed by a newline.
**
***********************************************************************/
{
Debug_String(str, UNKNOWN, 0, 1);
Debug_String(cb_cast(str), UNKNOWN, 0, 1);
}


Expand Down Expand Up @@ -292,7 +295,7 @@ static REBREQ *Req_SIO;
/*
***********************************************************************/
{
if (BYTE_SIZE(ser)) Debug_Str(BIN_HEAD(ser));
if (BYTE_SIZE(ser)) Debug_Str(s_cast(BIN_HEAD(ser)));
else Debug_Uni(ser);
}

Expand All @@ -308,9 +311,9 @@ static REBREQ *Req_SIO;
REBYTE buf[40];

Debug_String(str, UNKNOWN, 0, 0);
Debug_String(" ", 1, 0, 0);
Debug_String(cb_cast(" "), 1, 0, 0);
Form_Hex_Pad(buf, num, 8);
Debug_Str(buf);
Debug_Str(s_cast(buf));
}


Expand Down Expand Up @@ -350,7 +353,7 @@ static REBREQ *Req_SIO;
**
***********************************************************************/
{
Debug_Str(Get_Word_Name(word));
Debug_Str(cs_cast(Get_Word_Name(word)));
}


Expand All @@ -362,7 +365,7 @@ static REBREQ *Req_SIO;
**
***********************************************************************/
{
if (VAL_TYPE(value) < REB_MAX) Debug_Str(Get_Type_Name(value));
if (VAL_TYPE(value) < REB_MAX) Debug_Str(cs_cast(Get_Type_Name(value)));
else Debug_Str("TYPE?!");
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/f-deci.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ deci decimal_to_deci (REBDEC a) {

e -= (rve - c);

d = CHR_TO_INT(c);
d = CHR_TO_INT(cs_cast(c));

result.s = s;
result.m2 = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/core/f-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@

/***********************************************************************
**
*/ REBINT Partial1(REBVAL *sval, REBVAL *lval)
*/ REBCNT Partial1(REBVAL *sval, REBVAL *lval)
/*
** Process the /part (or /skip) and other length modifying
** arguments.
Expand Down Expand Up @@ -705,7 +705,7 @@
}
}

return (REBINT)len;
return (REBCNT)len;
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/l-scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@

// Check for identifiers:
for (n = 0; n < ESC_MAX; n++) {
if (NZ(cp = Match_Bytes(*bp, cb_cast(Esc_Names[n])))) {
if (NZ(cp = Match_Bytes(*bp, Esc_Names[n]))) {
if (cp && *cp == ')') {
*bp = cp + 1;
return Esc_Codes[n];
Expand Down
2 changes: 1 addition & 1 deletion src/core/m-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static void Mark_Series(REBSER *series, REBCNT depth);
return 0;
}

if (Reb_Opts->watch_recycle) Debug_Str(BOOT_STR(RS_WATCH, 0));
if (Reb_Opts->watch_recycle) Debug_Str(cs_cast(BOOT_STR(RS_WATCH, 0)));

GC_Disabled = 1;

Expand Down
8 changes: 4 additions & 4 deletions src/core/n-strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ static struct digest {
{
REBSER *ser;
REBCNT index;
REBINT len;
REBCNT len;

len = Partial1(D_ARG(1), D_ARG(3));

ser = Prep_Bin_Str(D_ARG(1), &index, &len); // result may be a SHARED BUFFER!

Set_Binary(D_RET, Compress(ser, index, len, D_REF(4))); // /gzip
Set_Binary(D_RET, Compress(ser, index, (REBINT)len, D_REF(4))); // /gzip

return R_RET;
}
Expand All @@ -318,13 +318,13 @@ static struct digest {
{
REBVAL *arg = D_ARG(1);
REBINT limit = 0;
REBINT len;
REBCNT len;

len = Partial1(D_ARG(1), D_ARG(3));

if (D_REF(5)) limit = Int32s(D_ARG(6), 1); // /limit size

Set_Binary(D_RET, Decompress(VAL_SERIES(arg), VAL_INDEX(arg), len, limit, D_REF(4))); // /gzip
Set_Binary(D_RET, Decompress(VAL_SERIES(arg), VAL_INDEX(arg), (REBINT)len, limit, D_REF(4))); // /gzip

return R_RET;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/p-dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

arg = Obj_Value(spec, STD_PORT_SPEC_NET_HOST);

if (IS_TUPLE(arg) && Scan_Tuple(VAL_BIN(arg), strlen(VAL_BIN(arg)), &tmp)) {
if (IS_TUPLE(arg) && Scan_Tuple(VAL_BIN(arg), LEN_BYTES(VAL_BIN(arg)), &tmp)) {
SET_FLAG(sock->modes, RST_REVERSE);
memcpy(&sock->net.remote_ip, VAL_TUPLE(&tmp), 4);
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/s-make.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ x*/ REBCNT Insert_Value(REBSER *series, REBCNT index, REBVAL *item, REBCNT type,

/***********************************************************************
**
*/ REBSER *Append_Bytes(REBSER *dst, const REBYTE *src)
*/ REBSER *Append_Bytes(REBSER *dst, const char *src)
/*
** Optimized function to append a non-encoded byte string.
** If dst is null, it will be created and returned.
Expand Down Expand Up @@ -543,7 +543,7 @@ x*/ REBCNT Insert_Value(REBSER *series, REBCNT index, REBVAL *item, REBCNT type,
REBYTE buf[32];

Form_Int(buf, num);
Append_Bytes(dst, buf);
Append_Bytes(dst, cs_cast(buf));
}


Expand All @@ -561,7 +561,7 @@ x*/ REBCNT Insert_Value(REBSER *series, REBCNT index, REBVAL *item, REBCNT type,
else
Form_Int_Pad(buf, num, -digs, digs, '0');

Append_Bytes(dst, buf);
Append_Bytes(dst, cs_cast(buf));
}


Expand Down
8 changes: 4 additions & 4 deletions src/core/s-mold.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ enum {
Mold_Value(mold, va_arg(args, REBVAL*), TRUE);
break;
case 'S': // String of bytes
Append_Bytes(series, va_arg(args, REBYTE*));
Append_Bytes(series, va_arg(args, const char*));
break;
case 'C': // Char
Append_Byte(series, va_arg(args, REBCNT));
Expand Down Expand Up @@ -536,7 +536,7 @@ STOID Mold_Handle(REBVAL *value, REB_MOLD *mold)
const REBYTE *name = VAL_HANDLE_NAME(value);
if (name != NULL) {
Append_Bytes(mold->series, "#[handle! ");
Append_Bytes(mold->series, (REBYTE *)name);
Append_Bytes(mold->series, cs_cast(name));
Append_Byte(mold->series, ']');
}
else {
Expand Down Expand Up @@ -608,7 +608,7 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
if (!sep) sep = "[]";

if (IS_END(value)) {
Append_Bytes(out, sep);
Append_Bytes(out, cs_cast(sep));
return;
}

Expand Down Expand Up @@ -709,7 +709,7 @@ STOID Mold_Block(REBVAL *value, REB_MOLD *mold)
break;
}

if (over) Append_Bytes(mold->series, sep ? sep : (REBYTE*)("[]"));
if (over) Append_Bytes(mold->series, sep ? cs_cast(sep) : "[]");
else Mold_Block_Series(mold, VAL_SERIES(value), VAL_INDEX(value), sep);

if (VAL_TYPE(value) == REB_SET_PATH)
Expand Down
2 changes: 1 addition & 1 deletion src/core/t-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void No_Nones(REBVAL *arg) {
REBFLG is_blk = FALSE; // arg is a block not a value

// Length of target (may modify index): (arg can be anything)
rlen = Partial1((action == A_CHANGE) ? block : arg, DS_ARG(AN_LENGTH));
rlen = (REBINT)Partial1((action == A_CHANGE) ? block : arg, DS_ARG(AN_LENGTH));

index = VAL_INDEX(block);
if (action == A_APPEND || index > tail) index = tail;
Expand Down
4 changes: 2 additions & 2 deletions src/core/t-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
bp = Form_Int_Pad(bp, (REBINT)VAL_YEAR(value), 6, -4, '0');
*bp = 0;

Append_Bytes(mold->series, buf);
Append_Bytes(mold->series, cs_cast(buf));

if (VAL_TIME(value) != NO_TIME) {

Expand All @@ -143,7 +143,7 @@
bp = Form_Int_Pad(bp, (tz&3) * 15, 2, 2, '0');
*bp = 0;

Append_Bytes(mold->series, buf);
Append_Bytes(mold->series, cs_cast(buf));
}
}
}
Expand Down
Loading

0 comments on commit ef2c892

Please sign in to comment.