From 3c9f409311438fa0ffce8a05f05a13dd7105b5bb Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 1 May 2020 19:14:16 +0200
Subject: [PATCH] Compiles with clang

---
 src/config.c            |  2 +-
 src/database/playlist.c |  2 +-
 src/database/queue.c    |  2 +-
 src/net/downloader.c    | 21 +++++++++++----------
 src/net/listen.c        |  2 +-
 src/thread.c            |  8 ++++----
 6 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/config.c b/src/config.c
index 7f1b3ada..5f386521 100644
--- a/src/config.c
+++ b/src/config.c
@@ -15,7 +15,7 @@
 #include <sys/stat.h>
 #include <limits.h>
 
-static inline int
+int
 load_so(const char *const mod_path, const char *const mod_init, void *mod)
 {
     /* An init function takes two arguments: the module pointer and a void*
diff --git a/src/database/playlist.c b/src/database/playlist.c
index 086f580b..970fb0fd 100644
--- a/src/database/playlist.c
+++ b/src/database/playlist.c
@@ -99,7 +99,7 @@ database_plt_export(sqlite3 *db, const char *name)
         "( kara_id INTEGER PRIMARY KEY NOT NULL CHECK(kara_id > 0) );";
     char SQL_STMT[LKT_MAX_SQLITE_STATEMENT];
     int code, ret = false;
-    sqlite3_stmt *stmt;
+    sqlite3_stmt *stmt = NULL;
 
     if (is_sql_str_invalid(name)) {
         LOG_ERROR("The playlist name '%s' is invalid", name);
diff --git a/src/database/queue.c b/src/database/queue.c
index 341455f0..515d46b9 100644
--- a/src/database/queue.c
+++ b/src/database/queue.c
@@ -643,7 +643,7 @@ bool
 database_queue_seekid(sqlite3 *db, int id, int *out_pos)
 {
     static const char *SQL_STMT = "SELECT position FROM queue_ WHERE kara_id = ? LIMIT 1";
-    int ret;
+    int ret = 0;
     sqlite3_stmt *stmt;
 
     SQLITE_PREPARE(db, stmt, SQL_STMT, error);
diff --git a/src/net/downloader.c b/src/net/downloader.c
index 76a9307a..96abec51 100644
--- a/src/net/downloader.c
+++ b/src/net/downloader.c
@@ -28,7 +28,7 @@ struct file {
     int fd;
 };
 
-static size_t
+size_t
 write_mem__(char *data, size_t size, size_t nmem, void *user)
 {
     size_t realsize = size * nmem;
@@ -43,7 +43,7 @@ write_mem__(char *data, size_t size, size_t nmem, void *user)
     return realsize;
 }
 
-static size_t
+size_t
 write_disk__(char *data, size_t size, size_t nmem, void *user)
 {
     ssize_t realsize = size * nmem;
@@ -87,7 +87,8 @@ repo_free(struct lkt_repo *const repo)
     if (!curl_init)
         curl_global_cleanup();
 }
-static inline int
+
+int
 safe_json_get_string(struct json_object *jobj, const char *key, char *content, const size_t len)
 {
     const char *got;
@@ -100,7 +101,7 @@ safe_json_get_string(struct json_object *jobj, const char *key, char *content, c
     return 0;
 }
 
-static inline int
+int
 safe_json_get_int32(struct json_object *json, const char *key, int32_t *ret)
 {
     struct json_object *field;
@@ -111,7 +112,7 @@ safe_json_get_int32(struct json_object *json, const char *key, int32_t *ret)
     return 0;
 }
 
-static inline long
+long
 get_digit_number(long i)
 {
     int count = 0;
@@ -133,7 +134,7 @@ safe_json_get_long(struct json_object *json, const char *key, long *ret)
     return err;
 }
 
-static inline int
+int
 __json_sync(struct lkt_repo *const repo, struct json_object **json)
 {
     RETURN_UNLESS(json, "Invalid argument", 1);
@@ -245,7 +246,7 @@ err:
     return ret;
 }
 
-static inline int
+int
 __download_kara(const char *url, const char *path, int override)
 {
     CURL *curl_handle;
@@ -333,7 +334,7 @@ repo_download_id_sync(struct lkt_repo *const repo, const uint64_t id, const char
 
 /* Get all the kara, make them unavailable */
 
-static inline void
+void
 __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_object *json)
 {
     size_t i, len = json_object_array_length(json);
@@ -419,7 +420,7 @@ err:
     free(kara);
 }
 
-static inline void *
+void *
 __repo_get_all_id_async(void *arg)
 {
     struct json_object *json;
@@ -434,7 +435,7 @@ __repo_get_all_id_async(void *arg)
     return NULL;
 }
 
-inline int
+int
 repo_update(struct lkt_repo *const repo)
 {
     return mthread_create(NULL, ATTR_DETACHED, __repo_get_all_id_async, repo);
diff --git a/src/net/listen.c b/src/net/listen.c
index 690c1844..ce535c8e 100644
--- a/src/net/listen.c
+++ b/src/net/listen.c
@@ -147,7 +147,7 @@ command_list_begin(struct lkt_state *srv, size_t c, int list_ok)
 static int
 handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd)
 {
-    int err, continuation = 0;
+    int err = 0, continuation = 0;
 
     switch (*lkt_client_get_mask(srv, c)) {
     case MPD_IDLE_NONE:
diff --git a/src/thread.c b/src/thread.c
index e4e3f107..8df3d086 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -15,7 +15,7 @@ struct __args {
     struct poller_thread_arg *arg;
 };
 
-static void *
+void *
 __start(void *args__)
 {
     struct __args *args = (struct __args *) args__;
@@ -92,7 +92,7 @@ poller_join(struct poller_thread *th, void **ret)
     return sta;
 }
 
-static inline int
+int
 th_append(unsigned int *len, unsigned int *size, void ***cells,
           pthread_mutex_t *lock, void *ptr)
 {
@@ -121,7 +121,7 @@ end:
     return ret;
 }
 
-static inline int
+int
 th_pop(unsigned int *len, void **cells, pthread_mutex_t *lock, void **ptr)
 {
     int ret = 1;
@@ -139,7 +139,7 @@ end:
     return ret;
 }
 
-static inline int
+int
 th_head(unsigned int len, void **cells, pthread_mutex_t *lock, void **ptr)
 {
     int ret = 1;
-- 
GitLab