Skip to content

Commit

Permalink
FIX: clang compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Apr 16, 2024
1 parent 8631f70 commit f6443ce
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/core/a-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ extern int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result);

/***********************************************************************
**
*/ RL_API void RL_Print(REBYTE *fmt, ...)
*/ RL_API void RL_Print(const REBYTE *fmt, ...)
/*
** Low level print of formatted data to the console.
**
Expand Down Expand Up @@ -1131,7 +1131,7 @@ RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf, REBFLG

/***********************************************************************
**
*/ RL_API REBCNT RL_Register_Handle(REBYTE *name, REBCNT size, void* free_func)
*/ RL_API REBCNT RL_Register_Handle(const REBYTE *name, REBCNT size, void* free_func)
/*
** Stores handle's specification (required data size and optional free callback.
**
Expand Down Expand Up @@ -1202,7 +1202,7 @@ RL_API REBCNT RL_Decode_UTF8_Char(const REBYTE *str, REBCNT *len)

/***********************************************************************
**
*/ RL_API REBCNT RL_Register_Handle_Spec(REBYTE *name, REBHSP *spec)
*/ RL_API REBCNT RL_Register_Handle_Spec(const REBYTE *name, REBHSP *spec)
/*
** Stores handle's specification (required data size and optional callbacks).
** It's an extended version of old RL_Register_Handle function.
Expand Down
4 changes: 1 addition & 3 deletions src/core/f-random.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ static REBI64 ran_x[KK]; /* the generator state */
#ifdef __STDC__
void ran_array(REBI64 aa[], int n)
#else
void ran_array(aa,n) /* put n new random numbers in aa */
REBI64 *aa; /* destination */
int n; /* array length (must be at least KK) */
void ran_array(REBI64* aa, int n) /* put n new random numbers in aa */
#endif
{
register int i,j;
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 @@ -52,7 +52,7 @@
oid = VAL_BIN_AT(val_oid);
len = VAL_LEN(val_oid);
out = Make_Binary(3 * len); // len * 3 should be enough to hold the result
p = SERIES_DATA(out);
p = (char*)SERIES_DATA(out);
n = SERIES_AVAIL(out);

if (len > 0) {
Expand Down Expand Up @@ -85,7 +85,7 @@
if (ret < 0) return R_ARG1; // error!
if ((size_t)ret >= n) {
Extend_Series(out, (REBLEN)(ret - n + 1)); // may reallocate p!
p = SERIES_DATA(out) + SERIES_TAIL(out);
p = (char*)(SERIES_DATA(out) + SERIES_TAIL(out));
n = SERIES_AVAIL(out);
ret = snprintf(p, n, ".%u", value);
if (ret < 0) return R_ARG1; // error!
Expand Down
4 changes: 3 additions & 1 deletion src/core/u-qoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
desc.height = codi->h;
desc.channels = 4;
desc.colorspace = QOI_SRGB;
int out_len = 0;

codi->data = qoi_encode(codi->bits, &desc, &codi->len);
codi->data = qoi_encode(codi->bits, &desc, &out_len);
codi->len = (out_len > 0) ? out_len : 0;
codi->error = codi->data == NULL ? -1 : 0;
}

Expand Down
14 changes: 7 additions & 7 deletions src/os/dev-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void Get_Local_IP(REBREQ *sock)
// Get the local IP address and port number.
// This code should be fast and never fail.
SOCKAI sa;
unsigned int len = sizeof(sa);
int len = sizeof(sa);

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

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

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

Expand Down Expand Up @@ -607,7 +607,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
{
SOCKAI sa;
REBREQ *news;
unsigned int len = sizeof(sa);
int len = sizeof(sa);
int result;
extern void Attach_Request(REBREQ **prior, REBREQ *req);

Expand Down
6 changes: 3 additions & 3 deletions src/os/host-ext-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
REBSER* str = RL_MAKE_STRING(32, FALSE); // 32 bytes, latin1 (must be large enough!)
REBYTE ver[8];
RL_VERSION(ver);
snprintf(SERIES_DATA(str), SERIES_REST(str), "Version: %i.%i.%i", ver[1], ver[2], ver[3]);
snprintf(s_cast(SERIES_DATA(str)), SERIES_REST(str), "Version: %i.%i.%i", ver[1], ver[2], ver[3]);
SERIES_TAIL(str) = LEN_BYTES(SERIES_DATA(str));
RXA_SERIES(frm, 1) = str;
RXA_TYPE (frm, 1) = RXT_STRING;
Expand Down Expand Up @@ -509,7 +509,7 @@ int XTestContext_mold(REBHOB *hob, REBSER *str) {
len = snprintf(
SERIES_DATA(str),
SERIES_REST(str),
"0#%lx id: %u", (unsigned long)hob->data, xtest->id
"0#%lx id: %u", (unsigned long)(uintptr_t)hob->data, xtest->id
);
if (len > 0) SERIES_TAIL(str) += len;
return len;
Expand All @@ -527,6 +527,6 @@ void Init_Ext_Test(void)
spec.get_path = XTestContext_get_path;
spec.set_path = XTestContext_set_path;
spec.mold = XTestContext_mold;
Handle_XTest = RL_REGISTER_HANDLE_SPEC("XTEST", &spec);
Handle_XTest = RL_REGISTER_HANDLE_SPEC((cb_cast("XTEST")), &spec);
}
#endif //TEST_EXTENSIONS
4 changes: 2 additions & 2 deletions src/os/win32/dev-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static BOOL Seek_File_64(REBREQ *file)
// On error, returns FALSE and sets file->error field.
HANDLE h = (HANDLE)file->handle;
DWORD result;
DWORD highint;
LONG highint;

if (file->file.index == -1) {
// Append:
Expand All @@ -69,7 +69,7 @@ static BOOL Seek_File_64(REBREQ *file)
}
else {
// Line below updates indexh if it is affected:
highint = (long)(file->file.index >> 32);
highint = file->file.index >> 32;
result = SetFilePointer(h, (long)(file->file.index), &highint, FILE_BEGIN);
}

Expand Down
4 changes: 2 additions & 2 deletions src/os/win32/dev-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static REBOOL Set_Serial_Settings(HANDLE hComm, REBREQ *req)
/*
***********************************************************************/
{
REBINT result = 0;
DWORD result = 0;
if (!req->handle) {
req->error = -RFE_NO_HANDLE;
return DR_ERROR;
Expand Down Expand Up @@ -205,7 +205,7 @@ static REBOOL Set_Serial_Settings(HANDLE hComm, REBREQ *req)
/*
***********************************************************************/
{
REBINT result = 0, len = 0;
DWORD result = 0, len = 0;
len = req->length - req->actual;
if (!req->handle) {
req->error = -RFE_NO_HANDLE;
Expand Down
4 changes: 2 additions & 2 deletions src/os/win32/host-compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ static REBXYF Zero_Pair = {0, 0};


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

// memcpy(pvBits, pixels, src_siz_x * src_siz_y * 4 );
Expand Down Expand Up @@ -585,7 +585,7 @@ static REBXYF Zero_Pair = {0, 0};
if (!AlphaBlend(hdc, left, top,
src_siz_x, src_siz_y,
hdcbmp, 0, 0, src_siz_x, src_siz_y, bf)) {
RL_Print("alphaBlend failed!\n");
RL_Print(cb_cast("alphaBlend failed!\n"));
}

// do cleanup
Expand Down
11 changes: 5 additions & 6 deletions src/os/win32/host-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,8 @@ static void onModalBlock(
break;

case WM_SIZE:

//case WM_SIZING:
RL_Print("SIZE %d\n", mode);
RL_Print(cb_cast("SIZE %d\n"), mode);
if (wParam == SIZE_MINIMIZED) {
//Invalidate the size but not win buffer
gob->old_size.x = 0;
Expand Down Expand Up @@ -607,7 +606,7 @@ static void onModalBlock(
};
int pf = ChoosePixelFormat(hdc, &pfd);
if (!pf) {
RL_Print("Could not find a pixel format.. OpenGL cannot create its context.\n");
RL_Print(cb_cast("Could not find a pixel format.. OpenGL cannot create its context.\n"));
return FALSE;
}
SetPixelFormat(hdc, pf, &pfd);
Expand All @@ -616,11 +615,11 @@ static void onModalBlock(
wglMakeCurrent(hdc, hglrc);
}
else {
RL_Print("Failed to create OpenGL context!\n");
RL_Print(cb_cast("Failed to create OpenGL context!\n"));
return FALSE;
}
RL_Print("OPENGL CONTEXT CREATED!\n");
RL_Print("Version %s\n", glGetString(GL_VERSION));
RL_Print(cb_cast("OPENGL CONTEXT CREATED!\n"));
RL_Print(cb_cast("Version %s\n"), glGetString(GL_VERSION));
return FALSE;

case WM_DESTROY:
Expand Down
17 changes: 11 additions & 6 deletions src/os/win32/host-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void Paint_Window(HWND window);
ZeroMemory(&wcex, sizeof(wcex));

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

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

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

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

Expand Down Expand Up @@ -781,7 +781,7 @@ void Paint_Window(HWND window);

// Remove any closed windows:
for (n = 0; n < MAX_WINDOWS; n++) {
if (g = Gob_Windows[n].gob) {
if ((g = Gob_Windows[n].gob)) {
if (!GOB_PARENT(g) && GET_GOB_FLAG(g, GOBF_WINDOW))
OS_Close_Window(g);
}
Expand Down Expand Up @@ -922,7 +922,7 @@ void Paint_Window(HWND window);
style |= CS_OWNDC;
break;
default:
//RL_Print("unknown widget name");
//RL_Print(cb_cast("unknown widget name"));
return NULL;
}

Expand Down Expand Up @@ -1151,6 +1151,11 @@ void Paint_Window(HWND window);
result = rect.top;
}
break;
case SM_SCREEN_NUM:
case SM_SCREEN_X:
case SM_SCREEN_Y:
// not used...
break;
}
return result;
}
Expand Down Expand Up @@ -1458,7 +1463,7 @@ void Paint_Window(HWND window);
| ICC_BAR_CLASSES
| ICC_DATE_CLASSES;
if (!InitCommonControlsEx(&InitCtrlEx)) {
RL_Print("Could not initialize common controls!\n");
RL_Print(cb_cast("Could not initialize common controls!\n"));
}
}
}
Expand Down

0 comments on commit f6443ce

Please sign in to comment.