Skip to content

Commit 282831e

Browse files
authored
Fix some compilation warnings and add esp-idf platform for experiment (#454)
And fix some code indent issues.
1 parent 7d8b79a commit 282831e

File tree

35 files changed

+342
-363
lines changed

35 files changed

+342
-363
lines changed

core/app-framework/app-native-shared/attr_container.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ attr_container_get_attr_begin(const attr_container_t *attr_cont,
106106

107107
/* tag content */
108108
p += str_len;
109-
if (p - attr_cont->buf >= total_length)
109+
if ((uint32_t)(p - attr_cont->buf) >= total_length)
110110
return NULL;
111111

112112
/* attribute num */
113113
attr_num = get_uint16(p);
114114
p += sizeof(uint16_t);
115-
if (p - attr_cont->buf >= total_length)
115+
if ((uint32_t)(p - attr_cont->buf) >= total_length)
116116
return NULL;
117117

118118
if (p_total_length)
@@ -174,7 +174,8 @@ attr_container_find_attr(const attr_container_t *attr_cont, const char *key)
174174

175175
if (str_len == strlen(key) + 1
176176
&& memcmp(p + sizeof(uint16_t), key, str_len) == 0) {
177-
if (p + sizeof(uint16_t) + str_len - attr_cont->buf >= total_length)
177+
if ((uint32_t)(p + sizeof(uint16_t) + str_len
178+
- attr_cont->buf) >= total_length)
178179
return NULL;
179180
return p;
180181
}
@@ -337,7 +338,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
337338
}
338339

339340
/* Set the attr buf */
340-
str_len = strlen(key) + 1;
341+
str_len = (uint16_t)(strlen(key) + 1);
341342
set_uint16(p, str_len);
342343
p += sizeof(uint16_t);
343344
bh_memcpy_s(p, str_len, key, str_len);
@@ -366,7 +367,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
366367
return true;
367368
}
368369

369-
if (p1 - p + msg_end - attr_end >= attr_len) {
370+
if ((uint32_t)(p1 - p + msg_end - attr_end) >= attr_len) {
370371
memmove(p, p1, attr_end - p1);
371372
bh_memcpy_s(p + (attr_end - p1), attr_len, attr_buf, attr_len);
372373
attr_container_free(attr_buf);
@@ -399,7 +400,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
399400
return true;
400401
} else {
401402
/* key not found */
402-
if (msg_end - attr_end >= attr_len) {
403+
if ((uint32_t)(msg_end - attr_end) >= attr_len) {
403404
bh_memcpy_s(attr_end, msg_end - attr_end, attr_buf, attr_len);
404405
attr_container_inc_attr_num(attr_cont);
405406
attr_container_free(attr_buf);
@@ -564,6 +565,9 @@ attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
564565
bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \
565566
break; \
566567
} \
568+
default: \
569+
bh_assert(0); \
570+
break; \
567571
} \
568572
return val.var_name; \
569573
} while (0)
@@ -819,6 +823,9 @@ void attr_container_dump(const attr_container_t *attr_cont)
819823
get_uint32(p));
820824
p += sizeof(uint32_t) + get_uint32(p);
821825
break;
826+
default:
827+
bh_assert(0);
828+
break;
822829
}
823830
}
824831

core/app-framework/base/native/timer_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "bh_platform.h"
77
#include "app_manager_export.h"
8-
#include "module_wasm_app.h"
8+
#include "../app-manager/module_wasm_app.h"
99
#include "timer_native_api.h"
1010

1111
static bool timer_thread_run = true;

core/app-mgr/app-manager/app_manager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,5 @@ module_interface *g_module_interfaces[Module_Max] = {
396396
#else
397397
NULL
398398
#endif
399-
};
399+
};
400+

core/app-mgr/app-manager/app_manager_host.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,14 @@ int aee_host_msg_callback(void *msg, uint16_t msg_len)
209209
memset(&request, 0, sizeof(request));
210210

211211
if (!unpack_request(recv_ctx.message.payload,
212-
recv_ctx.message.payload_size, &request))
212+
recv_ctx.message.payload_size, &request))
213213
continue;
214214

215215
request.sender = ID_HOST;
216216

217217
am_dispatch_request(&request);
218-
} else {
218+
}
219+
else {
219220
app_manager_printf("unexpected host msg type: %d\n", msg_type);
220221
}
221222

core/app-mgr/app-manager/message.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ bool send_error_response_to_host(int mid, int status, const char *msg)
7373
}
7474
}
7575

76-
set_response(response, status,
77-
FMT_ATTR_CONTAINER, (const char *)payload, payload_len);
76+
set_response(response, status, FMT_ATTR_CONTAINER,
77+
(const char *)payload, payload_len);
7878
response->mid = mid;
7979

8080
send_response_to_host(response);

core/app-mgr/app-mgr-shared/app_manager_export.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ typedef struct host_interface {
173173
* @return true if success, false otherwise
174174
*/
175175
bool
176-
app_manager_host_init(host_interface *interface);
176+
app_manager_host_init(host_interface *intf);
177177

178178
/* Startup app manager */
179179
void
180-
app_manager_startup(host_interface *interface);
180+
app_manager_startup(host_interface *intf);
181181

182182
/* Get queue of current applet */
183183
void *

core/config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226

227227
/* Default/min/max stack size of each app thread */
228228
#if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \
229-
&& !defined(BH_PLATFORM_FREERTOS)
229+
&& !defined(BH_PLATFORM_ESP_IDF) && !defined(BH_PLATFORM_OPENRTOS)
230230
#define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024)
231231
#define APP_THREAD_STACK_SIZE_MIN (24 * 1024)
232232
#else
@@ -259,5 +259,9 @@
259259
#define WASM_ENABLE_TAIL_CALL 0
260260
#endif
261261

262+
#ifndef WASM_ENABLE_CUSTOM_NAME_SECTION
263+
#define WASM_ENABLE_CUSTOM_NAME_SECTION 0
264+
#endif
265+
262266
#endif /* end of _CONFIG_H_ */
263267

core/iwasm/aot/aot_loader.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,10 @@ load_from_sections(AOTModule *module, AOTSection *sections,
16631663
error_buf, error_buf_size))
16641664
return false;
16651665
break;
1666+
default:
1667+
set_error_buf(error_buf, error_buf_size,
1668+
"invalid aot section type");
1669+
return false;
16661670
}
16671671

16681672
section = section->next;

core/iwasm/aot/aot_reloc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ typedef struct {
3636
REG_SYM(aot_call_indirect), \
3737
REG_SYM(wasm_runtime_enlarge_memory), \
3838
REG_SYM(wasm_runtime_set_exception), \
39-
REG_SYM(memset), \
40-
REG_SYM(memmove), \
39+
REG_SYM(aot_memset), \
40+
REG_SYM(aot_memmove), \
4141
REG_BULK_MEMORY_SYM() \
4242
REG_ATOMIC_WAIT_SYM()
4343
#else /* else of (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG) */
@@ -47,8 +47,8 @@ typedef struct {
4747
REG_SYM(aot_call_indirect), \
4848
REG_SYM(wasm_runtime_enlarge_memory), \
4949
REG_SYM(wasm_runtime_set_exception), \
50-
REG_SYM(memset), \
51-
REG_SYM(memmove), \
50+
REG_SYM(aot_memset), \
51+
REG_SYM(aot_memmove), \
5252
REG_SYM(fmin), \
5353
REG_SYM(fminf), \
5454
REG_SYM(fmax), \

core/iwasm/aot/aot_runtime.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,18 @@ aot_call_indirect(WASMExecEnv *exec_env,
19071907
}
19081908
}
19091909

1910+
void *
1911+
aot_memmove(void *dest, const void *src, size_t n)
1912+
{
1913+
return memmove(dest, src, n);
1914+
}
1915+
1916+
void *
1917+
aot_memset(void *s, int c, size_t n)
1918+
{
1919+
return memset(s, c, n);
1920+
}
1921+
19101922
#if WASM_ENABLE_BULK_MEMORY != 0
19111923
bool
19121924
aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index,

0 commit comments

Comments
 (0)