wslua: Avoid possible misuse of comma operator warning

Change-Id: I441359741332aa49fb91ded438cf2ec3d70b5e0f
Reviewed-on: https://code.wireshark.org/review/23560
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Stig Bjørlykke 2017-09-15 20:35:28 +02:00 committed by Michael Mann
parent 3f8384d779
commit e84c2e03e4
3 changed files with 24 additions and 12 deletions

View File

@ -475,8 +475,10 @@ static int finish_generic_find (lua_State *L, TUserdata *ud, TArgExec *argE,
}
return (method == METHOD_FIND) ? ALG_NSUB(ud) + 2 : ALG_NSUB(ud);
}
else if (ALG_NOMATCH (res))
return lua_pushnil (L), 1;
else if (ALG_NOMATCH (res)) {
lua_pushnil (L);
return 1;
}
else
return generate_error (L, ud, res);
}
@ -489,8 +491,10 @@ static int generic_find_func (lua_State *L, int method) {
int res;
checkarg_find_func (L, &argC, &argE);
if (argE.startoffset > (int)argE.textlen)
return lua_pushnil (L), 1;
if (argE.startoffset > (int)argE.textlen) {
lua_pushnil (L);
return 1;
}
if (argC.ud) {
ud = (TUserdata*) argC.ud;
@ -700,8 +704,10 @@ static int generic_find_method (lua_State *L, int method) {
int res;
checkarg_find_method (L, &argE, &ud);
if (argE.startoffset > (int)argE.textlen)
return lua_pushnil(L), 1;
if (argE.startoffset > (int)argE.textlen) {
lua_pushnil(L);
return 1;
}
res = findmatch_exec (ud, &argE);
if (ALG_ISMATCH (res)) {
@ -722,8 +728,10 @@ static int generic_find_method (lua_State *L, int method) {
}
return 0;
}
else if (ALG_NOMATCH (res))
return lua_pushnil (L), 1;
else if (ALG_NOMATCH (res)) {
lua_pushnil (L);
return 1;
}
else
return generate_error(L, ud, res);
}

View File

@ -310,8 +310,10 @@ static int Gregex_dfa_exec (lua_State *L)
}
else {
minfo_free (ud);
if (ALG_NOMATCH (res))
return lua_pushnil (L), 1;
if (ALG_NOMATCH (res)) {
lua_pushnil (L);
return 1;
}
else
return generate_error (L, ud, 0);
}

View File

@ -535,7 +535,8 @@ void wslua_register_classinstance_meta(lua_State *L, const wslua_class *cls_def)
lua_pushstring(L, cls_def->name); /* upval 1: class name */
wslua_push_attributes(L, cls_def->attrs, TRUE, -2); /* upval 2: getters table */
#ifdef WSLUA_WITH_INTROSPECTION
lua_pushvalue(L, -1), lua_rawsetfield(L, -5, "__getters"); /* set (transition) property on mt, remove later! */
lua_pushvalue(L, -1);
lua_rawsetfield(L, -5, "__getters"); /* set (transition) property on mt, remove later! */
#endif
lua_rawgetfield(L, -4, "__index"); /* upval 3: fallback __index method from metatable */
lua_pushvalue(L, -4); /* upval 4: class methods table */
@ -546,7 +547,8 @@ void wslua_register_classinstance_meta(lua_State *L, const wslua_class *cls_def)
lua_pushstring(L, cls_def->name); /* upval 1: class name */
wslua_push_attributes(L, cls_def->attrs, FALSE, -2); /* upval 2: setters table */
#ifdef WSLUA_WITH_INTROSPECTION
lua_pushvalue(L, -1), lua_rawsetfield(L, -5, "__setters"); /* set (transition) property on mt, remove later! */
lua_pushvalue(L, -1);
lua_rawsetfield(L, -5, "__setters"); /* set (transition) property on mt, remove later! */
#endif
lua_rawgetfield(L, -4, "__newindex"); /* upval 3: fallback __newindex method from metatable */
lua_pushcclosure(L, wslua_instancemeta_newindex, 3);