summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-14 14:14:22 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-14 14:14:22 +0000
commit3cdee6a406cb19b750754379e360140bcf068234 (patch)
tree3102366e4793da8642e97783a0f8b23cd68a2858 /src
parent803f55ece50bea9f0f8120dbcfe8068f689d3703 (diff)
downloadapk-tools-3cdee6a406cb19b750754379e360140bcf068234.tar.gz
apk-tools-3cdee6a406cb19b750754379e360140bcf068234.tar.bz2
apk-tools-3cdee6a406cb19b750754379e360140bcf068234.tar.xz
apk-tools-3cdee6a406cb19b750754379e360140bcf068234.zip
lua: typecast apk blob len
So we can build with -Werror
Diffstat (limited to 'src')
-rw-r--r--src/lua-apk.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lua-apk.c b/src/lua-apk.c
index efd7c3e..3c96b5c 100644
--- a/src/lua-apk.c
+++ b/src/lua-apk.c
@@ -11,12 +11,19 @@
int apk_verbosity;
unsigned int apk_flags;
+
+static apk_blob_t check_blob(lua_State *L, int index)
+{
+ apk_blob_t blob;
+ blob.ptr = (char *)luaL_checklstring(L, index, (size_t *)&blob.len);
+ return blob;
+}
+
/* version_validate(verstr) */
/* returns boolean */
static int Pversion_validate(lua_State *L)
{
- apk_blob_t ver;
- ver.ptr = (char *)luaL_checklstring(L, 1, &ver.len);
+ apk_blob_t ver = check_blob(L, 1);
lua_pushboolean(L, apk_version_validate(ver));
return 1;
}
@@ -27,8 +34,8 @@ static int Pversion_validate(lua_State *L)
static int Pversion_compare(lua_State *L)
{
apk_blob_t a, b;
- a.ptr = (char *)luaL_checklstring(L, 1, &a.len);
- b.ptr = (char *)luaL_checklstring(L, 2, &b.len);
+ a = check_blob(L, 1);
+ b = check_blob(L, 2);
lua_pushstring(L, apk_version_op_string(apk_version_compare_blob(a, b)));
return 1;
}
@@ -39,8 +46,8 @@ static int Pversion_compare(lua_State *L)
static int Pversion_is_less(lua_State *L)
{
apk_blob_t a, b;
- a.ptr = (char *)luaL_checklstring(L, 1, &a.len);
- b.ptr = (char *)luaL_checklstring(L, 2, &b.len);
+ a = check_blob(L, 1);
+ b = check_blob(L, 2);
lua_pushboolean(L, apk_version_compare_blob(a, b) == APK_VERSION_LESS);
return 1;
}