diff --git a/cmake/BuildLibEIO.cmake b/cmake/BuildLibEIO.cmake
index 48e7582e5a994bcb55232ace7f1d2a573450b520..64d401b29c5aaaa52120c7a8dca9bf6b267b1b71 100644
--- a/cmake/BuildLibEIO.cmake
+++ b/cmake/BuildLibEIO.cmake
@@ -3,9 +3,22 @@
 macro(libeio_build)
     set(eio_compile_flags)
 
-    set(eio_compile_flags "${eio_compile_flags} -Wno-unused-result")
-    set(eio_compile_flags "${eio_compile_flags} -Wno-dangling-else")
-    set(eio_compile_flags "${eio_compile_flags} -Wno-unused-value")
+    set(eio_compile_flags "${eio_compile_flags} -Wno-unused")
+    if (CC_HAS_WNO_DANGLING_ELSE)
+        set(eio_compile_flags "${eio_compile_flags} -Wno-dangling-else")
+    endif()
+    if (CC_HAS_WNO_PARENTHESES)
+        set(eio_compile_flags "${eio_compile_flags} -Wno-parentheses")
+    endif()
+    if (CC_HAS_WNO_UNUSED_FUNCTION)
+        set(eio_compile_flags "${eio_compile_flags} -Wno-unused-function")
+    endif()
+    if (CC_HAS_WNO_UNUSED_VALUE)
+        set(eio_compile_flags "${eio_compile_flags} -Wno-unused-value")
+    endif()
+    if (CC_HAS_WNO_UNUSED_RESULT)
+        set(eio_compile_flags "${eio_compile_flags} -Wno-unused-result")
+    endif()
     set(eio_compile_flags "${eio_compile_flags} -DENABLE_BUNDLED_LIBEIO=1")
     set(eio_compile_flags "${eio_compile_flags} -DEIO_STACKSIZE=0")
     if (TARGET_OS_LINUX)
diff --git a/cmake/BuildLibYAML.cmake b/cmake/BuildLibYAML.cmake
index b6d6685d89c85aa910420b01ae0547671381b719..74ecc4c77ce9165989a76e0cc0491b5af3a5a8c8 100644
--- a/cmake/BuildLibYAML.cmake
+++ b/cmake/BuildLibYAML.cmake
@@ -11,6 +11,11 @@ macro(libyaml_build)
         ${PROJECT_SOURCE_DIR}/third_party/libyaml/writer.c)
 
     add_library(yaml STATIC ${yaml_src})
+    set(yaml_compile_flags -Wno-unused)
+    if (CC_HAS_WNO_PARENTHESES_EQUALITY)
+        set(yaml_compile_flags "${yaml_compile_flags} -Wno-parentheses-equality")
+    endif()
+    set_target_properties(yaml PROPERTIES COMPILE_FLAGS "${yaml_compile_flags}")
 
     set(LIBYAML_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/libyaml)
     set(LIBYAML_LIBRARIES yaml)
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index 17d5d7785ca9d8f1e5fa7bb947951658c3a06709..487fe3e1ac725181fa1815d05f8b7dccae1407fd 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -202,10 +202,13 @@ endif()
 check_c_compiler_flag("-Wno-unused-const-variable" CC_HAS_WNO_UNUSED_CONST_VARIABLE)
 check_c_compiler_flag("-Wno-unused-result" CC_HAS_WNO_UNUSED_RESULT)
 check_c_compiler_flag("-Wno-unused-value" CC_HAS_WNO_UNUSED_VALUE)
+check_c_compiler_flag("-Wno-unused-function" CC_HAS_WNO_UNUSED_FUNCTION)
 check_c_compiler_flag("-fno-strict-aliasing" CC_HAS_FNO_STRICT_ALIASING)
 check_c_compiler_flag("-Wno-comment" CC_HAS_WNO_COMMENT)
 check_c_compiler_flag("-Wno-parentheses" CC_HAS_WNO_PARENTHESES)
+check_c_compiler_flag("-Wno-parentheses-equality" CC_HAS_WNO_PARENTHESES_EQUALITY)
 check_c_compiler_flag("-Wno-undefined-inline" CC_HAS_WNO_UNDEFINED_INLINE)
+check_c_compiler_flag("-Wno-dangling-else" CC_HAS_WNO_DANGLING_ELSE)
 
 if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
     set(HAVE_BUILTIN_CTZ 1)
diff --git a/extra/bin2c.c b/extra/bin2c.c
index 9776d55224094a93bcb63a0186acb50ba017d13b..2722a9eea2b16abe8f266681cbed73c134be2310 100644
--- a/extra/bin2c.c
+++ b/extra/bin2c.c
@@ -14,7 +14,6 @@
 int main(int argc, char** argv) {
 	const char *prefix = "";
 	const char *suffix = "\n";
-	int no_quote = 0; /* if 1, do not prepend and append quotation marks (") */
 	FILE *in = stdin;
 	FILE *out = stdout;
 
diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c
index e0df6ad5763f72d97d7b1ad00ca06af76b32f9be..47038dde94a8bc87f47715fe10335433eddd4c2a 100644
--- a/third_party/lua-cjson/lua_cjson.c
+++ b/third_party/lua-cjson/lua_cjson.c
@@ -330,7 +330,7 @@ static void json_append_number(struct luaL_serializer *cfg, strbuf_t *json,
 static void json_append_object(lua_State *l, struct luaL_serializer *cfg,
                                int current_depth, strbuf_t *json)
 {
-    int comma, keytype;
+    int comma;
 
     /* Object */
     strbuf_append_char(json, '{');
@@ -344,8 +344,6 @@ static void json_append_object(lua_State *l, struct luaL_serializer *cfg,
         else
             comma = 1;
 
-        /* table, key, value */
-        keytype = lua_type(l, -2);
     struct luaL_field field;
     luaL_checkfield(l, cfg, -2, &field);
     if (field.type == MP_UINT) {
@@ -420,7 +418,6 @@ static void json_append_data(lua_State *l, struct luaL_serializer *cfg,
 static int json_encode(lua_State *l)
 {
     struct luaL_serializer *cfg = luaL_checkserializer(l);
-    strbuf_t local_encode_buf;
     char *json;
     int len;