From 5ad20c90e31abfb9854cf2eae8292e44f2e18671 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 28 May 2019 17:06:15 -0400 Subject: build-fix and compiler-warnings when TRACE_TM is defined Signed-off-by: Thomas E. Dickey --- src/TMaction.c | 7 ++++--- src/TMstate.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/TMaction.c b/src/TMaction.c index d1ca2ca..84ba2a0 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -476,11 +476,12 @@ static XtActionProc *EnterBindCache( bindCache->widgetClass = XtClass(w); if (_XtGlobalTM.numBindCache == _XtGlobalTM.bindCacheTblSize) { - _XtGlobalTM.bindCacheTblSize += 16; + _XtGlobalTM.bindCacheTblSize = + (TMShortCard)(_XtGlobalTM.bindCacheTblSize + 16); _XtGlobalTM.bindCacheTbl = (TMBindCache *) XtRealloc((char *)_XtGlobalTM.bindCacheTbl, - ((_XtGlobalTM.bindCacheTblSize) * - sizeof(TMBindCache))); + (Cardinal)((_XtGlobalTM.bindCacheTblSize) * + sizeof(TMBindCache))); } _XtGlobalTM.bindCacheTbl[_XtGlobalTM.numBindCache++] = bindCache; #endif /* TRACE_TM */ diff --git a/src/TMstate.c b/src/TMstate.c index 0856909..910788a 100644 --- a/src/TMstate.c +++ b/src/TMstate.c @@ -1423,10 +1423,10 @@ XtTranslations _XtCreateXlations( #ifdef TRACE_TM LOCK_PROCESS; if (_XtGlobalTM.numTms == _XtGlobalTM.tmTblSize) { - _XtGlobalTM.tmTblSize += 16; + _XtGlobalTM.tmTblSize = (TMShortCard)(_XtGlobalTM.tmTblSize + 16); _XtGlobalTM.tmTbl = (XtTranslations *) XtRealloc((char *)_XtGlobalTM.tmTbl, - _XtGlobalTM.tmTblSize * sizeof(XtTranslations)); + (Cardinal)(_XtGlobalTM.tmTblSize * sizeof(XtTranslations))); } _XtGlobalTM.tmTbl[_XtGlobalTM.numTms++] = xlations; UNLOCK_PROCESS; @@ -1601,7 +1601,7 @@ void _XtAddEventSeqToStateTree( AmbigActions(initialEvent, state, stateTree); (*state)->actions = eventSeq->actions; #ifdef TRACE_TM - LOCK_PROCESS + LOCK_PROCESS; _XtGlobalTM.numComplexActions++; UNLOCK_PROCESS; #endif /* TRACE_TM */ -- cgit v1.2.3 From 390e9e20c029e4eb159d39bd3d79160ca4567650 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 28 May 2019 18:35:16 -0400 Subject: build- and compiler-warning fixes when XTTRACEMEMORY is defined Signed-off-by: Thomas E. Dickey --- src/Alloc.c | 22 +++++++++++----------- src/Selection.c | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Alloc.c b/src/Alloc.c index d75898c..7013f1c 100644 --- a/src/Alloc.c +++ b/src/Alloc.c @@ -307,7 +307,7 @@ void _XtHeapFree( typedef struct _Stats *StatsPtr; typedef struct _Stats { StatsPtr prev, next; - char *file; + const char *file; int line; unsigned size; unsigned long seq; @@ -317,9 +317,9 @@ typedef struct _Stats { static StatsPtr XtMemory = (StatsPtr)NULL; static unsigned long ActiveXtMemory = 0; static unsigned long XtSeqId = 0; -static unsigned long XtSeqBreakpoint = ~0; +static unsigned long XtSeqBreakpoint = (unsigned long)(~0UL); -#define StatsSize(n) ((((n) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) + sizeof(Stats)) +#define StatsSize(n) (unsigned)((((n) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) + sizeof(Stats)) #define ToStats(ptr) ((StatsPtr)(ptr - sizeof(Stats))) #define ToMem(ptr) (((char *)ptr) + sizeof(Stats)) @@ -349,7 +349,7 @@ static void _XtBreakpoint( char *_XtMalloc( unsigned size, - char *file, + const char *file, int line) { StatsPtr ptr; @@ -375,7 +375,7 @@ char *XtMalloc( char *_XtRealloc( char *ptr, unsigned size, - char *file, + const char *file, int line) { char *newptr; @@ -401,7 +401,7 @@ char *XtRealloc( char *_XtCalloc( unsigned num, unsigned size, - char *file, + const char *file, int line) { StatsPtr ptr; @@ -475,7 +475,7 @@ void XtFree(char *ptr) char *_XtHeapMalloc( Heap *heap, Cardinal size, - char *file, + const char *file, int line) { StatsPtr ptr; @@ -493,7 +493,7 @@ char *_XtHeapMalloc( return retval; } -void _XtHeapFree(register XtPointer heap) +void _XtHeapFree(Heap* heap) { register StatsPtr mem, next; @@ -517,7 +517,7 @@ void _XtHeapFree(register XtPointer heap) #include -void _XtPrintMemory(char * filename) +void _XtPrintMemory(const char * filename) { register StatsPtr mem; FILE *f; @@ -527,10 +527,10 @@ void _XtPrintMemory(char * filename) else f = fopen(filename, "w"); LOCK_PROCESS; - fprintf(f, "total size: %d\n", ActiveXtMemory); + fprintf(f, "total size: %lu\n", ActiveXtMemory); for (mem = XtMemory; mem; mem = mem->next) { if (mem->file) - fprintf(f, "size: %6d seq: %5d %12s(%4d) %s\n", + fprintf(f, "size: %6d seq: %5lu %12s(%4d) %s\n", mem->size, mem->seq, mem->file, mem->line, mem->heap ? "heap" : ""); } diff --git a/src/Selection.c b/src/Selection.c index 0e1a483..8c48dd7 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -1212,7 +1212,7 @@ static void HandleGetIncrement( #ifdef XT_COPY_SELECTION int size = (int) BYTELENGTH(length, info->format) + 1; char *tmp = __XtMalloc((Cardinal) size); - (void) memmove(tmp, value, size); + (void) memmove(tmp, value, (size_t) size); XFree(value); value = tmp; #endif @@ -1321,7 +1321,7 @@ Boolean HandleNormal( if (value) { /* it could have been deleted after the SelectionNotify */ int size = (int) BYTELENGTH(length, info->format) + 1; char *tmp = __XtMalloc((Cardinal) size); - (void) memmove(tmp, value, size); + (void) memmove(tmp, value, (size_t) size); XFree(value); value = (unsigned char *) tmp; } @@ -2206,7 +2206,7 @@ void XtGetSelectionParameters( if (*value_return) { int size = (int) BYTELENGTH(*length_return, *format_return) + 1; char *tmp = __XtMalloc((Cardinal) size); - (void) memmove(tmp, *value_return, size); + (void) memmove(tmp, *value_return, (size_t) size); XFree(*value_return); *value_return = tmp; } -- cgit v1.2.3 From 66c1ea79516a0b31043dc604172a42cd859e5b47 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 28 May 2019 18:46:27 -0400 Subject: fix compiler warnings when _TRACE_HEAP is defined Signed-off-by: Thomas E. Dickey --- src/Alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Alloc.c b/src/Alloc.c index 7013f1c..dd2f616 100644 --- a/src/Alloc.c +++ b/src/Alloc.c @@ -249,7 +249,7 @@ char* _XtHeapAlloc( if ((bytes + sizeof(char*)) >= (HEAP_SEGMENT_SIZE>>1)) { /* preserve current segment; insert this one in front */ #ifdef _TRACE_HEAP - printf( "allocating large segment (%d bytes) on heap %#x\n", + printf( "allocating large segment (%d bytes) on heap %p\n", bytes, heap ); #endif heap_loc = XtMalloc(bytes + (Cardinal) sizeof(char*)); @@ -265,7 +265,7 @@ char* _XtHeapAlloc( } /* else discard remainder of this segment */ #ifdef _TRACE_HEAP - printf( "allocating new segment on heap %#x\n", heap ); + printf( "allocating new segment on heap %p\n", heap ); #endif heap_loc = XtMalloc((unsigned)HEAP_SEGMENT_SIZE); *(char**)heap_loc = heap->start; -- cgit v1.2.3 From 4194ff5b427e39bb5325db0f377e80b3e6982e17 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 28 May 2019 18:49:25 -0400 Subject: fix compiler warnings when WHITEFILL is defined Signed-off-by: Thomas E. Dickey --- src/Intrinsic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Intrinsic.c b/src/Intrinsic.c index 49bec47..de41b53 100644 --- a/src/Intrinsic.c +++ b/src/Intrinsic.c @@ -1229,7 +1229,7 @@ static String ExtractLocaleName( strncpy(buf, start, (size_t) len); *(buf + len) = '\0'; # ifdef WHITEFILL - for (temp = buf; temp = strchr(temp, ' '); ) + for (temp = buf; (temp = strchr(temp, ' ')) != NULL; ) *temp++ = '-'; # endif return buf; @@ -1239,10 +1239,10 @@ static String ExtractLocaleName( # ifdef WHITEFILL if (strchr(lang, ' ')) { if (buf != NULL) XtFree (buf); - else buf = XtMalloc (strlen (lang) + 1); + else buf = XtMalloc ((Cardinal)strlen (lang) + 1); if (buf == NULL) return NULL; strcpy(buf, lang); - for (temp = buf; temp = strchr(temp, ' '); ) + for (temp = buf; (temp = strchr(temp, ' ')) != NULL; ) *temp++ = '-'; return buf; } -- cgit v1.2.3