Skip to content

Commit d3a9cdf

Browse files
committed
FIX: trying to get rid of pointer-sign warnings when using Clang
This is mostly (not exactly) based on Hostile Fork's commit metaeducation@91c07ea
1 parent a39eead commit d3a9cdf

Some content is hidden

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

42 files changed

+250
-203
lines changed

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

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

@@ -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,7 +699,7 @@ extern const REBYTE Str_Banner[];
699699

700700
/***********************************************************************
701701
**
702-
*/ void Register_Codec(REBYTE *name, codo dispatcher)
702+
*/ void Register_Codec(const REBYTE *name, codo dispatcher)
703703
/*
704704
** Internal function for adding a codec.
705705
**
@@ -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(cb_cast("text"), Codec_Text);
723+
Register_Codec(cb_cast("markup"), Codec_Markup);
724724
#ifdef USE_BMP_CODEC
725725
Init_BMP_Codec();
726726
#endif

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_(BOOT_STR(RS_TRACE,6), Get_Word_Name(word));
260+
Debug_Fmt_(cb_cast(BOOT_STR(RS_TRACE,6)), Get_Word_Name(word));
261261
Debug_Values(value, 1, 50);
262262
}
263263

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-task.c

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

70-
Debug_Str("Begin Task");
70+
Debug_Str((REBYTE*)"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("End Task");
77+
Debug_Str((REBYTE*)"End Task");
7878
}
7979

8080

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-dump.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ xx*/ void Dump_Bind_Table()
349349
};
350350

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

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

src/core/d-print.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static REBREQ *Req_SIO;
7171
**
7272
***********************************************************************/
7373
{
74-
Req_SIO->data = BYTES("\n");
74+
Req_SIO->data = b_cast("\n");
7575
Req_SIO->length = 1;
7676
Req_SIO->actual = 0;
7777

@@ -452,7 +452,7 @@ static REBREQ *Req_SIO;
452452

453453
/***********************************************************************
454454
**
455-
*/ void Debug_Fmt_(REBYTE *fmt, ...)
455+
*/ void Debug_Fmt_(const REBYTE *fmt, ...)
456456
/*
457457
** Print using a format string and variable number
458458
** of arguments. All args must be long word aligned
@@ -878,6 +878,6 @@ static REBREQ *Req_SIO;
878878
**
879879
***********************************************************************/
880880
{
881-
Set_Root_Series(TASK_BUF_PRINT, Make_Binary(1000), "print buffer");
882-
Set_Root_Series(TASK_BUF_FORM, Make_Binary(64), "form buffer");
881+
Set_Root_Series(TASK_BUF_PRINT, Make_Binary(1000), cb_cast("print buffer"));
882+
Set_Root_Series(TASK_BUF_FORM, Make_Binary(64), cb_cast("form buffer"));
883883
}

src/core/f-deci.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ deci deci_divide (deci a, deci b) {
10441044

10451045
#define MAX_NB 7
10461046

1047-
INLINE REBINT m_to_string (REBYTE *s, REBINT n, const REBCNT a[]) {
1047+
static INLINE REBINT m_to_string (REBYTE *s, REBINT n, const REBCNT a[]) {
10481048
REBCNT r, b[MAX_NB];
10491049
REBYTE v[10 * MAX_NB + 1], *vmax, *k;
10501050

@@ -1068,7 +1068,7 @@ INLINE REBINT m_to_string (REBYTE *s, REBINT n, const REBCNT a[]) {
10681068
*--k = '0' + r;
10691069
}
10701070

1071-
strcpy(s, k);
1071+
strcpy(s_cast(s), s_cast(k));
10721072
return vmax - k;
10731073
}
10741074

@@ -1102,7 +1102,7 @@ REBINT deci_to_string(REBYTE *string, const deci a, const REBYTE symbol, const R
11021102
}
11031103
*s++ = 'e';
11041104
INT_TO_STR(e - 1, s);
1105-
s = strchr(s, '\0');
1105+
s = b_cast(strchr(s_cast(s), '\0'));
11061106
} else { /* -6 <= e <= 0 */
11071107
memmove(s + 2 - e, s, j + 1);
11081108
*s++ = '0';
@@ -1122,7 +1122,7 @@ REBINT deci_to_string(REBYTE *string, const deci a, const REBYTE symbol, const R
11221122
s += j;
11231123
*s++ = 'e';
11241124
INT_TO_STR(e - j, s);
1125-
s = strchr(s, '\0');
1125+
s = b_cast(strchr(s_cast(s), '\0'));
11261126
}
11271127

11281128
return s - string;
@@ -1180,8 +1180,8 @@ deci deci_mod (deci a, deci b) {
11801180
}
11811181

11821182
/* in case of error the function returns deci_zero and *endptr = s */
1183-
deci string_to_deci (REBYTE *s, REBYTE **endptr) {
1184-
REBYTE *a = s;
1183+
deci string_to_deci (const REBYTE *s, const REBYTE **endptr) {
1184+
const REBYTE *a = s;
11851185
deci b = {0, 0, 0, 0, 0};
11861186
REBCNT sb[] = {0, 0, 0, 0}; /* significand */
11871187
REBINT f = 0, e = 0; /* exponents */
@@ -1281,7 +1281,7 @@ REBFLG deci_is_same (deci a, deci b) {
12811281
return (a.m0 == b.m0) && (a.m1 == b.m1) && (a.m2 == b.m2) && (a.s == b.s) && (a.e == b.e);
12821282
}
12831283

1284-
deci binary_to_deci(REBYTE s[12]) {
1284+
deci binary_to_deci(const REBYTE s[12]) {
12851285
deci d;
12861286
/* this looks like the only way, since the order of bits in bitsets is compiler-dependent */
12871287
d.s = s[0] >> 7;

src/core/f-enbase.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@
309309

310310
/***********************************************************************
311311
**
312-
*/ static REBSER *Decode_Base2(REBYTE **src, REBCNT len, REBYTE delim)
312+
*/ static REBSER *Decode_Base2(const REBYTE **src, REBCNT len, REBYTE delim)
313313
/*
314314
***********************************************************************/
315315
{
316316
REBYTE *bp;
317-
REBYTE *cp;
317+
const REBYTE *cp;
318318
REBCNT count = 0;
319319
REBINT accum = 0;
320320
REBYTE lex;
@@ -359,12 +359,12 @@
359359

360360
/***********************************************************************
361361
**
362-
*/ static REBSER *Decode_Base16(REBYTE **src, REBCNT len, REBYTE delim)
362+
*/ static REBSER *Decode_Base16(const REBYTE **src, REBCNT len, REBYTE delim)
363363
/*
364364
***********************************************************************/
365365
{
366366
REBYTE *bp;
367-
REBYTE *cp;
367+
const REBYTE *cp;
368368
REBCNT count = 0;
369369
REBINT accum = 0;
370370
REBYTE lex;
@@ -404,12 +404,12 @@
404404

405405
/***********************************************************************
406406
**
407-
*/ static REBSER *Decode_Base64(REBYTE **src, REBCNT len, REBYTE delim, REBOOL urlSafe)
407+
*/ static REBSER *Decode_Base64(const REBYTE **src, REBCNT len, REBYTE delim, REBOOL urlSafe)
408408
/*
409409
***********************************************************************/
410410
{
411411
REBYTE *bp;
412-
REBYTE *cp;
412+
const REBYTE *cp;
413413
REBCNT flip, pos;
414414
REBINT accum;
415415
REBYTE lex;
@@ -513,7 +513,7 @@
513513

514514
/***********************************************************************
515515
**
516-
*/ REBYTE *Decode_Binary(REBVAL *value, REBYTE *src, REBCNT len, REBINT base, REBYTE delim, REBOOL urlSafe)
516+
*/ const REBYTE *Decode_Binary(REBVAL *value, const REBYTE *src, REBCNT len, REBINT base, REBYTE delim, REBOOL urlSafe)
517517
/*
518518
** Scan and convert a binary string.
519519
**

src/core/f-extension.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ x*/ int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result)
328328
}
329329

330330
// Call its info() function for header and code body:
331-
if (!(info = OS_FIND_FUNCTION(dll, BOOT_STR(RS_EXTENSION, 0)))){
331+
if (!(info = OS_FIND_FUNCTION(dll, cs_cast(BOOT_STR(RS_EXTENSION, 0))))){
332332
OS_CLOSE_LIBRARY(dll);
333333
Trap1(RE_BAD_EXTENSION, val);
334334
}
@@ -341,7 +341,7 @@ x*/ int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result)
341341

342342
// Import the string into REBOL-land:
343343
src = Copy_Bytes(code, -1); // Nursery protected
344-
call = OS_FIND_FUNCTION(dll, BOOT_STR(RS_EXTENSION, 2)); // zero is allowed
344+
call = OS_FIND_FUNCTION(dll, cs_cast(BOOT_STR(RS_EXTENSION, 2))); // zero is allowed
345345
}
346346
else {
347347
// Hosted extension:

src/core/f-math.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
/***********************************************************************
3939
**
40-
*/ REBYTE *Grab_Int(REBYTE *cp, REBINT *val)
40+
*/ const REBYTE *Grab_Int(const REBYTE *cp, REBINT *val)
4141
/*
4242
** Grab an integer value from the string.
4343
**
@@ -70,7 +70,7 @@
7070

7171
/***********************************************************************
7272
**
73-
*/ REBYTE *Grab_Int_Scale(REBYTE *cp, REBINT *val, REBCNT scale)
73+
*/ const REBYTE *Grab_Int_Scale(const REBYTE *cp, REBINT *val, REBCNT scale)
7474
/*
7575
** Return integer scaled to the number of digits specified.
7676
** Used for the decimal part of numbers (e.g. times).
@@ -177,18 +177,18 @@
177177

178178
n = Form_Int_Len(tmp, val, max);
179179
if (n == 0) {
180-
strcpy(buf, "??");
180+
strcpy(s_cast(buf), "??");
181181
return buf; // too long
182182
}
183183

184184
if (len >= 0) {
185-
strcpy(buf, tmp);
185+
strcpy(s_cast(buf), s_cast(tmp));
186186
buf += n;
187187
for (; n < len; n++) *buf++ = pad;
188188
}
189189
else { // len < 0
190190
for (; n < -len; len++) *buf++ = pad;
191-
strcpy(buf, tmp);
191+
strcpy(s_cast(buf), s_cast(tmp));
192192
buf += n;
193193
}
194194

@@ -317,7 +317,7 @@
317317
if (e) {
318318
*cp++ = 'e';
319319
INT_TO_STR(e - 1, cp);
320-
cp = strchr(cp, 0);
320+
cp = b_cast(strchr(s_cast(cp), 0));
321321
}
322322

323323
if (trim == DEC_MOLD_PERCENT) *cp++ = '%';

0 commit comments

Comments
 (0)