Skip to content

Commit

Permalink
Refactor SConscript and add file checks in iwasm.c (#3945)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhkag authored Dec 6, 2024
1 parent aabe830 commit c32a6ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
11 changes: 4 additions & 7 deletions core/iwasm/common/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ cwd = GetCurrentDir()

src = Glob('*.c')

if rtconfig.ARCH == 'arm':
if re.match('^cortex-m.*', rtconfig.CPU):
src += ['arch/invokeNative_thumb.s']
elif re.match('^cortex-a.*', rtconfig.CPU):
src += ['arch/invokeNative_arm.s']
elif rtconfig.ARCH == 'ia32':
src += ['arch/invokeNative_ia32.s']
if rtconfig.ARCH == 'arm' and re.match('^cortex-m.*', rtconfig.CPU):
src += ['arch/invokeNative_thumb.s']
else:
src.append(f"arch/invokeNative_{rtconfig.ARCH}.s")

CPPPATH = [cwd, cwd + '/../include']

Expand Down
15 changes: 15 additions & 0 deletions product-mini/platforms/rt-thread/iwasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ my_read_file_to_buffer(char *filename, rt_uint32_t *size)
{
struct stat f_stat;

if (!filename || !size) {
rt_set_errno(-EINVAL);
return RT_NULL;
}

if (stat(filename, &f_stat) != 0) {
rt_set_errno(errno);
return RT_NULL;
}

if (f_stat.st_size <= 0) {
rt_set_errno(-EINVAL);
return RT_NULL;
}

rt_uint8_t *buff = rt_malloc(f_stat.st_size);
*size = 0;
if (!buff) {
Expand Down

0 comments on commit c32a6ce

Please sign in to comment.