diff --git a/Makefile b/Makefile
index 39a78661bf7ac8f3865a3b5899df94a2871396b4..1662f3dc40f06b8bc5411c2f4ffd675f4b255eef 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ VOICEMNGR := voicemngr
 
 CFLAGS += -O2 -fcaller-saves -fsection-anchors
 CFLAGS += -Wall -Werror
-CFLAGS += -Wextra -std=gnu99 -D_GNU_SOURCE
+CFLAGS += -Wextra -std=gnu99
 CFLAGS += -DBOS_OS_LINUXUSER -DBOS_CFG_TIME -DNTR_SUPPORT -DWITH_UBUS
 CFLAGS += -I./ -Ilibvoice/
 
diff --git a/libvoice/Makefile b/libvoice/Makefile
index 6a6f4a4f44f20b0aaf23e25f4ef7ff1eeba91a70..c25aeb68f05dc4e1d918284c3d80be6604f4cba4 100644
--- a/libvoice/Makefile
+++ b/libvoice/Makefile
@@ -12,7 +12,7 @@ LIBVOICE := libvoice.so
 
 CFLAGS  += -O2 -fcaller-saves -fsection-anchors
 CFLAGS  += -Wall -Werror
-CFLAGS  += -Wextra -std=gnu99 -D_GNU_SOURCE
+CFLAGS  += -Wextra -std=gnu99
 CFLAGS  += -DBOS_OS_LINUXUSER -DBOS_CFG_TIME -DNTR_SUPPORT -DWITH_UBUS
 CFLAGS  += -I./
 
diff --git a/line.c b/line.c
index 5df9d2f7719494f37bc2794921b4853511f89e77..3c0fb0127024d596aeebe5ee6adf280cfe3fb596 100644
--- a/line.c
+++ b/line.c
@@ -120,11 +120,12 @@ static int line_signal_ring(int line, int pcm, enum VOICE_SIGNAL signal, const c
 		// Parse the called ID string generated by Asterisk
 		if(data && strlen(data) >= CLID_MIN_LEN && strlen(data) <= MAX_CALLER_ID_LEN &&
 			data[CLID_TIME_DELIM] == ',' && data[CLID_NUMB_REC + 1] != ',') {
-			char callIdTmp[strlen(data) + 1];
+			char cid_tmp[strlen(data) + 1], *end;
 
-			strcpy(callIdTmp, data);                                // Copy into a temp buffer.
-			*strchrnul(callIdTmp + CLID_NUMB_REC, ',') = 0;         // Find comma after digits and null it.
-			strcpy(line_req->caller_id, callIdTmp + CLID_NUMB_REC); // Extract the number.
+			strcpy(cid_tmp, data);
+			if ((end = strchr(cid_tmp + CLID_NUMB_REC, ',')) != NULL)
+				*end = '\0'; // Find comma after digits and null it
+			strcpy(line_req->caller_id, cid_tmp + CLID_NUMB_REC); // Extract the number
 		}
 	}
 
diff --git a/main.c b/main.c
index 5eccb1fa1e9ace5cf0b6860bcd96a9bcd56f0a6c..fdeab07e94ce4d0622cd6f3975822670096b23bb 100644
--- a/main.c
+++ b/main.c
@@ -3,6 +3,9 @@
 #include <unistd.h>
 #include <signal.h>
 #include <stdlib.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>