summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-07-12 21:36:35 +0200
committerJoe <bousset.rudy@gmail.com>2022-07-12 21:36:35 +0200
commitdda48159a1b96b4003c1bc742b4dcd59d1efc61f (patch)
tree6526860ae15155c822021ec31cd961b049327891
parentWIP (diff)
downloadmpdview-dda48159a1b96b4003c1bc742b4dcd59d1efc61f.tar.gz
mpdview-dda48159a1b96b4003c1bc742b4dcd59d1efc61f.tar.bz2
mpdview-dda48159a1b96b4003c1bc742b4dcd59d1efc61f.tar.xz
mpdview-dda48159a1b96b4003c1bc742b4dcd59d1efc61f.tar.zst
mpdview-dda48159a1b96b4003c1bc742b4dcd59d1efc61f.zip
Update
-rw-r--r--Makefile13
-rw-r--r--src/c_mpdview.c21
2 files changed, 18 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 7dbdb7c..50999d1 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
# ========================
#
# mpdview: Makefile
-# Sun, 03 Jul 2022 15:15:01 +0200
+# Tue, 12 Jul 2022 20:25:26 +0200
# Joe
#
# BSD Makefile
@@ -20,7 +20,6 @@ default: all
SRCS_DIR := src
MAN_DIR := man
-# OBJS_DIR := obj
PREFIX ?= /usr/local
DESTDIR :=
MAKEOBJDIR := ./
@@ -47,7 +46,11 @@ CFLAGS += -Werror
CFLAGS += -pedantic
CFLAGS += -isystem/usr/local/include
CFLAGS += -glldb
-# CFLAGS += -march=native -O2 -pipe
+CFLAGS += -O0
+# CFLAGS += -march=ivybridge
+# CFLAGS += -O3
+CFLAGS += -pipe
+# CFLAGS += -fsanitize=address
LDFLAGS := -L/usr/local/lib
LDFLAGS += -lmpdclient
@@ -68,7 +71,7 @@ INSTALL := install
${NAME}: ${OBJS}
${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC} ${LDFLAGS}
-all: ${OBJS_DIR} ${NAME}
+all: ${OBJS} ${NAME}
clean:
${RM} ${OBJS} ${NAME} vgcore*
@@ -85,7 +88,7 @@ uninstall:
${RM} ${PREFIX}/man/man1/${NAME}.1.gz
${RM} ${PREFIX}/bin/${NAME}
-.PHONY: all clean install
+.PHONY: all asan clean install
# Files prefixes index
# --------------------
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 26af420..46e11ed 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -39,13 +39,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* mpdview: src/c_mpdview.c
- * Sun, 03 Jul 2022 16:06:29 +0200
+ * Tue, 12 Jul 2022 21:36:26 +0200
* Joe
*
* This is the entrypoint of the program.
*/
#include <sys/param.h>
+#include <sys/syslimits.h>
#include <stdlib.h>
#include <stdio.h>
@@ -70,6 +71,9 @@ c_create_view(void)
struct mpdview_s* view;
view = (struct mpdview_s*)malloc(sizeof(struct mpdview_s));
+ if (view == NULL) {
+ return (NULL);
+ }
view->conn = NULL;
view->status = NULL;
view->song = NULL;
@@ -159,17 +163,12 @@ c_get_current_dir(struct mpdview_s* v)
{
ptr_t ptr;
- snprintf(
- v->current_dir,
- PATH_MAX,
- "%s/%s",
- v->music_dir,
- mpd_song_get_uri(v->song)
- );
+ strlcpy(v->current_dir, v->music_dir, PATH_MAX);
+ v->current_dir[strlen(v->current_dir) + 1] = 0x00;
+ v->current_dir[strlen(v->current_dir)] = '/';
+ strlcat(v->current_dir, mpd_song_get_uri(v->song), PATH_MAX);
ptr = v->current_dir;
- while (*ptr != 0x00) {
- ptr++;
- }
+ ptr += strlen(v->current_dir);
while (*ptr != '/' && ptr > v->music_dir) {
ptr--;
}