Skip to content

Commit ec5859f

Browse files
committed
Add some fixes required by the C99 standard.
Use c-style cast instead of reinterpret_cast. Use identifiers for function parameters. Use type cast to avoid conversion error. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent bc82654 commit ec5859f

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

jerry-core/ecma/operations/ecma-objects.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
616616

617617
lit_string_hash_t hash = name_p->hash;
618618
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
619-
uint32_t bitmap_column = hash % bitmap_row_size;
619+
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
620620

621621
if ((own_names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) == 0)
622622
{
@@ -648,7 +648,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
648648
{
649649
lit_string_hash_t hash = name_p->hash;
650650
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
651-
uint32_t bitmap_column = hash % bitmap_row_size;
651+
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
652652

653653
bool is_add = true;
654654

@@ -687,7 +687,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
687687

688688
lit_string_hash_t hash = name_p->hash;
689689
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
690-
uint32_t bitmap_column = hash % bitmap_row_size;
690+
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
691691

692692
if ((names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) == 0)
693693
{
@@ -805,7 +805,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
805805

806806
lit_string_hash_t hash = name_p->hash;
807807
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
808-
uint32_t bitmap_column = hash % bitmap_row_size;
808+
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
809809

810810
if ((names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) == 0)
811811
{

tests/unit/test-api.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,12 @@ static bool foreach (const jerry_api_string_t *name,
287287
return true;
288288
} /* foreach */
289289

290-
static bool foreach_exception (const jerry_api_string_t *name, const jerry_api_value_t *, void *)
290+
#define UNUSED(x) (void)(x)
291+
292+
static bool foreach_exception (const jerry_api_string_t *name, const jerry_api_value_t *value, void * user_data)
291293
{
294+
UNUSED (value);
295+
UNUSED (user_data);
292296
char str_buf_p[128];
293297
ssize_t sz = jerry_api_string_to_char_buffer (name, (jerry_api_char_t *)str_buf_p, 128);
294298
str_buf_p[sz] = '\0';
@@ -300,9 +304,12 @@ static bool foreach_exception (const jerry_api_string_t *name, const jerry_api_v
300304
return true;
301305
} /* foreach_exception */
302306

303-
static bool foreach_subset (const jerry_api_string_t *, const jerry_api_value_t *, void *user_data)
307+
static bool foreach_subset (const jerry_api_string_t *name, const jerry_api_value_t *value, void *user_data)
304308
{
305-
int *count_p = reinterpret_cast<int *>(user_data);
309+
UNUSED (name);
310+
UNUSED (value);
311+
int *count_p = (int *) (user_data);
312+
306313
if (*count_p == 3)
307314
{
308315
return false;

tests/unit/test-poolman.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
const uint32_t test_iters = 1024;
2929

3030
// Subiterations count
31-
const uint32_t test_max_sub_iters = 1024;
31+
#define TEST_MAX_SUB_ITERS 1024
3232

33-
uint8_t *ptrs[test_max_sub_iters];
34-
uint8_t data[test_max_sub_iters][MEM_POOL_CHUNK_SIZE];
33+
uint8_t *ptrs[TEST_MAX_SUB_ITERS];
34+
uint8_t data[TEST_MAX_SUB_ITERS][MEM_POOL_CHUNK_SIZE];
3535

3636
int
3737
main (int __attr_unused___ argc,
@@ -43,7 +43,7 @@ main (int __attr_unused___ argc,
4343

4444
for (uint32_t i = 0; i < test_iters; i++)
4545
{
46-
const size_t subiters = ((size_t) rand () % test_max_sub_iters) + 1;
46+
const size_t subiters = ((size_t) rand () % TEST_MAX_SUB_ITERS) + 1;
4747

4848
for (size_t j = 0; j < subiters; j++)
4949
{

0 commit comments

Comments
 (0)