Skip to content

Commit d98b9ee

Browse files
authored
Merge pull request #9 from Oldes/cast
FIX: fighting with Clang warnings
2 parents a39eead + 4a2ee0f commit d98b9ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+353
-302
lines changed

src/core/a-constants.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const REBYTE Month_Lengths[12] = {
8888
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
8989
};
9090

91-
const REBYTE * const Month_Names[12] = {
91+
const REBYTE * Month_Names[12] = {
9292
BP"January", BP"February", BP"March",
9393
BP"April", BP"May", BP"June",
9494
BP"July", BP"August", BP"September",

src/core/a-lib.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,9 @@ RL_API REBYTE *RL_Word_String(u32 word)
677677
*/
678678
{
679679
REBYTE *s1, *s2;
680-
// !!This code should use a function from c-words.c (but nothing perfect yet.)
681-
if (word == 0 || word >= PG_Word_Table.series->tail) return 0;
682-
s1 = VAL_SYM_NAME(BLK_SKIP(PG_Word_Table.series, word));
683-
s2 = OS_MAKE(strlen(s1));
684-
strcpy(s2, s1);
680+
s1 = Get_Sym_Name(word);
681+
s2 = OS_MAKE(strlen(cs_cast(s1)));
682+
strcpy(s_cast(s2), cs_cast(s1));
685683
return s2;
686684
}
687685

src/core/b-init.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extern const REBYTE Str_Banner[];
114114
***********************************************************************/
115115
{
116116
if (rargs->options & RO_VERS) {
117-
Debug_Fmt((REBYTE*)Str_Banner, REBOL_VER, REBOL_REV, REBOL_UPD, REBOL_SYS, REBOL_VAR);
117+
Debug_Fmt(Str_Banner, REBOL_VER, REBOL_REV, REBOL_UPD, REBOL_SYS, REBOL_VAR);
118118
OS_EXIT(0);
119119
}
120120
}
@@ -179,7 +179,7 @@ extern const REBYTE Str_Banner[];
179179
Free_Series(text);
180180
}
181181

182-
Set_Root_Series(ROOT_BOOT, boot, "boot block"); // Do not let it get GC'd
182+
Set_Root_Series(ROOT_BOOT, boot, cb_cast("boot block")); // Do not let it get GC'd
183183

184184
Boot_Block = (BOOT_BLK *)VAL_BLK(BLK_HEAD(boot));
185185

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

@@ -463,7 +463,7 @@ extern const REBYTE Str_Banner[];
463463
***********************************************************************/
464464
{
465465
DS_Series = Make_Block(size);
466-
Set_Root_Series(TASK_STACK, DS_Series, "data stack"); // uses special GC
466+
Set_Root_Series(TASK_STACK, DS_Series, cb_cast("data stack")); // uses special GC
467467
DS_Base = BLK_HEAD(DS_Series);
468468
DSP = DSF = 0;
469469
SET_NONE(DS_TOP); // avoids it being set to END (GC problem)
@@ -509,7 +509,7 @@ extern const REBYTE Str_Banner[];
509509

510510
/***********************************************************************
511511
**
512-
*/ void Set_Root_Series(REBVAL *value, REBSER *ser, REBYTE *label)
512+
*/ void Set_Root_Series(REBVAL *value, REBSER *ser, const REBYTE *label)
513513
/*
514514
** Used to set block and string values in the ROOT context.
515515
**
@@ -699,14 +699,14 @@ extern const REBYTE Str_Banner[];
699699

700700
/***********************************************************************
701701
**
702-
*/ void Register_Codec(REBYTE *name, codo dispatcher)
702+
*/ void Register_Codec(const char *name, codo dispatcher)
703703
/*
704704
** Internal function for adding a codec.
705705
**
706706
***********************************************************************/
707707
{
708708
REBVAL *value = Get_System(SYS_CODECS, 0);
709-
REBCNT sym = Make_Word(name, 0);
709+
REBCNT sym = Make_Word(cb_cast(name), 0);
710710

711711
value = Append_Frame(VAL_OBJ_FRAME(value), 0, sym);
712712
SET_HANDLE(value, dispatcher);
@@ -719,8 +719,8 @@ extern const REBYTE Str_Banner[];
719719
/*
720720
***********************************************************************/
721721
{
722-
Register_Codec((REBYTE*)"text", Codec_Text);
723-
Register_Codec((REBYTE*)"markup", Codec_Markup);
722+
Register_Codec("text", Codec_Text);
723+
Register_Codec("markup", Codec_Markup);
724724
#ifdef USE_BMP_CODEC
725725
Init_BMP_Codec();
726726
#endif

src/core/c-error.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
680680
errs = Construct_Object(0, VAL_BLK(errors), 0);
681681
Set_Object(Get_System(SYS_CATALOG, CAT_ERRORS), errs);
682682

683-
Set_Root_Series(TASK_ERR_TEMPS, Make_Block(3), "task errors");
683+
Set_Root_Series(TASK_ERR_TEMPS, Make_Block(3), cb_cast("task errors"));
684684

685685
// Create objects for all error types:
686686
for (val = BLK_SKIP(errs, 1); NOT_END(val); val++) {

src/core/c-frame.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
//Debug_Fmt("Bind Table (Size: %d)", SERIES_TAIL(Bind_Table));
101101
for (n = 0; n < SERIES_TAIL(Bind_Table); n++) {
102102
if (binds[n]) {
103-
Debug_Fmt("Bind table fault: %3d to %3d (%s)", n, binds[n], Get_Sym_Name(n));
103+
Debug_Fmt(cb_cast("Bind table fault: %3d to %3d (%s)"), n, binds[n], Get_Sym_Name(n));
104104
}
105105
}
106106
}
@@ -1395,12 +1395,12 @@
13951395

13961396
for (n = 0; n < tail; n++, values++, words++) {
13971397
if (IS_END(words) || IS_END(values)) {
1398-
Debug_Fmt("** Early %s end at index: %d", IS_END(words) ? "words" : "values", n);
1398+
Debug_Fmt(cb_cast("** Early %s end at index: %d"), IS_END(words) ? "words" : "values", n);
13991399
}
14001400
}
14011401

14021402
if (NOT_END(words) || NOT_END(values))
1403-
Debug_Fmt("** Missing %s end at index: %d type: %d", NOT_END(words) ? "words" : "values", n, VAL_TYPE(words));
1403+
Debug_Fmt(cb_cast("** Missing %s end at index: %d type: %d"), NOT_END(words) ? "words" : "values", n, VAL_TYPE(words));
14041404
}
14051405

14061406

@@ -1411,5 +1411,5 @@
14111411
***********************************************************************/
14121412
{
14131413
// Temporary block used while scanning for frame words:
1414-
Set_Root_Series(TASK_BUF_WORDS, Make_Block(100), "word cache"); // just holds words, no GC
1414+
Set_Root_Series(TASK_BUF_WORDS, Make_Block(100), cb_cast("word cache")); // just holds words, no GC
14151415
}

src/core/c-port.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,12 @@
207207
REBINT result;
208208
REBCNT wt = 1;
209209
REBCNT res = (timeout >= 1000) ? 0 : 16; // OS dependent?
210-
REBCNT old_time = -1;
210+
REBINT old_time = -1;
211211

212212
while (wt) {
213213
if (GET_SIGNAL(SIG_ESCAPE)) {
214214
CLR_SIGNAL(SIG_ESCAPE);
215+
Out_Str(cb_cast("[ESC]"), 1);
215216
Halt_Code(RE_HALT, 0); // Throws!
216217
}
217218

@@ -235,12 +236,13 @@
235236
if (old_time >= 0
236237
&& time - old_time < res) {
237238
res = time - old_time;
239+
// printf("=== res: %u old_time: %i time: %u \n", res, old_time, time);
238240
}
239241

240242
old_time = time;
241243
}
242244

243-
//printf("%d %d %d\n", dt, time, timeout);
245+
// printf("base: %ull res: %u wt: %u old_time: %i time: %u timeout: %u\n", base, res, wt, old_time, time, timeout);
244246

245247
// Wait for events or time to expire:
246248
//Debug_Num("OSW", wt);

src/core/c-word.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170

171171
/***********************************************************************
172172
**
173-
*/ static REBCNT Make_Word_Name(REBYTE *str, REBCNT len)
173+
*/ static REBCNT Make_Word_Name(const REBYTE *str, REBCNT len)
174174
/*
175175
** Allocates and copies the text string of the word.
176176
**
@@ -186,7 +186,7 @@
186186

187187
/***********************************************************************
188188
**
189-
*/ REBCNT Make_Word(REBYTE *str, REBCNT len)
189+
*/ REBCNT Make_Word(const REBYTE *str, REBCNT len)
190190
/*
191191
** Given a string and its length, compute its hash value,
192192
** search for a match, and if not found, add it to the table.

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
}
@@ -377,7 +377,7 @@ xx*/ void Dump_Bind_Table()
377377
args = BLK_HEAD(VAL_FUNC_ARGS(DSF_FUNC(dsf)));
378378
m = SERIES_TAIL(VAL_FUNC_ARGS(DSF_FUNC(dsf)));
379379
for (n = 1; n < m; n++)
380-
Debug_Fmt("\t%s: %72r", Get_Word_Name(args+n), DSF_ARGS(dsf, n));
380+
Debug_Fmt(cb_cast("\t%s: %72r"), Get_Word_Name(args+n), DSF_ARGS(dsf, n));
381381
}
382382
//Debug_Fmt(Str_Stack[2], PRIOR_DSF(dsf));
383383
if (PRIOR_DSF(dsf) > 0) Dump_Stack(PRIOR_DSF(dsf), dsf-1);

0 commit comments

Comments
 (0)