summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-11-12 10:30:18 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-11-12 20:45:19 +0300
commit5407e712dd7c381c857827cdaf2902158213e07d (patch)
treec340a42874df6108166253daef3f2299958c2fc8 /cord
parente52e35343429108368986e4b28852bbe6e33f6e0 (diff)
downloadbdwgc-5407e712dd7c381c857827cdaf2902158213e07d.tar.gz
Eliminate 'casting signed to bigger unsigned int' CSA warning
* cord/cordprnt.c (CORD_vsprintf): Cast prec, width, max_size, res local variables to unsigned. * cord/tests/cordtest.c (test_basics): Change type of i local variable from int to size_t; cast c local variable to unsigned char. * dbg_mlc.c (GC_store_debug_info_inner): Do not cast linenum parameter. * include/private/dbg_mlc.h (oh.oh_string, oh.oh_int): Refine comment. * include/private/dbg_mlc.h (oh.oh_int): Change type from word to signed_word. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Cast GC_markers_m1 to signed_word first. * misc.c (GC_init): Cast space_divisor local variable to unsigned (instead of word). * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG] (GC_write): Cast bytes_written local variable to unsigned (instead of size_t).
Diffstat (limited to 'cord')
-rw-r--r--cord/cordprnt.c18
-rw-r--r--cord/tests/cordtest.c5
2 files changed, 12 insertions, 11 deletions
diff --git a/cord/cordprnt.c b/cord/cordprnt.c
index d9d9f536..0195cce0 100644
--- a/cord/cordprnt.c
+++ b/cord/cordprnt.c
@@ -241,18 +241,18 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
if (prec == VARIABLE) prec = va_arg(args, int);
arg = va_arg(args, CORD);
len = CORD_len(arg);
- if (prec != NONE && len > (size_t)prec) {
+ if (prec != NONE && len > (unsigned)prec) {
if (prec < 0) return(-1);
- arg = CORD_substr(arg, 0, prec);
+ arg = CORD_substr(arg, 0, (unsigned)prec);
len = (unsigned)prec;
}
- if (width != NONE && len < (size_t)width) {
- char * blanks =
- (char *)GC_MALLOC_ATOMIC(width - len + 1);
+ if (width != NONE && len < (unsigned)width) {
+ char * blanks = (char *)GC_MALLOC_ATOMIC(
+ (unsigned)width - len + 1);
if (NULL == blanks) OUT_OF_MEMORY;
- memset(blanks, ' ', width-len);
- blanks[width-len] = '\0';
+ memset(blanks, ' ', (unsigned)width - len);
+ blanks[(unsigned)width - len] = '\0';
if (left_adj) {
arg = CORD_cat(arg, blanks);
} else {
@@ -307,7 +307,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
if (prec != NONE && prec > max_size) max_size = prec;
max_size += CONV_RESULT_LEN;
if (max_size >= CORD_BUFSZ) {
- buf = (char *)GC_MALLOC_ATOMIC(max_size + 1);
+ buf = (char *)GC_MALLOC_ATOMIC((unsigned)max_size + 1);
if (NULL == buf) OUT_OF_MEMORY;
} else {
if (CORD_BUFSZ - (result[0].ec_bufptr-result[0].ec_buf)
@@ -352,7 +352,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
&& !defined(__EMX__))
va_end(vsprintf_args);
# endif
- len = (size_t)res;
+ len = (unsigned)res;
if ((char *)(GC_word)res == buf) {
/* old style vsprintf */
len = strlen(buf);
diff --git a/cord/tests/cordtest.c b/cord/tests/cordtest.c
index c3ad01f4..73ab82aa 100644
--- a/cord/tests/cordtest.c
+++ b/cord/tests/cordtest.c
@@ -65,7 +65,7 @@ char id_cord_fn(size_t i, void * client_data)
void test_basics(void)
{
CORD x = CORD_from_char_star("ab");
- int i;
+ size_t i;
CORD y;
CORD_pos p;
@@ -128,7 +128,8 @@ void test_basics(void)
while(CORD_pos_valid(p)) {
char c = CORD_pos_fetch(p);
- if(c != i) ABORT("Traversal of function node failed");
+ if ((unsigned char)c != i)
+ ABORT("Traversal of function node failed");
CORD_next(p);
i++;
}