diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2019-03-17 17:19:45 -0400 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2019-04-06 10:31:25 -0700 |
commit | cf9e8c73c4ffa671d580938c9a84d6ef0bd2710d (patch) | |
tree | 21cd4cab8b92df9f9050ea8df40d9cc35bed451d /src/Alloc.c | |
parent | fb7e899e94dd402c868e8eb59ccf32284732f6ac (diff) |
This cleans up the "easy" warning fixes which can be made using my
Regress script, comparing object-files before/after the edits:
https://invisible-island.net/ansification/index.html
https://invisible-island.net/scripts/readme.html
The changes are casts, which quiet the gcc warnings about implicit
conversion that my "gcc-normal" script would show. I avoided
reformatting the code.
The change reduces the number of gcc warnings from 769 to 163.
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src/Alloc.c')
-rw-r--r-- | src/Alloc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Alloc.c b/src/Alloc.c index 754881b..868af3b 100644 --- a/src/Alloc.c +++ b/src/Alloc.c @@ -143,20 +143,20 @@ Cardinal XtAsprintf( if (len < 0) _XtAllocError("vsnprintf"); - *new_string = XtMalloc(len + 1); /* snprintf doesn't count trailing '\0' */ + *new_string = XtMalloc((Cardinal) len + 1); /* snprintf doesn't count trailing '\0' */ if (len < sizeof(buf)) { - strncpy(*new_string, buf, len); + strncpy(*new_string, buf, (size_t) len); (*new_string)[len] = '\0'; } else { va_start(ap, format); - if (vsnprintf(*new_string, len + 1, format, ap) < 0) + if (vsnprintf(*new_string, (size_t) (len + 1), format, ap) < 0) _XtAllocError("vsnprintf"); va_end(ap); } - return len; + return (Cardinal) len; } @@ -252,7 +252,7 @@ char* _XtHeapAlloc( printf( "allocating large segment (%d bytes) on heap %#x\n", bytes, heap ); #endif - heap_loc = XtMalloc(bytes + sizeof(char*)); + heap_loc = XtMalloc(bytes + (Cardinal) sizeof(char*)); if (heap->start) { *(char**)heap_loc = *(char**)heap->start; *(char**)heap->start = heap_loc; @@ -273,10 +273,10 @@ char* _XtHeapAlloc( heap->current = heap_loc + sizeof(char*); heap->bytes_remaining = HEAP_SEGMENT_SIZE - sizeof(char*); } - bytes = (bytes + (sizeof(long) - 1)) & (~(sizeof(long) - 1)); + bytes = (Cardinal) ((bytes + (sizeof(long) - 1)) & (~(sizeof(long) - 1))); heap_loc = heap->current; heap->current += bytes; - heap->bytes_remaining -= bytes; /* can be negative, if rounded */ + heap->bytes_remaining = (heap->bytes_remaining - (int) bytes); /* can be negative, if rounded */ return heap_loc; } |