Skip to content

Commit f6443ce

Browse files
committed
FIX: clang compiler warnings
1 parent 8631f70 commit f6443ce

11 files changed

+41
-37
lines changed

src/core/a-lib.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ extern int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result);
399399

400400
/***********************************************************************
401401
**
402-
*/ RL_API void RL_Print(REBYTE *fmt, ...)
402+
*/ RL_API void RL_Print(const REBYTE *fmt, ...)
403403
/*
404404
** Low level print of formatted data to the console.
405405
**
@@ -1131,7 +1131,7 @@ RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf, REBFLG
11311131

11321132
/***********************************************************************
11331133
**
1134-
*/ RL_API REBCNT RL_Register_Handle(REBYTE *name, REBCNT size, void* free_func)
1134+
*/ RL_API REBCNT RL_Register_Handle(const REBYTE *name, REBCNT size, void* free_func)
11351135
/*
11361136
** Stores handle's specification (required data size and optional free callback.
11371137
**
@@ -1202,7 +1202,7 @@ RL_API REBCNT RL_Decode_UTF8_Char(const REBYTE *str, REBCNT *len)
12021202

12031203
/***********************************************************************
12041204
**
1205-
*/ RL_API REBCNT RL_Register_Handle_Spec(REBYTE *name, REBHSP *spec)
1205+
*/ RL_API REBCNT RL_Register_Handle_Spec(const REBYTE *name, REBHSP *spec)
12061206
/*
12071207
** Stores handle's specification (required data size and optional callbacks).
12081208
** It's an extended version of old RL_Register_Handle function.

src/core/f-random.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ static REBI64 ran_x[KK]; /* the generator state */
5959
#ifdef __STDC__
6060
void ran_array(REBI64 aa[], int n)
6161
#else
62-
void ran_array(aa,n) /* put n new random numbers in aa */
63-
REBI64 *aa; /* destination */
64-
int n; /* array length (must be at least KK) */
62+
void ran_array(REBI64* aa, int n) /* put n new random numbers in aa */
6563
#endif
6664
{
6765
register int i,j;

src/core/n-oid.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
oid = VAL_BIN_AT(val_oid);
5353
len = VAL_LEN(val_oid);
5454
out = Make_Binary(3 * len); // len * 3 should be enough to hold the result
55-
p = SERIES_DATA(out);
55+
p = (char*)SERIES_DATA(out);
5656
n = SERIES_AVAIL(out);
5757

5858
if (len > 0) {
@@ -85,7 +85,7 @@
8585
if (ret < 0) return R_ARG1; // error!
8686
if ((size_t)ret >= n) {
8787
Extend_Series(out, (REBLEN)(ret - n + 1)); // may reallocate p!
88-
p = SERIES_DATA(out) + SERIES_TAIL(out);
88+
p = (char*)(SERIES_DATA(out) + SERIES_TAIL(out));
8989
n = SERIES_AVAIL(out);
9090
ret = snprintf(p, n, ".%u", value);
9191
if (ret < 0) return R_ARG1; // error!

src/core/u-qoi.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262
desc.height = codi->h;
6363
desc.channels = 4;
6464
desc.colorspace = QOI_SRGB;
65+
int out_len = 0;
6566

66-
codi->data = qoi_encode(codi->bits, &desc, &codi->len);
67+
codi->data = qoi_encode(codi->bits, &desc, &out_len);
68+
codi->len = (out_len > 0) ? out_len : 0;
6769
codi->error = codi->data == NULL ? -1 : 0;
6870
}
6971

src/os/dev-net.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void Get_Local_IP(REBREQ *sock)
8585
// Get the local IP address and port number.
8686
// This code should be fast and never fail.
8787
SOCKAI sa;
88-
unsigned int len = sizeof(sa);
88+
int len = sizeof(sa);
8989

9090
getsockname(sock->socket, (struct sockaddr *)&sa, &len);
9191
sock->net.local_ip = sa.sin_addr.s_addr; //htonl(ip); NOTE: REBOL stays in network byte order
@@ -96,7 +96,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
9696
{
9797
// Set non-blocking mode. Return TRUE if no error.
9898
#ifdef FIONBIO
99-
long mode = 1;
99+
u_long mode = 1;
100100
return !IOCTL(sock, FIONBIO, &mode);
101101
#else
102102
int flags;
@@ -317,7 +317,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
317317

318318
// Else, make the lookup request:
319319
host = OS_Make(MAXGETHOSTSTRUCT); // be sure to free it
320-
handle = WSAAsyncGetHostByName(Event_Handle, WM_DNS, sock->data, (char*)host, MAXGETHOSTSTRUCT);
320+
handle = WSAAsyncGetHostByName(Event_Handle, WM_DNS, (const char*)sock->data, (char*)host, MAXGETHOSTSTRUCT);
321321
if (handle != 0) {
322322
sock->net.host_info = host;
323323
sock->length = sock->socket; // save TCP socket temporarily
@@ -475,13 +475,13 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
475475
//WATCH1("sendto data: %x\n", sock->data);
476476
if (GET_FLAG(sock->modes, RST_UDP)) {
477477
Set_Addr(&remote_addr, sock->net.remote_ip, sock->net.remote_port);
478-
result = sendto(sock->socket, sock->data, len, flags,
478+
result = sendto(sock->socket, (const char*)sock->data, len, flags,
479479
(struct sockaddr*)&remote_addr, addr_len);
480480
}
481481
else {
482482
// Expects that the socket is already connected and
483483
// there is no need to specify the remote address again
484-
result = send(sock->socket, sock->data, len, flags);
484+
result = send(sock->socket, (const char*)sock->data, len, flags);
485485
}
486486

487487
//printf("sento time: %d\n", OS_Delta_Time(tm, 0));
@@ -500,7 +500,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
500500
// if (result < 0) ...
501501
}
502502
else {
503-
result = recvfrom(sock->socket, sock->data, len, 0,
503+
result = recvfrom(sock->socket, (char*)sock->data, len, 0,
504504
(struct sockaddr*)&remote_addr, &addr_len);
505505
WATCH2("recv() len: %d result: %d\n", len, result);
506506

@@ -607,7 +607,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
607607
{
608608
SOCKAI sa;
609609
REBREQ *news;
610-
unsigned int len = sizeof(sa);
610+
int len = sizeof(sa);
611611
int result;
612612
extern void Attach_Request(REBREQ **prior, REBREQ *req);
613613

src/os/host-ext-test.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
425425
REBSER* str = RL_MAKE_STRING(32, FALSE); // 32 bytes, latin1 (must be large enough!)
426426
REBYTE ver[8];
427427
RL_VERSION(ver);
428-
snprintf(SERIES_DATA(str), SERIES_REST(str), "Version: %i.%i.%i", ver[1], ver[2], ver[3]);
428+
snprintf(s_cast(SERIES_DATA(str)), SERIES_REST(str), "Version: %i.%i.%i", ver[1], ver[2], ver[3]);
429429
SERIES_TAIL(str) = LEN_BYTES(SERIES_DATA(str));
430430
RXA_SERIES(frm, 1) = str;
431431
RXA_TYPE (frm, 1) = RXT_STRING;
@@ -509,7 +509,7 @@ int XTestContext_mold(REBHOB *hob, REBSER *str) {
509509
len = snprintf(
510510
SERIES_DATA(str),
511511
SERIES_REST(str),
512-
"0#%lx id: %u", (unsigned long)hob->data, xtest->id
512+
"0#%lx id: %u", (unsigned long)(uintptr_t)hob->data, xtest->id
513513
);
514514
if (len > 0) SERIES_TAIL(str) += len;
515515
return len;
@@ -527,6 +527,6 @@ void Init_Ext_Test(void)
527527
spec.get_path = XTestContext_get_path;
528528
spec.set_path = XTestContext_set_path;
529529
spec.mold = XTestContext_mold;
530-
Handle_XTest = RL_REGISTER_HANDLE_SPEC("XTEST", &spec);
530+
Handle_XTest = RL_REGISTER_HANDLE_SPEC((cb_cast("XTEST")), &spec);
531531
}
532532
#endif //TEST_EXTENSIONS

src/os/win32/dev-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static BOOL Seek_File_64(REBREQ *file)
6060
// On error, returns FALSE and sets file->error field.
6161
HANDLE h = (HANDLE)file->handle;
6262
DWORD result;
63-
DWORD highint;
63+
LONG highint;
6464

6565
if (file->file.index == -1) {
6666
// Append:
@@ -69,7 +69,7 @@ static BOOL Seek_File_64(REBREQ *file)
6969
}
7070
else {
7171
// Line below updates indexh if it is affected:
72-
highint = (long)(file->file.index >> 32);
72+
highint = file->file.index >> 32;
7373
result = SetFilePointer(h, (long)(file->file.index), &highint, FILE_BEGIN);
7474
}
7575

src/os/win32/dev-serial.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static REBOOL Set_Serial_Settings(HANDLE hComm, REBREQ *req)
170170
/*
171171
***********************************************************************/
172172
{
173-
REBINT result = 0;
173+
DWORD result = 0;
174174
if (!req->handle) {
175175
req->error = -RFE_NO_HANDLE;
176176
return DR_ERROR;
@@ -205,7 +205,7 @@ static REBOOL Set_Serial_Settings(HANDLE hComm, REBREQ *req)
205205
/*
206206
***********************************************************************/
207207
{
208-
REBINT result = 0, len = 0;
208+
DWORD result = 0, len = 0;
209209
len = req->length - req->actual;
210210
if (!req->handle) {
211211
req->error = -RFE_NO_HANDLE;

src/os/win32/host-compositor.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ static REBXYF Zero_Pair = {0, 0};
557557

558558

559559
// create our DIB section and select the bitmap into the dc
560-
hbitmap = CreateDIBSection(hdcbmp, &bmi, DIB_RGB_COLORS, &pvBits , NULL, 0x0);
560+
hbitmap = CreateDIBSection(hdcbmp, &bmi, DIB_RGB_COLORS, (void**)&pvBits, NULL, 0x0);
561561
SelectObject(hdcbmp, hbitmap);
562562

563563
// memcpy(pvBits, pixels, src_siz_x * src_siz_y * 4 );
@@ -585,7 +585,7 @@ static REBXYF Zero_Pair = {0, 0};
585585
if (!AlphaBlend(hdc, left, top,
586586
src_siz_x, src_siz_y,
587587
hdcbmp, 0, 0, src_siz_x, src_siz_y, bf)) {
588-
RL_Print("alphaBlend failed!\n");
588+
RL_Print(cb_cast("alphaBlend failed!\n"));
589589
}
590590

591591
// do cleanup

src/os/win32/host-event.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,8 @@ static void onModalBlock(
284284
break;
285285

286286
case WM_SIZE:
287-
288287
//case WM_SIZING:
289-
RL_Print("SIZE %d\n", mode);
288+
RL_Print(cb_cast("SIZE %d\n"), mode);
290289
if (wParam == SIZE_MINIMIZED) {
291290
//Invalidate the size but not win buffer
292291
gob->old_size.x = 0;
@@ -607,7 +606,7 @@ static void onModalBlock(
607606
};
608607
int pf = ChoosePixelFormat(hdc, &pfd);
609608
if (!pf) {
610-
RL_Print("Could not find a pixel format.. OpenGL cannot create its context.\n");
609+
RL_Print(cb_cast("Could not find a pixel format.. OpenGL cannot create its context.\n"));
611610
return FALSE;
612611
}
613612
SetPixelFormat(hdc, pf, &pfd);
@@ -616,11 +615,11 @@ static void onModalBlock(
616615
wglMakeCurrent(hdc, hglrc);
617616
}
618617
else {
619-
RL_Print("Failed to create OpenGL context!\n");
618+
RL_Print(cb_cast("Failed to create OpenGL context!\n"));
620619
return FALSE;
621620
}
622-
RL_Print("OPENGL CONTEXT CREATED!\n");
623-
RL_Print("Version %s\n", glGetString(GL_VERSION));
621+
RL_Print(cb_cast("OPENGL CONTEXT CREATED!\n"));
622+
RL_Print(cb_cast("Version %s\n"), glGetString(GL_VERSION));
624623
return FALSE;
625624

626625
case WM_DESTROY:

src/os/win32/host-window.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void Paint_Window(HWND window);
295295
ZeroMemory(&wcex, sizeof(wcex));
296296

297297
if(!GetClassInfoEx(hInstance, old_class, &wcex)) {
298-
RL_Print("Failed to get old class info!\n");
298+
RL_Print(cb_cast("Failed to get old class info!\n"));
299299
}
300300
wcex.cbSize = sizeof(WNDCLASSEX);
301301
wcex.cbWndExtra = 0; //sizeof(WNDEXTRA);
@@ -344,11 +344,11 @@ void Paint_Window(HWND window);
344344

345345
wc.lpfnWndProc = REBOL_OpenGL_Proc;
346346
wc.lpszClassName = TXT("RebOpenGL");
347-
if (!RegisterClassEx(&wc)) RL_Print("Failed to register OpenGL class\n");
347+
if (!RegisterClassEx(&wc)) RL_Print(cb_cast("Failed to register OpenGL class\n"));
348348

349349
wc.lpfnWndProc = REBOL_Base_Proc;
350350
wc.lpszClassName = TXT("RebBase");
351-
if (!RegisterClassEx(&wc)) RL_Print("Failed to register Base class\n");
351+
if (!RegisterClassEx(&wc)) RL_Print(cb_cast("Failed to register Base class\n"));
352352

353353
//Make_Subclass(Class_Name_Button, TEXT("BUTTON"), NULL, TRUE);
354354

@@ -781,7 +781,7 @@ void Paint_Window(HWND window);
781781

782782
// Remove any closed windows:
783783
for (n = 0; n < MAX_WINDOWS; n++) {
784-
if (g = Gob_Windows[n].gob) {
784+
if ((g = Gob_Windows[n].gob)) {
785785
if (!GOB_PARENT(g) && GET_GOB_FLAG(g, GOBF_WINDOW))
786786
OS_Close_Window(g);
787787
}
@@ -922,7 +922,7 @@ void Paint_Window(HWND window);
922922
style |= CS_OWNDC;
923923
break;
924924
default:
925-
//RL_Print("unknown widget name");
925+
//RL_Print(cb_cast("unknown widget name"));
926926
return NULL;
927927
}
928928

@@ -1151,6 +1151,11 @@ void Paint_Window(HWND window);
11511151
result = rect.top;
11521152
}
11531153
break;
1154+
case SM_SCREEN_NUM:
1155+
case SM_SCREEN_X:
1156+
case SM_SCREEN_Y:
1157+
// not used...
1158+
break;
11541159
}
11551160
return result;
11561161
}
@@ -1458,7 +1463,7 @@ void Paint_Window(HWND window);
14581463
| ICC_BAR_CLASSES
14591464
| ICC_DATE_CLASSES;
14601465
if (!InitCommonControlsEx(&InitCtrlEx)) {
1461-
RL_Print("Could not initialize common controls!\n");
1466+
RL_Print(cb_cast("Could not initialize common controls!\n"));
14621467
}
14631468
}
14641469
}

0 commit comments

Comments
 (0)