AP_Scripting: Add a return around luaL_error

This is the normal method of calling luaL_error which longjmp's away,
and it helps the static analysis tools realize that anything afterwards
will not be reached
This commit is contained in:
Michael du Breuil 2020-03-27 19:45:43 -07:00 committed by Andrew Tridgell
parent e7fdf8fad1
commit 6753e99604
2 changed files with 6 additions and 6 deletions

View File

@ -1330,7 +1330,7 @@ void emit_userdata_method(const struct userdata *data, const struct method *meth
// extract the userdata, it was a pointer, so we need to grab it // extract the userdata, it was a pointer, so we need to grab it
fprintf(source, " %s * ud = *check_%s(L, 1);\n", data->name, data->sanatized_name); fprintf(source, " %s * ud = *check_%s(L, 1);\n", data->name, data->sanatized_name);
fprintf(source, " if (ud == NULL) {\n"); fprintf(source, " if (ud == NULL) {\n");
fprintf(source, " luaL_error(L, \"Internal error, null pointer\");\n"); fprintf(source, " return luaL_error(L, \"Internal error, null pointer\");\n");
fprintf(source, " }\n"); fprintf(source, " }\n");
break; break;
} }

View File

@ -2519,7 +2519,7 @@ static int AP_HAL__UARTDriver_set_flow_control(lua_State *L) {
binding_argcheck(L, 2); binding_argcheck(L, 2);
AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1); AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1);
if (ud == NULL) { if (ud == NULL) {
luaL_error(L, "Internal error, null pointer"); return luaL_error(L, "Internal error, null pointer");
} }
const lua_Integer raw_data_2 = luaL_checkinteger(L, 2); const lua_Integer raw_data_2 = luaL_checkinteger(L, 2);
luaL_argcheck(L, ((raw_data_2 >= static_cast<int32_t>(AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE)) && (raw_data_2 <= static_cast<int32_t>(AP_HAL::UARTDriver::FLOW_CONTROL_AUTO))), 2, "argument out of range"); luaL_argcheck(L, ((raw_data_2 >= static_cast<int32_t>(AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE)) && (raw_data_2 <= static_cast<int32_t>(AP_HAL::UARTDriver::FLOW_CONTROL_AUTO))), 2, "argument out of range");
@ -2534,7 +2534,7 @@ static int AP_HAL__UARTDriver_available(lua_State *L) {
binding_argcheck(L, 1); binding_argcheck(L, 1);
AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1); AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1);
if (ud == NULL) { if (ud == NULL) {
luaL_error(L, "Internal error, null pointer"); return luaL_error(L, "Internal error, null pointer");
} }
const uint32_t data = ud->available(); const uint32_t data = ud->available();
@ -2547,7 +2547,7 @@ static int AP_HAL__UARTDriver_write(lua_State *L) {
binding_argcheck(L, 2); binding_argcheck(L, 2);
AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1); AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1);
if (ud == NULL) { if (ud == NULL) {
luaL_error(L, "Internal error, null pointer"); return luaL_error(L, "Internal error, null pointer");
} }
const lua_Integer raw_data_2 = luaL_checkinteger(L, 2); const lua_Integer raw_data_2 = luaL_checkinteger(L, 2);
luaL_argcheck(L, ((raw_data_2 >= MAX(0, 0)) && (raw_data_2 <= MIN(UINT8_MAX, UINT8_MAX))), 2, "argument out of range"); luaL_argcheck(L, ((raw_data_2 >= MAX(0, 0)) && (raw_data_2 <= MIN(UINT8_MAX, UINT8_MAX))), 2, "argument out of range");
@ -2564,7 +2564,7 @@ static int AP_HAL__UARTDriver_read(lua_State *L) {
binding_argcheck(L, 1); binding_argcheck(L, 1);
AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1); AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1);
if (ud == NULL) { if (ud == NULL) {
luaL_error(L, "Internal error, null pointer"); return luaL_error(L, "Internal error, null pointer");
} }
const int16_t data = ud->read(); const int16_t data = ud->read();
@ -2576,7 +2576,7 @@ static int AP_HAL__UARTDriver_begin(lua_State *L) {
binding_argcheck(L, 2); binding_argcheck(L, 2);
AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1); AP_HAL::UARTDriver * ud = *check_AP_HAL__UARTDriver(L, 1);
if (ud == NULL) { if (ud == NULL) {
luaL_error(L, "Internal error, null pointer"); return luaL_error(L, "Internal error, null pointer");
} }
const uint32_t raw_data_2 = coerce_to_uint32_t(L, 2); const uint32_t raw_data_2 = coerce_to_uint32_t(L, 2);
luaL_argcheck(L, ((raw_data_2 >= MAX(1U, 0U)) && (raw_data_2 <= MIN(UINT32_MAX, UINT32_MAX))), 2, "argument out of range"); luaL_argcheck(L, ((raw_data_2 >= MAX(1U, 0U)) && (raw_data_2 <= MIN(UINT32_MAX, UINT32_MAX))), 2, "argument out of range");