Skip to content

Commit 1d56a21

Browse files
committed
FIX: several clang warnings fixed
1 parent 445ee86 commit 1d56a21

File tree

7 files changed

+24
-20
lines changed

7 files changed

+24
-20
lines changed

src/core/n-crypt.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ static uECC_Curve get_ecc_curve(REBCNT curve_type) {
621621

622622
if (ref_init) {
623623
if(!uECC_make_key(ecc->public, ecc->private, curve)) {
624-
puts("failed to init ECDH key");
624+
//puts("failed to init ECDH key");
625625
Trap0(RE_INVALID_HANDLE); //TODO: change to something better!
626626
} else return R_ARG1;
627627
}
@@ -757,6 +757,7 @@ static uECC_Curve get_ecc_curve(REBCNT curve_type) {
757757
return R_FALSE;
758758
}
759759
}
760+
return R_UNSET;
760761
}
761762

762763

@@ -798,7 +799,7 @@ static uECC_Curve get_ecc_curve(REBCNT curve_type) {
798799
if (IS_BINARY(val_ctx)) {
799800
len = VAL_LEN(val_ctx);
800801
if (!(len == 32 || len == 16)) {
801-
printf("ChaCha20 key must be of size 32 or 16 bytes! Is: %i\n", len);
802+
//printf("ChaCha20 key must be of size 32 or 16 bytes! Is: %i\n", len);
802803
Trap1(RE_INVALID_DATA, val_ctx);
803804
return R_NONE;
804805
}

src/core/n-io.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ static REBSER *Read_All_File(char *fname)
869869
REBSER *blk;
870870
REBSER *dir;
871871

872-
while (n = (REBCNT)LEN_STR(str)) {
872+
while ((n = (REBCNT)LEN_STR(str))) {
873873
len++;
874874
str += n + 1; // next
875875
}
@@ -888,7 +888,7 @@ static REBSER *Read_All_File(char *fname)
888888
dir = To_REBOL_Path(str, n, -1, TRUE);
889889
str += n + 1; // next
890890
len = dir->tail;
891-
while (n = (REBCNT)LEN_STR(str)) {
891+
while ((n = (REBCNT)LEN_STR(str))) {
892892
dir->tail = len;
893893
Append_Uni_Uni(dir, str, n);
894894
Set_Series(REB_FILE, Append_Value(blk), Copy_String(dir, 0, -1));

src/core/t-tuple.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
REBVAL *arg;
189189
REBYTE *vp = NULL;
190190
REBYTE *ap = NULL;
191-
REBINT len = 0;
191+
REBCNT len = 0;
192192
REBINT alen;
193193
REBINT v;
194194
REBINT a;

src/core/u-compress.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void Trap_ZStream_Error(z_stream *stream, int err, REBOOL while_compression)
8282
{
8383
REBVAL *ret = DS_RETURN;
8484
if(stream->msg) {
85-
REBSER* msg = Append_UTF8(NULL, cs_cast(stream->msg), cast(REBINT, strlen(stream->msg)));
85+
REBSER* msg = Append_UTF8(NULL, cb_cast(stream->msg), cast(REBINT, strlen(stream->msg)));
8686
SET_STRING(ret, msg);
8787
} else {
8888
SET_INTEGER(ret, err);

src/core/u-iconv.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,13 @@ static REBINT get_codepage_id(REBVAL *cp)
518518

519519
//printf("get_codepage_id from: %s\n", name);
520520
#ifdef TO_WINDOWS
521-
if (_strnicmp(name, "cp", 2) == 0)
522-
return atoi(name + 2); /* CP123 */
521+
if (_strnicmp(cs_cast(name), "cp", 2) == 0)
522+
return atoi(cs_cast(name + 2)); /* CP123 */
523523
else if ('0' <= name[0] && name[0] <= '9')
524-
return atoi(name); /* 123 */
524+
return atoi(cs_cast(name)); /* 123 */
525525

526526
for (i = 0; codepage_alias[i].name != NULL; ++i)
527-
if (_stricmp(name, codepage_alias[i].name) == 0)
527+
if (_stricmp(cs_cast(name), codepage_alias[i].name) == 0)
528528
return codepage_alias[i].codepage;
529529
#else
530530
if (strncasecmp(name, "cp", 2) == 0)
@@ -628,11 +628,11 @@ static REBYTE* get_codepage_name(REBVAL *cp)
628628
}
629629

630630
if (VAL_LEN(data) > 0) {
631-
dst_len = MultiByteToWideChar(cp, 0, VAL_BIN_DATA(data), src_len, NULL, 0);
631+
dst_len = MultiByteToWideChar(cp, 0, cs_cast(VAL_BIN_DATA(data)), src_len, NULL, 0);
632632
if (dst_len <= 0) return R_NONE; //@@ or error?
633633

634634
dst_wide = Make_Series(dst_len, 2, FALSE);
635-
dst_len = MultiByteToWideChar(cp, 0, VAL_BIN_DATA(data), src_len, (REBCHR*)BIN_HEAD(dst_wide), dst_len);
635+
dst_len = MultiByteToWideChar(cp, 0, cs_cast(VAL_BIN_DATA(data)), src_len, (REBCHR*)BIN_HEAD(dst_wide), dst_len);
636636
dst_wide->tail = dst_len;
637637
} else {
638638
dst_wide = Make_Series(1, 2, FALSE);
@@ -670,7 +670,7 @@ static REBYTE* get_codepage_name(REBVAL *cp)
670670
if (dst_len <= 0) return R_NONE; //@@ or error?
671671

672672
dest = Make_Series(dst_len, 1, FALSE);
673-
dst_len = WideCharToMultiByte(tp, 0, (REBCHR*)BIN_HEAD(dst_wide), dst_wide->tail, BIN_HEAD(dest), dst_len, 0, &default_char_used);
673+
dst_len = WideCharToMultiByte(tp, 0, (REBCHR*)BIN_HEAD(dst_wide), dst_wide->tail, s_cast(BIN_HEAD(dest)), dst_len, 0, &default_char_used);
674674
dest->tail = dst_len;
675675
}
676676
else {

src/include/reb-ext.h

+3
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,6 @@ enum {
166166
RXC_QUEUED, // pending in event queue
167167
RXC_DONE, // call completed, structs can be freed
168168
};
169+
170+
171+
#define AS_WORD(w) RL_MAP_WORD(b_cast(w)) // may be used to awoid warning casting from char* to REBYTE*

src/os/host-ext-test.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ REBCNT Test_Async_Callback(REBSER *obj, REBCNT word)
178178
RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
179179
REBYTE *str;
180180

181-
printf("Context ptr: %08X\n", ctx);
181+
printf("Context ptr: %p\n", ctx);
182182

183183
switch (cmd) {
184184

@@ -196,7 +196,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
196196
break;
197197

198198
case 3: //command [{return system word from internal string}]
199-
RXA_WORD(frm, 1) = RL_MAP_WORD("system"); //?? is frame always long enough??
199+
RXA_WORD(frm, 1) = AS_WORD("system"); //?? is frame always long enough??
200200
RXA_TYPE(frm, 1) = RXT_WORD;
201201
break;
202202

@@ -247,7 +247,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
247247
case 11: //command [{creates a handle}]"
248248
{
249249
RXA_HANDLE(frm, 1) = (void*)42;
250-
RXA_HANDLE_TYPE(frm, 1) = RL_MAP_WORD("xtest");
250+
RXA_HANDLE_TYPE(frm, 1) = AS_WORD("xtest");
251251
RXA_TYPE(frm, 1) = RXT_HANDLE;
252252
}
253253
break;
@@ -270,7 +270,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
270270
case 14: //command [{return vector size in values (from object)} o [object!]]
271271
{
272272
RXIARG vec;
273-
REBCNT type = RL_GET_FIELD(RXA_OBJECT(frm, 1), RL_MAP_WORD("v"), &vec);
273+
REBCNT type = RL_GET_FIELD(RXA_OBJECT(frm, 1), AS_WORD("v"), &vec);
274274
if(type == RXT_VECTOR) {
275275
REBSER *vecs = (REBSER*)vec.series;
276276
u16* data = (u16*)vecs->data;
@@ -287,8 +287,8 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
287287
REBSER *blk = RXA_SERIES(frm, 1);
288288
REBCNT n, type;
289289
RXIARG val;
290-
printf("\nBlock with %i values:\n", RL_SERIES(blk, RXI_SER_TAIL));
291-
for(n = 0; type = RL_GET_VALUE(blk, n, &val); n++) {
290+
printf("\nBlock with %llu values:\n", RL_SERIES(blk, RXI_SER_TAIL));
291+
for(n = 0; (type = RL_GET_VALUE(blk, n, &val)); n++) {
292292
if(type == RXT_END) break;
293293
printf("\t%i -> %i\n", n, type);
294294
}
@@ -306,5 +306,5 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
306306

307307
void Init_Ext_Test(void)
308308
{
309-
RL = RL_Extend(&RX_Spec[0], (RXICAL)&RX_Call);
309+
RL = RL_Extend(b_cast(&RX_Spec[0]), (RXICAL)&RX_Call);
310310
}

0 commit comments

Comments
 (0)