aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_util.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-26 23:42:15 -0500
committerGerald Combs <gerald@wireshark.org>2014-02-27 21:23:09 +0000
commitc826191be02132251a9bd7cdaa44647b24bfce95 (patch)
tree61acb2aad3b0243f22abe3084564a34161891635 /epan/wslua/wslua_util.c
parentc875dc8597a6ff3a513cd6b8397626c331564f5e (diff)
Fix coverity warnings for all wslua files. (redux)
This fixes/addresses all the coverity warnings shown by the buildbots. (I hope) Change-Id: Ic2722df97c577d274e3cf3f0cbdca1902edde047 Reviewed-on: https://code.wireshark.org/review/423 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/wslua/wslua_util.c')
-rw-r--r--epan/wslua/wslua_util.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index b8205daa32..f36e488113 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -45,7 +45,7 @@ WSLUA_FUNCTION wslua_format_date(lua_State* LS) { /* Formats an absolute timesta
nstime_t then;
gchar* str;
- then.secs = (guint32)floor(timestamp);
+ then.secs = (guint32)(floor(timestamp));
then.nsecs = (guint32) ( (timestamp-(double)(then.secs))*1000000000);
str = abs_time_to_ep_str(&then, ABSOLUTE_TIME_LOCAL, TRUE);
lua_pushstring(LS,str);
@@ -59,7 +59,7 @@ WSLUA_FUNCTION wslua_format_time(lua_State* LS) { /* Formats a relative timestam
nstime_t then;
gchar* str;
- then.secs = (guint32)floor(timestamp);
+ then.secs = (guint32)(floor(timestamp));
then.nsecs = (guint32) ( (timestamp-(double)(then.secs))*1000000000);
str = rel_time_to_ep_str(&then);
lua_pushstring(LS,str);
@@ -186,7 +186,10 @@ WSLUA_FUNCTION wslua_loadfile(lua_State* L) {
filename = wslua_get_actual_filename(given_fname);
- if (!filename) WSLUA_ARG_ERROR(loadfile,FILENAME,"file does not exist");
+ if (!filename) {
+ WSLUA_ARG_ERROR(loadfile,FILENAME,"file does not exist");
+ return 0;
+ }
if (luaL_loadfile(L, filename) == 0) {
g_free(filename);
@@ -207,11 +210,17 @@ WSLUA_FUNCTION wslua_dofile(lua_State* L) {
char* filename;
int n;
- if (!given_fname) WSLUA_ARG_ERROR(dofile,FILENAME,"must be a string");
+ if (!given_fname) {
+ WSLUA_ARG_ERROR(dofile,FILENAME,"must be a string");
+ return 0;
+ }
filename = wslua_get_actual_filename(given_fname);
- if (!filename) WSLUA_ARG_ERROR(dofile,FILENAME,"file does not exist");
+ if (!filename) {
+ WSLUA_ARG_ERROR(dofile,FILENAME,"file does not exist");
+ return 0;
+ }
n = lua_gettop(L);
if (luaL_loadfile(L, filename) != 0) lua_error(L);
@@ -262,14 +271,21 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
Dir dir;
char* dirname_clean;
- if (!dirname) WSLUA_ARG_ERROR(Dir_open,PATHNAME,"must be a string");
+ if (!dirname) {
+ WSLUA_ARG_ERROR(Dir_open,PATHNAME,"must be a string");
+ return 0;
+ }
dirname_clean = wslua_get_actual_filename(dirname);
- if (!dirname_clean) WSLUA_ARG_ERROR(Dir_open,PATHNAME,"directory does not exist");
+ if (!dirname_clean) {
+ WSLUA_ARG_ERROR(Dir_open,PATHNAME,"directory does not exist");
+ return 0;
+ }
if (!test_for_directory(dirname_clean)) {
g_free(dirname_clean);
WSLUA_ARG_ERROR(Dir_open,PATHNAME, "must be a directory");
+ return 0;
}
dir = (Dir)g_malloc(sizeof(struct _wslua_dir));
@@ -284,6 +300,7 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
g_free(dir);
WSLUA_ARG_ERROR(Dir_open,PATHNAME,"could not open directory");
+ return 0;
}
pushDir(L,dir);