Skip to content

Commit ef2c892

Browse files
committed
FIX: more fixes trying to lower number of Clang warnings
1 parent d3a9cdf commit ef2c892

21 files changed

+60
-58
lines changed

src/core/b-init.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ extern const REBYTE Str_Banner[];
200200
}
201201
}
202202

203-
ASSERT(!CMP_BYTES("end!", Get_Sym_Name(SYM_END_TYPE)), RP_BAD_END_CANON_WORD);
204-
ASSERT(!CMP_BYTES("true", Get_Sym_Name(SYM_TRUE)), RP_BAD_TRUE_CANON_WORD);
205-
ASSERT(!CMP_BYTES("line", BOOT_STR(RS_SCAN,1)), RP_BAD_BOOT_STRING);
203+
ASSERT(!CMP_BYTES(cb_cast("end!"), Get_Sym_Name(SYM_END_TYPE)), RP_BAD_END_CANON_WORD);
204+
ASSERT(!CMP_BYTES(cb_cast("true"), Get_Sym_Name(SYM_TRUE)), RP_BAD_TRUE_CANON_WORD);
205+
ASSERT(!CMP_BYTES(cb_cast("line"), BOOT_STR(RS_SCAN,1)), RP_BAD_BOOT_STRING);
206206
}
207207

208208

src/core/c-do.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void Trace_Return(REBVAL *word, REBVAL *value)
257257
{
258258
int depth;
259259
CHECK_DEPTH(depth);
260-
Debug_Fmt_(cb_cast(BOOT_STR(RS_TRACE,6)), Get_Word_Name(word));
260+
Debug_Fmt_(BOOT_STR(RS_TRACE,6), Get_Word_Name(word));
261261
Debug_Values(value, 1, 50);
262262
}
263263

src/core/c-task.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@
6767
{
6868
REBSER *body;
6969

70-
Debug_Str((REBYTE*)"Begin Task");
70+
Debug_Str("Begin Task");
7171

7272
Init_Task();
7373
body = Clone_Block(VAL_MOD_BODY(task));
7474
OS_TASK_READY(0);
7575
Do_Blk(body, 0);
7676

77-
Debug_Str((REBYTE*)"End Task");
77+
Debug_Str("End Task");
7878
}
7979

8080

src/core/d-crash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ enum Crash_Msg_Nums {
7878

7979
// "REBOL PANIC #nnn:"
8080
COPY_BYTES(buf, Crash_Msgs[CM_ERROR], CRASH_BUF_SIZE);
81-
APPEND_BYTES(buf, " #", CRASH_BUF_SIZE);
81+
APPEND_BYTES(buf, cb_cast(" #"), CRASH_BUF_SIZE);
8282
Form_Int(buf + LEN_BYTES(buf), id);
83-
APPEND_BYTES(buf, ": ", CRASH_BUF_SIZE);
83+
APPEND_BYTES(buf, cb_cast(": "), CRASH_BUF_SIZE);
8484

8585
// "REBOL PANIC #nnn: put error message here"
8686
// The first few error types only print general error message.

src/core/d-dump.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
/***********************************************************************
3535
**
36-
*/ void Dump_Series(REBSER *series, REBYTE *memo)
36+
*/ void Dump_Series(REBSER *series, const char *memo)
3737
/*
3838
***********************************************************************/
3939
{
@@ -100,7 +100,7 @@
100100
for (tp = str; *tp;) *cp++ = *tp++;
101101

102102
*cp = 0;
103-
Debug_Str(buf);
103+
Debug_Str(cs_cast(buf));
104104
if (cnt >= limit) break;
105105
cp = buf;
106106
}
@@ -119,7 +119,7 @@
119119
REBYTE *cp;
120120
REBCNT l, n;
121121
REBCNT *bp = (REBCNT*)vp;
122-
REBYTE *type;
122+
const REBYTE *type;
123123

124124
cp = buf;
125125
for (l = 0; l < count; l++) {
@@ -141,12 +141,12 @@
141141
}
142142
n = 0;
143143
if (IS_WORD((REBVAL*)val) || IS_GET_WORD((REBVAL*)val) || IS_SET_WORD((REBVAL*)val)) {
144-
char * name = Get_Word_Name((REBVAL*)val);
145-
n = snprintf(cp, sizeof(buf) - (cp - buf), " (%s)", name);
144+
const char * name = cs_cast(Get_Word_Name((REBVAL*)val));
145+
n = snprintf(s_cast(cp), sizeof(buf) - (cp - buf), " (%s)", name);
146146
}
147147

148148
*(cp + n) = 0;
149-
Debug_Str(buf);
149+
Debug_Str(s_cast(buf));
150150
cp = buf;
151151
}
152152
}
@@ -349,7 +349,7 @@ xx*/ void Dump_Bind_Table()
349349
};
350350

351351
DISABLE_GC;
352-
for (n = 0; n < 14; n++) Debug_Fmt(cb_cast(BOOT_STR(RS_DUMP, n)), nums[n]);
352+
for (n = 0; n < 14; n++) Debug_Fmt(BOOT_STR(RS_DUMP, n), nums[n]);
353353
ENABLE_GC;
354354
}
355355

src/core/d-print.c

+17-14
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ static REBREQ *Req_SIO;
7171
**
7272
***********************************************************************/
7373
{
74-
Req_SIO->data = b_cast("\n");
74+
// !!! Don't put const literal directly into mutable Req_SIO->data
75+
static REBYTE newline[] = "\n";
76+
77+
Req_SIO->data = newline;
7578
Req_SIO->length = 1;
7679
Req_SIO->actual = 0;
7780

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

8487
/***********************************************************************
8588
**
86-
*/ static void Prin_OS_String(REBYTE *bp, REBINT len, REBOOL uni)
89+
*/ static void Prin_OS_String(const REBYTE *bp, REBINT len, REBOOL uni)
8790
/*
8891
** Print a string, but no line terminator or space.
8992
**
@@ -141,7 +144,7 @@ static REBREQ *Req_SIO;
141144

142145
/***********************************************************************
143146
**
144-
*/ void Out_Str(REBYTE *bp, REBINT lines)
147+
*/ void Out_Str(const REBYTE *bp, REBINT lines)
145148
/*
146149
***********************************************************************/
147150
{
@@ -206,18 +209,18 @@ static REBREQ *Req_SIO;
206209
//RESET_SERIES(Trace_Buffer);
207210
}
208211
else {
209-
Out_Str("backtrace not enabled", 1);
212+
Out_Str(cb_cast("backtrace not enabled"), 1);
210213
}
211214
}
212215

213216

214217
/***********************************************************************
215218
**
216-
*/ void Debug_String(REBYTE *bp, REBINT len, REBOOL uni, REBINT lines)
219+
*/ void Debug_String(const REBYTE *bp, REBINT len, REBOOL uni, REBINT lines)
217220
/*
218221
***********************************************************************/
219222
{
220-
REBUNI *up = (REBUNI*)bp;
223+
const REBUNI *up = cast(const REBUNI*, bp);
221224
REBUNI uc;
222225

223226
if (Trace_Limit > 0) {
@@ -245,19 +248,19 @@ static REBREQ *Req_SIO;
245248
/*
246249
***********************************************************************/
247250
{
248-
Debug_String("", UNKNOWN, 0, 1);
251+
Debug_String(cb_cast(""), UNKNOWN, 0, 1);
249252
}
250253

251254

252255
/***********************************************************************
253256
**
254-
*/ void Debug_Str(REBYTE *str)
257+
*/ void Debug_Str(const char *str)
255258
/*
256259
** Print a string followed by a newline.
257260
**
258261
***********************************************************************/
259262
{
260-
Debug_String(str, UNKNOWN, 0, 1);
263+
Debug_String(cb_cast(str), UNKNOWN, 0, 1);
261264
}
262265

263266

@@ -292,7 +295,7 @@ static REBREQ *Req_SIO;
292295
/*
293296
***********************************************************************/
294297
{
295-
if (BYTE_SIZE(ser)) Debug_Str(BIN_HEAD(ser));
298+
if (BYTE_SIZE(ser)) Debug_Str(s_cast(BIN_HEAD(ser)));
296299
else Debug_Uni(ser);
297300
}
298301

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

310313
Debug_String(str, UNKNOWN, 0, 0);
311-
Debug_String(" ", 1, 0, 0);
314+
Debug_String(cb_cast(" "), 1, 0, 0);
312315
Form_Hex_Pad(buf, num, 8);
313-
Debug_Str(buf);
316+
Debug_Str(s_cast(buf));
314317
}
315318

316319

@@ -350,7 +353,7 @@ static REBREQ *Req_SIO;
350353
**
351354
***********************************************************************/
352355
{
353-
Debug_Str(Get_Word_Name(word));
356+
Debug_Str(cs_cast(Get_Word_Name(word)));
354357
}
355358

356359

@@ -362,7 +365,7 @@ static REBREQ *Req_SIO;
362365
**
363366
***********************************************************************/
364367
{
365-
if (VAL_TYPE(value) < REB_MAX) Debug_Str(Get_Type_Name(value));
368+
if (VAL_TYPE(value) < REB_MAX) Debug_Str(cs_cast(Get_Type_Name(value)));
366369
else Debug_Str("TYPE?!");
367370
}
368371

src/core/f-deci.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ deci decimal_to_deci (REBDEC a) {
546546

547547
e -= (rve - c);
548548

549-
d = CHR_TO_INT(c);
549+
d = CHR_TO_INT(cs_cast(c));
550550

551551
result.s = s;
552552
result.m2 = 0;

src/core/f-stubs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@
667667

668668
/***********************************************************************
669669
**
670-
*/ REBINT Partial1(REBVAL *sval, REBVAL *lval)
670+
*/ REBCNT Partial1(REBVAL *sval, REBVAL *lval)
671671
/*
672672
** Process the /part (or /skip) and other length modifying
673673
** arguments.
@@ -705,7 +705,7 @@
705705
}
706706
}
707707

708-
return (REBINT)len;
708+
return (REBCNT)len;
709709
}
710710

711711

src/core/l-scan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376

377377
// Check for identifiers:
378378
for (n = 0; n < ESC_MAX; n++) {
379-
if (NZ(cp = Match_Bytes(*bp, cb_cast(Esc_Names[n])))) {
379+
if (NZ(cp = Match_Bytes(*bp, Esc_Names[n]))) {
380380
if (cp && *cp == ')') {
381381
*bp = cp + 1;
382382
return Esc_Codes[n];

src/core/m-gc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static void Mark_Series(REBSER *series, REBCNT depth);
546546
return 0;
547547
}
548548

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

551551
GC_Disabled = 1;
552552

src/core/n-strings.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ static struct digest {
296296
{
297297
REBSER *ser;
298298
REBCNT index;
299-
REBINT len;
299+
REBCNT len;
300300

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

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

305-
Set_Binary(D_RET, Compress(ser, index, len, D_REF(4))); // /gzip
305+
Set_Binary(D_RET, Compress(ser, index, (REBINT)len, D_REF(4))); // /gzip
306306

307307
return R_RET;
308308
}
@@ -318,13 +318,13 @@ static struct digest {
318318
{
319319
REBVAL *arg = D_ARG(1);
320320
REBINT limit = 0;
321-
REBINT len;
321+
REBCNT len;
322322

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

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

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

329329
return R_RET;
330330
}

src/core/p-dns.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
arg = Obj_Value(spec, STD_PORT_SPEC_NET_HOST);
6868

69-
if (IS_TUPLE(arg) && Scan_Tuple(VAL_BIN(arg), strlen(VAL_BIN(arg)), &tmp)) {
69+
if (IS_TUPLE(arg) && Scan_Tuple(VAL_BIN(arg), LEN_BYTES(VAL_BIN(arg)), &tmp)) {
7070
SET_FLAG(sock->modes, RST_REVERSE);
7171
memcpy(&sock->net.remote_ip, VAL_TUPLE(&tmp), 4);
7272
}

src/core/s-make.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ x*/ REBCNT Insert_Value(REBSER *series, REBCNT index, REBVAL *item, REBCNT type,
417417

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

545545
Form_Int(buf, num);
546-
Append_Bytes(dst, buf);
546+
Append_Bytes(dst, cs_cast(buf));
547547
}
548548

549549

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

564-
Append_Bytes(dst, buf);
564+
Append_Bytes(dst, cs_cast(buf));
565565
}
566566

567567

src/core/s-mold.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ enum {
9696
Mold_Value(mold, va_arg(args, REBVAL*), TRUE);
9797
break;
9898
case 'S': // String of bytes
99-
Append_Bytes(series, va_arg(args, REBYTE*));
99+
Append_Bytes(series, va_arg(args, const char*));
100100
break;
101101
case 'C': // Char
102102
Append_Byte(series, va_arg(args, REBCNT));
@@ -536,7 +536,7 @@ STOID Mold_Handle(REBVAL *value, REB_MOLD *mold)
536536
const REBYTE *name = VAL_HANDLE_NAME(value);
537537
if (name != NULL) {
538538
Append_Bytes(mold->series, "#[handle! ");
539-
Append_Bytes(mold->series, (REBYTE *)name);
539+
Append_Bytes(mold->series, cs_cast(name));
540540
Append_Byte(mold->series, ']');
541541
}
542542
else {
@@ -608,7 +608,7 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
608608
if (!sep) sep = "[]";
609609

610610
if (IS_END(value)) {
611-
Append_Bytes(out, sep);
611+
Append_Bytes(out, cs_cast(sep));
612612
return;
613613
}
614614

@@ -709,7 +709,7 @@ STOID Mold_Block(REBVAL *value, REB_MOLD *mold)
709709
break;
710710
}
711711

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

715715
if (VAL_TYPE(value) == REB_SET_PATH)

src/core/t-block.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void No_Nones(REBVAL *arg) {
207207
REBFLG is_blk = FALSE; // arg is a block not a value
208208

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

212212
index = VAL_INDEX(block);
213213
if (action == A_APPEND || index > tail) index = tail;

src/core/t-date.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
bp = Form_Int_Pad(bp, (REBINT)VAL_YEAR(value), 6, -4, '0');
121121
*bp = 0;
122122

123-
Append_Bytes(mold->series, buf);
123+
Append_Bytes(mold->series, cs_cast(buf));
124124

125125
if (VAL_TIME(value) != NO_TIME) {
126126

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

146-
Append_Bytes(mold->series, buf);
146+
Append_Bytes(mold->series, cs_cast(buf));
147147
}
148148
}
149149
}

0 commit comments

Comments
 (0)