mirror of
https://github.com/SuperBFG7/ympd
synced 2025-07-03 18:43:01 +00:00
Fix: optimize compile options
Fix: fix compiler warnings
This commit is contained in:
parent
597268aca6
commit
68a471c0df
@ -30,7 +30,7 @@ include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${LIBMPDCLIENT_I
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -pedantic -D MG_ENABLE_SSL -D MG_ENABLE_THREADS -D MG_ENABLE_IPV6 -D MG_DISABLE_MQTT -D MG_DISABLE_MQTT_BROKER -D MG_DISABLE_DNS_SERVER -D MG_DISABLE_COAP -D MG_DISABLE_HTTP_CGI -D MG_DISABLE_HTTP_SSI -D MG_DISABLE_HTTP_WEBDAV")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -O2 -Wall -Wextra -pedantic -Wformat=2 -Wno-unused-parameter -Wshadow -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -Wnested-externs -Wmissing-include-dirs -D MG_ENABLE_SSL -D MG_ENABLE_THREADS -D MG_ENABLE_IPV6 -D MG_DISABLE_MQTT -D MG_DISABLE_MQTT_BROKER -D MG_DISABLE_DNS_SERVER -D MG_DISABLE_COAP -D MG_DISABLE_HTTP_CGI -D MG_DISABLE_HTTP_SSI -D MG_DISABLE_HTTP_WEBDAV")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=bounds-strict -fsanitize=alignment -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool -fsanitize=enum -fsanitize=vptr -static-libasan")
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
@ -81,7 +81,7 @@ bool state_file_write(t_config *config, const char *name, const char *value) {
|
||||
}
|
||||
|
||||
|
||||
bool testdir(char *name, char *dirname) {
|
||||
bool testdir(const char *name, const char *dirname) {
|
||||
DIR* dir = opendir(dirname);
|
||||
if (dir) {
|
||||
closedir(dir);
|
||||
|
@ -187,7 +187,7 @@ typedef struct t_config {
|
||||
} t_config;
|
||||
|
||||
//global functions
|
||||
bool testdir(char *name, char *dirname);
|
||||
bool testdir(const char *name, const char *dirname);
|
||||
int randrange(int n);
|
||||
bool validate_string(const char *data);
|
||||
int copy_string(char * const dest, char const * const src, size_t const dst_len, size_t const src_len);
|
||||
|
@ -55,13 +55,13 @@
|
||||
} while (0)
|
||||
|
||||
#define PUT_SONG_TAGS() do { \
|
||||
struct node *current = mpd_state->mympd_tags.list; \
|
||||
struct node *current_tag = mpd_state->mympd_tags.list; \
|
||||
int tagnr = 0; \
|
||||
while (current != NULL) { \
|
||||
while (current_tag != NULL) { \
|
||||
if (tagnr ++) \
|
||||
len += json_printf(&out, ","); \
|
||||
len += json_printf(&out, "%Q: %Q", current->data, mpd_client_get_tag(song, mpd_tag_name_parse(current->data))); \
|
||||
current = current->next; \
|
||||
len += json_printf(&out, "%Q: %Q", current_tag->data, mpd_client_get_tag(song, mpd_tag_name_parse(current_tag->data))); \
|
||||
current_tag = current_tag->next; \
|
||||
} \
|
||||
len += json_printf(&out, ", Duration: %d, uri: %Q", mpd_song_get_duration(song), mpd_song_get_uri(song)); \
|
||||
} while (0)
|
||||
@ -1402,7 +1402,7 @@ static char *mpd_client_get_tag(struct mpd_song const *song, const enum mpd_tag_
|
||||
else if (tag == MPD_TAG_ALBUM_ARTIST)
|
||||
str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
|
||||
else
|
||||
str = "-";
|
||||
str = strdup("-");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@ -1623,7 +1623,7 @@ static int mpd_client_put_volume(t_mpd_state *mpd_state, char *buffer) {
|
||||
}
|
||||
|
||||
static int mpd_client_put_settings(t_mpd_state *mpd_state, char *buffer) {
|
||||
char *replaygain = "";
|
||||
char *replaygain = strdup("");
|
||||
size_t len;
|
||||
int nr = 0;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
@ -168,7 +168,6 @@ static void mympd_api(t_config *config, t_mympd_state *mympd_state, t_work_reque
|
||||
else {
|
||||
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"error\", \"data\": \"Unknown table %s\"}", p_charbuf1);
|
||||
printf("MYMPD_API_COLS_SAVE: Unknown table %s\n", p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
}
|
||||
if (len == 0) {
|
||||
if (state_file_write(config, p_charbuf1, cols))
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <pthread.h>
|
||||
#include "tiny_queue.h"
|
||||
|
||||
tiny_queue_t* tiny_queue_create() {
|
||||
tiny_queue_t *tiny_queue_create(void) {
|
||||
struct tiny_queue_t* queue = (struct tiny_queue_t*)malloc(sizeof(struct tiny_queue_t));
|
||||
queue->head = NULL;
|
||||
queue->tail = NULL;
|
||||
|
@ -33,7 +33,7 @@ typedef struct tiny_queue_t {
|
||||
pthread_cond_t wakeup;
|
||||
} tiny_queue_t;
|
||||
|
||||
tiny_queue_t* tiny_queue_create();
|
||||
tiny_queue_t *tiny_queue_create(void);
|
||||
void tiny_queue_free(tiny_queue_t *queue);
|
||||
void tiny_queue_push(struct tiny_queue_t *queue, void *data);
|
||||
void *tiny_queue_shift(struct tiny_queue_t *queue);
|
||||
|
@ -196,7 +196,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
bool rc = handle_api(user_data->conn_id, hm->body.p, hm->body.len);
|
||||
if (rc == false) {
|
||||
printf("ERROR: Invalid API request.\n");
|
||||
char *response = "{\"type\": \"error\", \"data\": \"Invalid API request\"}";
|
||||
const char *response = "{\"type\": \"error\", \"data\": \"Invalid API request\"}";
|
||||
mg_send_head(nc, 200, strlen(response), "Content-Type: application/json");
|
||||
mg_printf(nc, "%s", response);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user