Skip to content

Commit

Permalink
Cleaned up almost all compiler warnings by careful casting
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Dec 19, 2018
1 parent 70d7e74 commit a3564f4
Show file tree
Hide file tree
Showing 49 changed files with 160 additions and 160 deletions.
2 changes: 2 additions & 0 deletions src/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
18 Dec 2018
* cleaned up compiler warnings in various files by careful casting
17 Dec 2018
* cleaned up win32 fileopen routines considerably
* added resDialogTemplate, resDialogItemTemplate for creating memory dialog templates
Expand Down
4 changes: 2 additions & 2 deletions src/Configs/config.macosx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ PSPTOOLSPREFIX = psp-
#
####################################################################
OPTIMIZE = Y
DEBUG = Y
VERBOSE = Y
DEBUG = N
VERBOSE = N
THREADSAFE = Y
GPROF = N
#SHOWSTUBS = 1
Expand Down
4 changes: 2 additions & 2 deletions src/Configs/config.suse
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ PSPTOOLSPREFIX = psp-
#
####################################################################
OPTIMIZE = Y
DEBUG = Y
VERBOSE = Y
DEBUG = N
VERBOSE = N
THREADSAFE = Y
GPROF = N
#SHOWSTUBS = 1
Expand Down
4 changes: 2 additions & 2 deletions src/config
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ PSPTOOLSPREFIX = psp-
#
####################################################################
OPTIMIZE = Y
DEBUG = Y
VERBOSE = Y
DEBUG = N
VERBOSE = N
THREADSAFE = Y
GPROF = N
#SHOWSTUBS = 1
Expand Down
1 change: 0 additions & 1 deletion src/demos/canny/canny.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ PMWIMAGEHDR
read_image_pixmap(GR_WINDOW_ID wid)
{
MWIMAGEINFO info;
GR_PIXELVAL *buf, *out;
static MWIMAGEHDR image;

GrGetImageInfo(wid, &info);
Expand Down
2 changes: 1 addition & 1 deletion src/demos/fbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ X11_init(void)
sprintf(name, "fbe %dx%dx%dbpp", CRTX, CRTY, BITS_PER_PIXEL);

XChangeProperty(display, window, XA_WM_NAME, XA_STRING, 8,
PropModeReplace, name, strlen(name));
PropModeReplace, (unsigned char *)name, strlen(name));
XMapWindow(display, window);

gc = XCreateGC(display, window, 0, NULL);
Expand Down
8 changes: 4 additions & 4 deletions src/demos/mwdvetest/mwdvetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ DLGBOOL CALLBACK defDemoDlg ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
if( GetDlgCtrlID((HWND)lParam) == IDC_CTLCOLOR )
{
HBRUSH hbr = (HBRUSH)DefWindowProc ( hWnd, message, wParam, lParam );
HBRUSH hbr = (HBRUSH)(LRESULT)DefWindowProc ( hWnd, message, wParam, lParam );
SetTextColor ( (HDC)wParam, RGB(255,0,0) );
SetBkColor ( (HDC)wParam, GetSysColor(COLOR_3DFACE) );
return hbr;
return (DLGBOOL)hbr;
}
}
return DefWindowProc ( hWnd, message, wParam, lParam );
Expand Down Expand Up @@ -97,7 +97,7 @@ DLGBOOL CALLBACK dlgDemoStatic ( HWND hWnd, UINT message, WPARAM wParam, LPARAM
"\xd8\xaa\xd8\xab\xd8\xac\xd8\xad 12345\n"
);
SendDlgItemMessage(hWnd, IDC_STATICFONT1, WM_SETFONT,
(WPARAM)GetStockObject(SYSTEM_FONT), 0 );
(WPARAM)(HGDIOBJ)GetStockObject(SYSTEM_FONT), 0 );
}

return defDemoDlg ( hWnd, message, wParam, lParam );
Expand Down Expand Up @@ -298,7 +298,7 @@ DLGBOOL CALLBACK dlgDemoList ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
//printf ( "WM_MEASUREITEM\n" );
if( lpMs->CtlID == IDC_LIST_ODV )
{
lpMs->itemHeight = 14+3*abs(3-lpMs->itemID);
lpMs->itemHeight = 14+3*abs(3-(INT)lpMs->itemID);
}
else
lpMs->itemHeight = 20;
Expand Down
6 changes: 3 additions & 3 deletions src/demos/mwin/mine.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int bombnum = 10;

static BOM bom[30][18];
static NO NoAdr[540];
static SCORE score[3];
//static SCORE score[3];
static int itime, leftbombnum;
static int oldx, oldy, adrx, adry;
static int flag_bombout, flag_finished, flag_size = 2;
Expand Down Expand Up @@ -350,7 +350,7 @@ void Finished(HWND hWnd)
int i,j;
HDC hdc;
RECT bombnumber;
MAINWINCREATE CreateInfo;
//MAINWINCREATE CreateInfo;

hdc = GetDC(hWnd);

Expand Down Expand Up @@ -827,7 +827,7 @@ LRESULT TestMyWinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
int ran1, ran2;
static RECT bombregion, face, onerect, bombnumber, clock;
static RECT winposition;
MAINWINCREATE CreateInfo;
//MAINWINCREATE CreateInfo;

PAINTSTRUCT ps;
switch (message) {
Expand Down
4 changes: 2 additions & 2 deletions src/demos/mwin/mwalpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CreateAppWindow(void)
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
width, height,
NULL, (HMENU)++nextid, NULL, NULL);
NULL, (HMENU)(LONG_PTR)++nextid, NULL, NULL);

return hwnd;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
hbmpOrg = SelectObject(hdcMem, hbmp);

/* paint window to offscreen*/
hbr = (HBRUSH)GetClassLongPtr(hwnd, GCL_HBRBACKGROUND);
hbr = (HBRUSH)(ULONG_PTR)GetClassLongPtr(hwnd, GCL_HBRBACKGROUND);
FillRect(hdcMem, &rc, hbr);
SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT));
SetBkMode(hdcMem, TRANSPARENT);
Expand Down
14 changes: 7 additions & 7 deletions src/demos/mwin/mwdemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ RegisterAppClass(void)
HWND
CreateAppWindow(void)
{
HWND hwnd, hlist;
HWND hwnd;
static int nextid = 1;
int width, height;
RECT r;
Expand All @@ -134,7 +134,7 @@ CreateAppWindow(void)
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
width, height,
NULL, (HMENU)nextid++, NULL, NULL);
NULL, (HMENU)(LONG_PTR)nextid++, NULL, NULL);

#if CONTROLS
if(hwnd
Expand Down Expand Up @@ -169,7 +169,7 @@ CreateAppWindow(void)
width * 5 / 8, 32, 100, 18,
hwnd, (HMENU)6, NULL, NULL);

hlist = CreateWindowEx(0L, "LISTBOX",
HWND hlist = CreateWindowEx(0L, "LISTBOX",
"OK",
WS_HSCROLL|WS_VSCROLL|WS_BORDER|WS_CHILD | WS_VISIBLE,
width * 5 / 8, 54, 100, 48,
Expand Down Expand Up @@ -273,7 +273,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
break;

case WM_TIMER:
pData = (pdemoWndData) GetWindowLongPtr(hwnd, 0);
pData = (pdemoWndData)(LONG_PTR)GetWindowLongPtr(hwnd, 0);
#if GRAPH3D
GetClientRect(hwnd, &rc);
if(countup) {
Expand Down Expand Up @@ -302,9 +302,9 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
break;
case WM_DESTROY:
KillTimer(hwnd, 1);
pData = (pdemoWndData) GetWindowLongPtr(hwnd, 0);
pData = (pdemoWndData)(LONG_PTR)GetWindowLongPtr(hwnd, 0);
free ( pData );
SetWindowLongPtr(hwnd, 0, NULL);
SetWindowLongPtr(hwnd, 0, (LONG_PTR)0);
break;
case WM_SIZE:
break;
Expand Down Expand Up @@ -443,7 +443,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)

case WM_MOUSEMOVE:
#if GRAPH3D
pData = (pdemoWndData) GetWindowLongPtr(hwnd, 0);
pData = (pdemoWndData)(LONG_PTR)GetWindowLongPtr(hwnd, 0);
if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
POINT pt;

Expand Down
1 change: 0 additions & 1 deletion src/demos/mwin/mwprogbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
MSG msg;
WNDCLASS wndclass;

HWND hlist;
int width, height;

width=270;
Expand Down
6 changes: 3 additions & 3 deletions src/demos/mwin/mwterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
if(ch == '\r')
EmOutChar(hwnd, '\n');
} else
WritePtyShell(ttyfd, &ch, 1);
WritePtyShell(ttyfd, (char *)&ch, 1);
break;

case WM_FDINPUT:
if(ReadPtyShell(ttyfd, &ch, 1) == 1)
if(ReadPtyShell(ttyfd, (char *)&ch, 1) == 1)
EmOutChar(hwnd, ch);
break;

Expand Down Expand Up @@ -208,7 +208,7 @@ EmOutChar(HWND hwnd, unsigned char ch)
rc.right -= XMARGIN;
rc.bottom -= YMARGIN;
FillRect(hdc, &rc,
(HBRUSH)GetClassLongPtr(hwnd, GCL_HBRBACKGROUND));
(HBRUSH)(ULONG_PTR)GetClassLongPtr(hwnd, GCL_HBRBACKGROUND));
ReleaseDC(hwnd, hdc);
}
return;
Expand Down
6 changes: 3 additions & 3 deletions src/demos/nanox/getselection.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static int got_client_data(GR_EVENT *event)
{
GR_EVENT_CLIENT_DATA *ev = &event->clientdata;

fprintf(stderr, "Got client data packet with serial number %ld for window %d from window %d\n",
fprintf(stderr, "Got client data packet with serial number %d for window %d from window %d\n",
ev->serial, ev->wid, ev->rid);

if(!(data = realloc(data, bytes_received + ev->datalen + 1))) {
Expand All @@ -25,10 +25,10 @@ static int got_client_data(GR_EVENT *event)
}
memcpy(data + bytes_received, ev->data, ev->datalen);

fprintf(stderr, "Got client data packet with serial number %ld for window %d from window %d\n",
fprintf(stderr, "Got client data packet with serial number %d for window %d from window %d\n",
ev->serial, ev->wid, ev->rid);

fprintf(stderr, "Already received %ld bytes, this packet is %ld bytes, total data length is %ld bytes so ",
fprintf(stderr, "Already received %d bytes, this packet is %d bytes, total data length is %d bytes so ",
bytes_received, ev->datalen, ev->len);

bytes_received += ev->datalen;
Expand Down
2 changes: 1 addition & 1 deletion src/demos/nanox/nsaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define RANDRANGE(LO, HI) ((rand() % ((int)(HI) - (int)(LO) + 1)) + (int)(LO))
#define FRANDRANGE(LO, HI) (((double)rand() * ((double)(HI) - (double)(LO)) / \
#define FRANDRANGE(LO, HI) (((double)(int)rand() * ((double)(HI) - (double)(LO)) / \
(double)((double)RAND_MAX + 1.0)) + (double)(LO))

#define PI 3.14159265358979323846264338327
Expand Down
15 changes: 6 additions & 9 deletions src/demos/nanox/nxlsclients.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ main(int argc, char* argv[])
printf("\tAbsolute upper-left Y: %d\n", info.y);
printf("\tWidth = %d\n", info.width);
printf("\tHeight = %d\n", info.height);
printf("\tBorder: size = %d, colour = %s (#%06lX)\n", \
info.bordersize,
lookupColour(info.bordercolor), info.bordercolor);
printf("\tBackground colour = %s (#%06lX)\n", \
lookupColour(info.background), info.background);
printf("\tBorder: size = %d, colour = %s (#%06X)\n",
info.bordersize, lookupColour(info.bordercolor), info.bordercolor);
printf("\tBackground colour = %s (#%06X)\n", lookupColour(info.background), info.background);

printf("\tParent = %d\n", info.parent);
printf("\tFirst child = %d\n", info.child);
Expand All @@ -155,7 +153,7 @@ main(int argc, char* argv[])
printf(", realized = %d", info.realized);
printf("\n");

printf("\tEvent mask (0x%08lX):\n", info.eventmask);
printf("\tEvent mask (0x%08X):\n", info.eventmask);
{
int i, n = 0;
GR_EVENT_MASK tmp = info.eventmask;
Expand Down Expand Up @@ -190,8 +188,7 @@ main(int argc, char* argv[])

printf("\t\tBackground colour: ");
if ((wm_props.flags & GR_WM_FLAGS_BACKGROUND) == GR_WM_FLAGS_BACKGROUND)
printf("%s (#%06lX)\n", lookupColour(wm_props.background),
wm_props.background);
printf("%s (#%06X)\n", lookupColour(wm_props.background), wm_props.background);
else
printf("<unspecified>\n");

Expand All @@ -201,7 +198,7 @@ main(int argc, char* argv[])
else
printf("<unspecified>\n");

printf("\t\tProperty bits (0x%08lX):\n", wm_props.props);
printf("\t\tProperty bits (0x%08X):\n", wm_props.props);
{
int i, n = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/demos/nanox/setselection.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(int argc, char *argv[])
switch(event.type) {
case GR_EVENT_TYPE_CLIENT_DATA_REQ:
req = &event.clientdatareq;
fprintf(stderr, "Got request with serial number %ld from window %d for mime type %d\n",
fprintf(stderr, "Got request with serial number %d from window %d for mime type %d\n",
req->serial, req->rid, req->mimetype);
GrSendClientData(wid, req->rid, req->serial, data_len, data_len, buf);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/demos/nanox/snap_ppm.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int writeout(snapstate *state)
return 1;
}

if(fwrite(rgb, 3, 1, fp) < 0) goto badwrite;
if(!fwrite(rgb, 3, 1, fp)) goto badwrite;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/demos/nbreaker/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void dump_state(nbstate *state)
state->animateperiod);

/* Print the time of the last animate() call: */
printf("lastanim = %ldS %lduS\n", state->lastanim.tv_sec,
printf("lastanim = %ldS %duS\n", state->lastanim.tv_sec,
state->lastanim.tv_usec);

/* Print the current power-up and power-down timer values: */
Expand Down
12 changes: 7 additions & 5 deletions src/demos/nxscribble/li_recognizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ static char *lialg_recognize_stroke(rClassifier *, point_list *);
char* li_err_msg = NULL;
char _zdebug_flag[128];

#ifndef __ECOS
#ifdef __ECOS
#define BCOPY bcopy
#else
/* This is standard - defined in <stdlib.h> */
#define bcopy(s1,s2,n) memcpy(s2,s1,n)
#define BCOPY(s1,s2,n) memcpy(s2,s1,n)
#endif

#if 0 /* was #ifdef mips*/
Expand Down Expand Up @@ -93,7 +95,7 @@ add_example(point_list* l,int npts,pen_point* pts)

/*Copy points.*/

bcopy(pts,lpts,npts * sizeof(pen_point));
BCOPY(pts,lpts,npts * sizeof(pen_point));

return(p);
}
Expand Down Expand Up @@ -261,8 +263,8 @@ read_classifier_points(FILE* fd,int nclss,point_list** ex,char** cnames)

/*Transfer to recognizer.*/

bcopy(examples,ex,sizeof(examples));
bcopy(names,cnames,sizeof(names));
BCOPY(examples,ex,sizeof(examples));
BCOPY(names,cnames,sizeof(names));

return(0);

Expand Down
2 changes: 1 addition & 1 deletion src/demos/nxscribble/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ Matrix m, inv;
printf("det = %g\n", det);
}
*/
if(abs(det) > abs(maxdet))
if(fabs(det) > fabs(maxdet))
maxdet = det, mi = i, mj = j;
FreeMatrix(sm);
}
Expand Down
2 changes: 1 addition & 1 deletion src/demos/nxscribble/sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ register sClassifier sc;
{
register sClassIndex c;

printf("\n----Classifier %x, %d features:-----\n", (int*)sc, sc->nfeatures);
printf("\n----Classifier %x, %d features:-----\n", (int)sc, sc->nfeatures);
printf("%d classes: ", sc->nclasses);
for(c = 0; c < sc->nclasses; c++)
printf("%s ", sc->classdope[c]->name);
Expand Down
2 changes: 0 additions & 2 deletions src/demos/nxscribble/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ char *tempstring(); /* returns a pointer to space that will reused soon */

#ifdef __ECOS
extern char *strdup(char *);
#else
#define bcopy movmem
#endif
#define index strchr
#define rindex strrchr
Expand Down

0 comments on commit a3564f4

Please sign in to comment.