From d1a264a39af9e9d29090a8d294cb34d632eff110 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 2 May 2015 14:41:56 +0200 Subject: util.pposix: Return error from ftruncate if that fails too (but what would we do here?) --- util-src/pposix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'util-src') diff --git a/util-src/pposix.c b/util-src/pposix.c index d797f032..5288b08c 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -750,7 +750,10 @@ int lc_fallocate(lua_State* L) { lua_pushstring(L, strerror(ret)); /* posix_fallocate() can leave a bunch of NULs at the end, so we cut that * this assumes that offset == length of the file */ - ftruncate(fileno(f), offset); + if(ftruncate(fileno(f), offset) != 0) { + lua_pushstring(L, strerror(errno)); + return 3; + } return 2; } } -- cgit v1.2.3 From 8f40f1f4e63216c60f2f61610a4386376c46c476 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 2 May 2015 14:52:51 +0200 Subject: util.encodings: Move declarations to top of function [pedantic] --- util-src/encodings.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'util-src') diff --git a/util-src/encodings.c b/util-src/encodings.c index 2eaad2c8..c00b2267 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -476,14 +476,15 @@ static int Lidna_to_unicode(lua_State* L) { /** idna.to_unicode(s) */ static int Lidna_to_ascii(lua_State* L) { /** idna.to_ascii(s) */ size_t len; const char* s = check_utf8(L, 1, &len); + char* output = NULL; + int ret; if(s == NULL || len != strlen(s)) { lua_pushnil(L); return 1; /* TODO return error message */ } - char* output = NULL; - int ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES); + ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES); if(ret == IDNA_SUCCESS) { lua_pushstring(L, output); -- cgit v1.2.3