Skip to content

Commit 0b5a49f

Browse files
committed
Warning fixes.
Passing argument 1 of ‘strncmp’ from incompatible pointer type. Assignments from incompatible pointer types. Passing argument or initialization discards ‘const’ qualifier from pointer target type. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent 25b0750 commit 0b5a49f

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
132132
/* FIXME: "We currently have to re-compile the bytecode, because
133133
* we can't copy it without knowing its length."
134134
*/
135-
re_compiled_code_t *new_bc_p = NULL;
135+
const re_compiled_code_t *new_bc_p = NULL;
136136
ecma_value_t bc_comp = re_compile_bytecode (&new_bc_p, pattern_string_p, flags);
137137
/* Should always succeed, since we're compiling from a source that has been compiled previously. */
138138
JERRY_ASSERT (ecma_is_value_empty (bc_comp));
@@ -201,7 +201,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
201201
ecma_property_t *bc_prop_p = ecma_get_internal_property (this_obj_p,
202202
ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE);
203203
/* Try to compile bytecode from new source. */
204-
re_compiled_code_t *new_bc_p = NULL;
204+
const re_compiled_code_t *new_bc_p = NULL;
205205
ECMA_TRY_CATCH (bc_dummy,
206206
re_compile_bytecode (&new_bc_p, pattern_string_p, flags),
207207
ret_value);

jerry-core/ecma/operations/ecma-regexp-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */
306306
bytecode_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE);
307307

308308
/* Compile bytecode. */
309-
re_compiled_code_t *bc_p = NULL;
309+
const re_compiled_code_t *bc_p = NULL;
310310
ECMA_TRY_CATCH (empty, re_compile_bytecode (&bc_p, pattern_p, flags), ret_value);
311311

312312
ECMA_SET_POINTER (bytecode_prop_p->v.internal_property.value, bc_p);

jerry-core/jerry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ snapshot_load_compiled_code (const uint8_t *snapshot_data_p, /**< snapshot data
21712171
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
21722172
{
21732173
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
2174-
re_compiled_code_t *re_bytecode_p = NULL;
2174+
const re_compiled_code_t *re_bytecode_p = NULL;
21752175

21762176
const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (uint16_t);
21772177

jerry-core/lit/lit-literal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ lit_find_literal_by_utf8_string (const lit_utf8_byte_t *str_p, /**< a string to
129129
continue;
130130
}
131131

132-
if (!strncmp (rec_p + 1, (const char *) str_p, str_size))
132+
if (!strncmp ((const char *) (rec_p + 1), (const char *) str_p, str_size))
133133
{
134134
return lit;
135135
}

jerry-core/mem/mem-heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void *mem_heap_alloc_block_internal (const size_t size)
260260
}
261261
else
262262
{
263-
JERRY_ASSERT (MEM_HEAP_GET_ADDR_FROM_OFFSET (mem_heap.first.next_offset)->size > MEM_ALIGNMENT);
263+
JERRY_ASSERT (data_space_p->size > MEM_ALIGNMENT);
264264
mem_heap_free_t *const remaining_p = MEM_HEAP_GET_ADDR_FROM_OFFSET (mem_heap.first.next_offset) + 1;
265265

266266
VALGRIND_DEFINED_SPACE (remaining_p, sizeof (mem_heap_free_t));

jerry-core/mem/mem-poolman.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
/**
3838
* Node for free chunk list
3939
*/
40-
typedef struct
40+
typedef struct mem_pools_chunk
4141
{
42-
struct mem_pools_chunk_t *next_p; /* pointer to next pool chunk */
42+
struct mem_pools_chunk *next_p; /* pointer to next pool chunk */
4343
#ifndef MEM_HEAP_PTR_64
4444
uint32_t dummy; /* dummy member for alignment */
4545
#endif

jerry-core/parser/js/js-lexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
18081808
context_p->literal_count++;
18091809

18101810
/* Compile the RegExp literal and store the RegExp bytecode pointer */
1811-
re_compiled_code_t *re_bytecode_p = NULL;
1811+
const re_compiled_code_t *re_bytecode_p = NULL;
18121812
ecma_value_t completion_value;
18131813

18141814
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p, length);

jerry-core/parser/regexp/re-compiler.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
*/
4242
static void
4343
re_append_char_class (void *re_ctx_p, /**< RegExp compiler context */
44-
ecma_char_t start, /**< character class range from */
45-
ecma_char_t end) /**< character class range to */
44+
uint32_t start, /**< character class range from */
45+
uint32_t end) /**< character class range to */
4646
{
4747
re_compiler_ctx_t *ctx_p = (re_compiler_ctx_t *) re_ctx_p;
48-
re_append_char (ctx_p->bytecode_ctx_p, start);
49-
re_append_char (ctx_p->bytecode_ctx_p, end);
48+
re_append_char (ctx_p->bytecode_ctx_p, (ecma_char_t) start);
49+
re_append_char (ctx_p->bytecode_ctx_p, (ecma_char_t) end);
5050
ctx_p->parser_ctx_p->num_of_classes++;
5151
} /* re_append_char_class */
5252

@@ -452,7 +452,7 @@ static const re_compiled_code_t *re_cache[RE_CACHE_SIZE];
452452
* @return compiled bytecode - if found
453453
* NULL - otherwise
454454
*/
455-
re_compiled_code_t *
455+
const re_compiled_code_t *
456456
re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
457457
uint16_t flags, /**< flags */
458458
uint32_t *idx) /**< [out] index */
@@ -461,7 +461,7 @@ re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
461461

462462
for (*idx = 0u; *idx < RE_CACHE_SIZE; (*idx)++)
463463
{
464-
re_compiled_code_t *cached_bytecode_p = re_cache[*idx];
464+
const re_compiled_code_t *cached_bytecode_p = re_cache[*idx];
465465

466466
if (cached_bytecode_p != NULL)
467467
{
@@ -495,13 +495,13 @@ re_cache_gc_run ()
495495
{
496496
for (uint32_t i = 0u; i < RE_CACHE_SIZE; i++)
497497
{
498-
re_compiled_code_t *cached_bytecode_p = re_cache[i];
498+
const re_compiled_code_t *cached_bytecode_p = re_cache[i];
499499

500500
if (cached_bytecode_p != NULL
501501
&& (cached_bytecode_p->flags >> ECMA_BYTECODE_REF_SHIFT) == 1)
502502
{ /* Only the cache has reference for the bytecode */
503503

504-
ecma_bytecode_deref (cached_bytecode_p);
504+
ecma_bytecode_deref ((ecma_compiled_code_t *) cached_bytecode_p);
505505
re_cache[i] = NULL;
506506
}
507507
}
@@ -516,7 +516,7 @@ re_cache_gc_run ()
516516
* Returned value must be freed with ecma_free_value
517517
*/
518518
ecma_value_t
519-
re_compile_bytecode (re_compiled_code_t **out_bytecode_p, /**< [out] pointer to bytecode */
519+
re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, /**< [out] pointer to bytecode */
520520
ecma_string_t *pattern_str_p, /**< pattern */
521521
uint16_t flags) /**< flags */
522522
{
@@ -604,7 +604,7 @@ re_compile_bytecode (re_compiled_code_t **out_bytecode_p, /**< [out] pointer to
604604

605605
if (cache_idx < RE_CACHE_SIZE)
606606
{
607-
ecma_bytecode_ref (*out_bytecode_p);
607+
ecma_bytecode_ref ((ecma_compiled_code_t *) *out_bytecode_p);
608608
re_cache[cache_idx] = *out_bytecode_p;
609609
}
610610
else

jerry-core/parser/regexp/re-compiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ typedef struct
4848
} re_compiler_ctx_t;
4949

5050
ecma_value_t
51-
re_compile_bytecode (re_compiled_code_t **, ecma_string_t *, uint16_t);
51+
re_compile_bytecode (const re_compiled_code_t **, ecma_string_t *, uint16_t);
5252

53-
re_compiled_code_t *
53+
const re_compiled_code_t *
5454
re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, uint16_t flags, uint32_t *idx);
5555

5656
void re_cache_gc_run ();

0 commit comments

Comments
 (0)