Commit 2ffd3a9a authored by Hardy Simpson's avatar Hardy Simpson

compile: protect memset with if()check to suppress __warn_memset_zero_len...

compile: protect memset with if()check to suppress __warn_memset_zero_len compiler errors in some gcc>4.5.x
parent b5597e79
......@@ -322,7 +322,7 @@ int zlog_buf_printf_dec32(zlog_buf_t * a_buf, uint32_t ui32, int width)
/* zero_len not changed */
num_len = len_left - zero_len;
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail += len_left;
//*(a_buf->tail) = '\0';
......@@ -337,7 +337,7 @@ int zlog_buf_printf_dec32(zlog_buf_t * a_buf, uint32_t ui32, int width)
}
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail = q;
//*(a_buf->tail) = '\0';
......@@ -413,7 +413,7 @@ int zlog_buf_printf_dec64(zlog_buf_t * a_buf, uint64_t ui64, int width)
/* zero_len not changed */
num_len = len_left - zero_len;
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail += len_left;
//*(a_buf->tail) = '\0';
......@@ -428,7 +428,7 @@ int zlog_buf_printf_dec64(zlog_buf_t * a_buf, uint64_t ui64, int width)
}
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail = q;
//*(a_buf->tail) = '\0';
......@@ -493,7 +493,7 @@ int zlog_buf_printf_hex(zlog_buf_t * a_buf, uint32_t ui32, int width)
/* zero_len not changed */
num_len = len_left - zero_len;
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail += len_left;
//*(a_buf->tail) = '\0';
......@@ -508,7 +508,7 @@ int zlog_buf_printf_hex(zlog_buf_t * a_buf, uint32_t ui32, int width)
}
}
memset(a_buf->tail, '0', zero_len);
if (zero_len) memset(a_buf->tail, '0', zero_len);
memcpy(a_buf->tail + zero_len, p, num_len);
a_buf->tail = q;
//*(a_buf->tail) = '\0';
......@@ -612,7 +612,7 @@ int zlog_buf_adjust_append(zlog_buf_t * a_buf, const char *str, size_t str_len,
source_len = append_len;
space_len = 0;
}
memset(a_buf->tail + source_len, ' ', space_len);
if (space_len) memset(a_buf->tail + source_len, ' ', space_len);
memcpy(a_buf->tail, str, source_len);
} else {
if (space_len < append_len) {
......@@ -621,7 +621,7 @@ int zlog_buf_adjust_append(zlog_buf_t * a_buf, const char *str, size_t str_len,
space_len = append_len;
source_len = 0;
}
memset(a_buf->tail, ' ', space_len);
if (space_len) memset(a_buf->tail, ' ', space_len);
memcpy(a_buf->tail + space_len, str, source_len);
}
a_buf->tail += append_len;
......@@ -637,10 +637,10 @@ int zlog_buf_adjust_append(zlog_buf_t * a_buf, const char *str, size_t str_len,
}
if (left_adjust) {
memset(a_buf->tail + source_len, ' ', space_len);
if (space_len) memset(a_buf->tail + source_len, ' ', space_len);
memcpy(a_buf->tail, str, source_len);
} else {
memset(a_buf->tail, ' ', space_len);
if (space_len) memset(a_buf->tail, ' ', space_len);
memcpy(a_buf->tail + space_len, str, source_len);
}
a_buf->tail += append_len;
......
......@@ -70,6 +70,7 @@ static int zc_arraylist_expand_inner(zc_arraylist_t * a_list, int max)
{
void *tmp;
int new_size;
int diff_size;
new_size = zc_max(a_list->size * 2, max);
tmp = realloc(a_list->array, new_size * sizeof(void *));
......@@ -79,8 +80,8 @@ static int zc_arraylist_expand_inner(zc_arraylist_t * a_list, int max)
return -1;
}
a_list->array = (void **)tmp;
memset(a_list->array + a_list->size, 0x00,
(new_size - a_list->size) * sizeof(void *));
diff_size = new_size - a_list->size;
if (diff_size) memset(a_list->array + a_list->size, 0x00, diff_size * sizeof(void *));
a_list->size = new_size;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment