Skip to content

Commit

Permalink
FIX: many unsigned/signed variable conflict warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jan 21, 2023
1 parent 1742fa8 commit 149789c
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 111 deletions.
3 changes: 2 additions & 1 deletion src/core/a-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1149,7 +1150,7 @@ RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf, REBFLG
REBCNT idx;

// Convert C-string to Rebol word
len = strlen(cs_cast(name));
len = LEN_BYTES(name);
sym = Scan_Word(name, len);
if (!sym) return NOT_FOUND; //TODO: use different value if word is invalid?
idx = Register_Handle(sym, size, (REB_HANDLE_FREE_FUNC)free_func);
Expand Down
4 changes: 2 additions & 2 deletions src/core/b-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2022 Rebol Open Source Contributors
** Copyright 2012-2023 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -370,7 +370,7 @@ extern const REBYTE Str_Banner[];
***********************************************************************/
{
const REBYTE*version = BOOT_STR(RS_VERSION, 0);
Set_String(ds, Copy_Bytes(version, strlen(cs_cast(version))));
Set_String(ds, Copy_Bytes(version, LEN_BYTES(version)));
return R_RET;
}

Expand Down
7 changes: 4 additions & 3 deletions src/core/c-do.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1388,8 +1389,8 @@ x*/ static REBINT Do_Args_Light(REBVAL *func, REBVAL *path, REBSER *block, REBCN
REBCNT dsf;

REBSER *words;
REBINT len;
REBINT n;
REBLEN len;
REBLEN n;
REBINT start;
REBVAL *val;

Expand Down Expand Up @@ -1442,7 +1443,7 @@ x*/ static REBINT Do_Args_Light(REBVAL *func, REBVAL *path, REBSER *block, REBCN
}
// Copy block contents to stack:
if (len < n) n = len;
if (start + n + 100 > SERIES_REST(DS_Series)) Expand_Stack(STACK_MIN);
if (n + start + 100 > SERIES_REST(DS_Series)) Expand_Stack(STACK_MIN);
memcpy(&DS_Base[start], BLK_SKIP(block, index), n * sizeof(REBVAL));
DSP = start + n - 1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/d-crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -47,7 +48,7 @@ enum Crash_Msg_Nums {

/***********************************************************************
**
*/ void Crash(REBINT id, ...)
*/ REB_NORETURN void Crash(REBINT id, ...)
/*
** Print a failure message and abort.
**
Expand Down
5 changes: 3 additions & 2 deletions src/core/d-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -100,7 +101,7 @@ static REBREQ *Req_SIO;

/***********************************************************************
**
*/ static void Prin_OS_String(const REBYTE *bp, REBINT len, REBOOL uni, REBOOL err)
*/ static void Prin_OS_String(const REBYTE *bp, REBLEN len, REBOOL uni, REBOOL err)
/*
** Print a string, but no line terminator or space.
**
Expand All @@ -118,7 +119,7 @@ static REBREQ *Req_SIO;
if (!bp) Crash(RP_NO_PRINT_PTR);

// Determine length if not provided:
if (len == UNKNOWN) len = (REBINT)(uni ? wcslen((const wchar_t*)up) : LEN_BYTES(bp));
if (len == UNKNOWN) len = (uni ? (REBLEN)wcslen((const wchar_t*)up) : LEN_BYTES(bp));

SET_FLAG(Req_SIO->flags, RRF_FLUSH);
if (err)
Expand Down
12 changes: 7 additions & 5 deletions src/core/f-enbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -771,7 +772,8 @@ static REBU64 base36_powers[BASE36_LENGTH] = {
REBCNT ser_size;
REBINT pad = 0;
REBU64 c = 0;
REBINT i, d = 0;
REBINT d = 0;
REBCNT i;

cp = *src;

Expand Down Expand Up @@ -799,7 +801,7 @@ static REBU64 base36_powers[BASE36_LENGTH] = {
ser_size = SERIES_AVAIL(ser);
bp = STR_HEAD(ser);

for (i = 7; i >= 0; i--) {
for (i = 8; i > 0; --i) {
bp[i] = (REBYTE)(c & 0xFF);
c >>= 8;
}
Expand Down Expand Up @@ -1001,7 +1003,7 @@ static REBU64 base36_powers[BASE36_LENGTH] = {
REBYTE *bp;
REBYTE *src;
REBCNT x=0;
REBINT loop;
REBCNT loop;
REBCNT i, chunk;

if(len > VAL_LEN(value)) len = VAL_LEN(value);
Expand All @@ -1012,8 +1014,8 @@ static REBU64 base36_powers[BASE36_LENGTH] = {
// (Note: tail not properly set yet)

//if (len >= 32 && brk) *bp++ = LF;
loop = (len / 4) - 1;
if(loop >= 0) {
if(len >= 4) {
loop = (len / 4) - 1;
for (x = 0; x <= 4 * loop;) {
chunk = ((REBCNT)src[x++]) << 24u;
chunk |= ((REBCNT)src[x++]) << 16u;
Expand Down
5 changes: 3 additions & 2 deletions src/core/f-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -505,9 +506,9 @@ x*/ int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result)
case RXR_BAD_ARGS:
case RXR_ERROR:
{
const char* errmsg = frm.args[1].series;
const REBYTE* errmsg = frm.args[1].series;
if(errmsg != NULL) {
int len = strlen(errmsg);
REBLEN len = LEN_BYTES(errmsg);
VAL_SET(val, REB_STRING);
VAL_SERIES(val) = Make_Binary(len);
VAL_INDEX(val) = 0;
Expand Down
25 changes: 13 additions & 12 deletions src/core/n-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2022 Rebol Open Source Contributors
** Copyright 2012-2023 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -53,7 +53,7 @@ static mbedtls_ctr_drbg_context ctr_drbg;
{
REBVAL *blk;
REBVAL tmp;
REBCNT sym;
// REBCNT sym;

mbedtls_ctr_drbg_init(&ctr_drbg);
mbedtls_entropy_init(&entropy);
Expand Down Expand Up @@ -422,7 +422,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
}

//allocate new binary!
outBytes = mbedtls_rsa_get_len(rsa);
outBytes = (REBLEN)mbedtls_rsa_get_len(rsa);
data = Make_Binary(outBytes-1);
outBinary = BIN_DATA(data);

Expand All @@ -435,7 +435,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
else {
size_t olen = 0;
err = mbedtls_rsa_rsaes_pkcs1_v15_decrypt(rsa, mbedtls_ctr_drbg_random, &ctr_drbg, &olen, inBinary, outBinary, outBytes);
outBytes = olen;
outBytes = (REBLEN)olen;
}
if (err) goto error;

Expand Down Expand Up @@ -534,7 +534,8 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
REBSER *out = NULL;
REBINT err;
DHM_CTX *dhm;
size_t gx_len, gy_len, olen = 0;
REBLEN gx_len, gy_len;
size_t olen = 0;

if (refPublic && refSecret) {
// only one can be used
Expand All @@ -547,7 +548,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
dhm = (DHM_CTX *)VAL_HANDLE_CONTEXT_DATA(key);

if (refPublic) {
gx_len = mbedtls_mpi_size(&dhm->MBEDTLS_PRIVATE(GX));
gx_len = (REBLEN)mbedtls_mpi_size(&dhm->MBEDTLS_PRIVATE(GX));
if (gx_len <= 0) goto error;
out = Make_Binary(gx_len-1);
mbedtls_mpi_write_binary(&dhm->MBEDTLS_PRIVATE(GX), BIN_DATA(out), gx_len);
Expand All @@ -562,7 +563,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
// and derive the shared secret of these 2 public parts
err = mbedtls_dhm_calc_secret(dhm, BIN_DATA(out), gy_len, &olen, mbedtls_ctr_drbg_random, &ctr_drbg);
if (err) goto error;
BIN_LEN(out) = olen;
BIN_LEN(out) = (REBLEN)olen;
}
SET_BINARY(D_RET, out);
return R_RET;
Expand Down Expand Up @@ -661,7 +662,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
);
if (err) goto error;
SET_BINARY(D_RET, bin);
BIN_LEN(bin) = olen;
BIN_LEN(bin) = (REBLEN)olen;
}
if (ref_secret) {
mbed = &ctx->MBEDTLS_PRIVATE(ctx).MBEDTLS_PRIVATE(mbed_ecdh);
Expand All @@ -677,7 +678,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
if (err) goto error;

SET_BINARY(D_RET, bin);
BIN_LEN(bin) = olen;
BIN_LEN(bin) = (REBLEN)olen;
}
return R_RET;

Expand Down Expand Up @@ -725,9 +726,9 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
}
else {
SET_BINARY(D_RET, bin);
BIN_LEN(bin) = len;
BIN_LEN(bin) = (REBLEN)len;
}
exit:
//exit:
mbedtls_ecdsa_free(&ctx);
return (err) ? R_NONE : R_RET;
}
Expand Down Expand Up @@ -822,7 +823,7 @@ static int myrand(void *rng_state, unsigned char *output, size_t len)
goto done;
}
SET_BINARY(D_RET, bin);
BIN_LEN(bin) = len;
BIN_LEN(bin) = (REBLEN)len;
}
if (ref_verify) {
mbed = &ctx_ecdh->MBEDTLS_PRIVATE(ctx).private_mbed_ecdh;
Expand Down
14 changes: 9 additions & 5 deletions src/core/n-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2023 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -136,21 +137,24 @@ static REBSER *Read_All_File(char *fname)
{
REBVAL *val = D_ARG(1);
REB_MOLD mo = {0};
REBINT len = NO_LIMIT;
REBCNT len;

if (D_REF(3)) SET_FLAG(mo.opts, MOPT_MOLD_ALL);
if (D_REF(4)) SET_FLAG(mo.opts, MOPT_INDENT);
if (D_REF(5)) {
if (VAL_INT64(D_ARG(6)) > (i64)MAX_I32)
len = MAX_I32;
if (VAL_INT64(D_ARG(6)) > (i64)MAX_U32)
len = MAX_U32;
else if (VAL_INT64(D_ARG(6)) <= 0)
len = 0;
else
len = VAL_INT32(D_ARG(6));
len = VAL_UNT32(D_ARG(6));
}
else {
len = NO_LIMIT;
}

Reset_Mold(&mo);
mo.limit = (REBINT)len;
mo.limit = len;

if (D_REF(2) && IS_BLOCK(val)) SET_FLAG(mo.opts, MOPT_ONLY);

Expand Down
4 changes: 2 additions & 2 deletions src/core/n-oid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2022 Rebol Open Source Contributors
** Copyright 2012-2023 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -83,7 +83,7 @@
/* Last byte */
ret = snprintf(p, n, ".%u", value);
if (ret >= n) {
Extend_Series(out, ret - n + 1); // may reallocate p!
Extend_Series(out, (REBLEN)(ret - n + 1)); // may reallocate p!
p = SERIES_DATA(out) + SERIES_TAIL(out);
n = SERIES_AVAIL(out);
ret = snprintf(p, n, ".%u", value);
Expand Down
23 changes: 13 additions & 10 deletions src/core/n-strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2021 Rebol Open Source Contributors
** Copyright 2012-2023 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -185,7 +185,7 @@ static struct digest {
REBVAL *spec = D_ARG(ARG_CHECKSUM_SPEC);
REBINT sum;
REBINT i = 0;
REBINT j;
REBCNT j;
REBSER *digest, *ser;
REBCNT len, keylen;
REBYTE *data;
Expand Down Expand Up @@ -231,7 +231,7 @@ static struct digest {
REBYTE ipad[128],opad[128]; // Size must be max of all digest[].hmacblock;
void *ctx = Make_Mem(digests[i].ctxsize());

int blocklen = digests[i].hmacblock;
REBCNT blocklen = digests[i].hmacblock;

if (keylen > blocklen) {
digests[i].digest(keycp,keylen,tmpdigest);
Expand Down Expand Up @@ -921,7 +921,7 @@ static struct digest {
***********************************************************************/
{
REBVAL *arg = D_ARG(1);
REBINT len;
REBCNT len;
// REBSER *series;
REBYTE buffer[MAX_TUPLE*2+4]; // largest value possible
REBYTE *buf;
Expand All @@ -942,19 +942,22 @@ static struct digest {

buf = &buffer[0];

len = -1;
if (D_REF(2)) { // /size
//@@ https://github.com/Oldes/Rebol-issues/issues/127
len = (REBINT) VAL_INT64(D_ARG(3));
if (len <= 0) Trap_Arg(D_ARG(3));
if (VAL_INT64(D_ARG(3)) <= 0 || VAL_UNT64(D_ARG(3)) > MAX_U32)
Trap_Arg(D_ARG(3));
len = VAL_UNT32(D_ARG(3));
}
else {
len = NO_LIMIT;
}
if (IS_INTEGER(arg)) { // || IS_DECIMAL(arg)) {
if (len < 0 || len > MAX_HEX_LEN) len = MAX_HEX_LEN;
if (len == NO_LIMIT || len > MAX_HEX_LEN) len = MAX_HEX_LEN;
Form_Hex_Pad(buf, VAL_INT64(arg), len);
}
else if (IS_TUPLE(arg)) {
REBINT n;
if (len < 0 || len > 2 * MAX_TUPLE || len > 2 * VAL_TUPLE_LEN(arg))
REBCNT n;
if (len == NO_LIMIT || len > 2 * MAX_TUPLE || len > 2 * VAL_TUPLE_LEN(arg))
len = 2 * VAL_TUPLE_LEN(arg);
for (n = 0; n < VAL_TUPLE_LEN(arg); n++)
buf = Form_Hex2(buf, VAL_TUPLE(arg)[n]);
Expand Down
Loading

0 comments on commit 149789c

Please sign in to comment.