Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d0e6ab38
Commit
d0e6ab38
authored
Aug 11, 2015
by
devsaurus
Browse files
add write error detection in node_compile()
parent
4a69d242
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/node.c
View file @
d0e6ab38
...
@@ -382,7 +382,10 @@ static int node_compile( lua_State* L )
...
@@ -382,7 +382,10 @@ static int node_compile( lua_State* L )
int
result
=
luaU_dump
(
L
,
f
,
writer
,
&
file_fd
,
stripping
);
int
result
=
luaU_dump
(
L
,
f
,
writer
,
&
file_fd
,
stripping
);
lua_unlock
(
L
);
lua_unlock
(
L
);
fs_flush
(
file_fd
);
if
(
fs_flush
(
file_fd
)
<
0
)
{
// result codes aren't propagated by flash_fs.h
// overwrite Lua error, like writer() does in case of a file io error
result
=
1
;
}
fs_close
(
file_fd
);
fs_close
(
file_fd
);
file_fd
=
FS_OPEN_OK
-
1
;
file_fd
=
FS_OPEN_OK
-
1
;
...
@@ -392,6 +395,9 @@ static int node_compile( lua_State* L )
...
@@ -392,6 +395,9 @@ static int node_compile( lua_State* L )
if
(
result
==
LUA_ERR_CC_NOTINTEGER
)
{
if
(
result
==
LUA_ERR_CC_NOTINTEGER
)
{
return
luaL_error
(
L
,
"target lua_Number is integral but fractional value found"
);
return
luaL_error
(
L
,
"target lua_Number is integral but fractional value found"
);
}
}
if
(
result
==
1
)
{
// result status generated by writer() or fs_flush() fail
return
luaL_error
(
L
,
"writing to file failed"
);
}
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment