兼容 asr1903
Change-Id: I3888f1adc86ea1fa73af4996d31f40223c0e5735
diff --git a/build.sh b/build.sh
index 30a0414..201bf90 100755
--- a/build.sh
+++ b/build.sh
@@ -14,6 +14,8 @@
export BUILD_STD_LIBC=glibc
fi
+export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2`
+
if [ -n "$1" ] ;then
case "$1" in
v1)
@@ -156,6 +158,12 @@
if [ ! -d out/bin ];then
mkdir -p out/bin
fi
+
+ if [ "$BUILD_LIBC_TEMP" == "musl" ];then
+ [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so
+ else
+ [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so
+ fi
if [ -n "$1" ] ;then
if [ "$1" == "v1" -o "$1" == "v2" ];then
diff --git a/config b/config
index d379e8f..11c6dd5 100755
--- a/config
+++ b/config
@@ -1,5 +1,8 @@
# Libc glibc / musl
CONFIG_MBTK_LIBC=glibc
+# Libc 4.9/8.4/13.3
+CONFIG_GCC_VERSION=8.4
+
# mbtk_source version : 1 / 2
CONFIG_MBTK_SOURCE_VERSION=1
diff --git a/mbtk/Make.defines b/mbtk/Make.defines
index 355db8c..d364ff9 100755
--- a/mbtk/Make.defines
+++ b/mbtk/Make.defines
@@ -8,12 +8,12 @@
OUT_DIR = $(ROOT)/out
LOCAL_PATH=.
+BUILD_TOOLCHAIN_DIR = $(ROOT)/toolchain/gcc-$(BUILD_GCC_VERSION)-$(BUILD_STD_LIBC)
+
ifeq ($(BUILD_STD_LIBC), glibc)
-BUILD_TOOLCHAIN_DIR = $(ROOT)/toolchain/gcc-8.4-glibc
CC=$(BUILD_TOOLCHAIN_DIR)/bin/arm-openwrt-linux-gnueabi-gcc
AR=$(BUILD_TOOLCHAIN_DIR)/bin/arm-openwrt-linux-gnueabi-ar
else
-BUILD_TOOLCHAIN_DIR = $(ROOT)/toolchain/gcc-8.4
CC=$(BUILD_TOOLCHAIN_DIR)/bin/arm-openwrt-linux-muslgnueabi-gcc
AR=$(BUILD_TOOLCHAIN_DIR)/bin/arm-openwrt-linux-muslgnueabi-ar
endif
@@ -30,7 +30,7 @@
# -Werror=non-virtual-dtor
#CFLAGS= --sysroot=$(BUILD_TOOLCHAIN_DIR) -Os -pipe -rdynamic -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -mfloat-abi=hard -fno-exceptions -Wno-multichar -ffunction-sections -fdata-sections -funwind-tables -Wa,--noexecstack -fno-short-enums -no-canonical-prefixes -fno-canonical-system-headers -mfpu=neon -fno-builtin-sin -fno-strict-volatile-bitfields -Wno-psabi -mthumb-interwork -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop -frename-registers -mthumb -fomit-frame-pointer -fno-strict-aliasing -Werror=format-security -Werror=return-type -Werror=address -Werror=sequence-point -ffunction-sections -Wl,--gc-sections -Wl,--no-undefined -Wno-sign-compare -Wno-pointer-arith
-CFLAGS = --sysroot=$(BUILD_TOOLCHAIN_DIR) -Os -pipe -rdynamic -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -Wall -Werror -g
+CFLAGS = --sysroot=$(BUILD_TOOLCHAIN_DIR) -Os -pipe -rdynamic -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -Wall -Werror -g -Wno-error=format
CFLAGS_TEST = --sysroot=$(BUILD_TOOLCHAIN_DIR) -Os -pipe -rdynamic -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -mfloat-abi=hard -fno-exceptions -Wno-multichar -ffunction-sections -fdata-sections -funwind-tables -Wa,--noexecstack -fno-short-enums -no-canonical-prefixes -fno-canonical-system-headers -mfpu=neon -fno-builtin-sin -fno-strict-volatile-bitfields -Wno-psabi -mthumb-interwork -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop -frename-registers -mthumb -fomit-frame-pointer -fno-strict-aliasing -Werror=format-security -Werror=return-type -Werror=address -Werror=sequence-point -ffunction-sections -Wl,--gc-sections -Wl,--no-undefined -Wno-sign-compare -Wno-pointer-arith
diff --git a/mbtk/aboot-tiny/jacana/jacana_main.c b/mbtk/aboot-tiny/jacana/jacana_main.c
index abd0ef3..27a7ade 100755
--- a/mbtk/aboot-tiny/jacana/jacana_main.c
+++ b/mbtk/aboot-tiny/jacana/jacana_main.c
@@ -33,6 +33,10 @@
char gpioCtrlPath[128] = "/sys/devices/platform/asr-gps/ctrl";
+#ifndef LOG_ERR_LEVEL
+#define LOG_ERR_LEVEL 3 /* error conditions */
+#endif
+
static void dubheWrite(char* str)
{
int fd;
diff --git a/mbtk/libmbtk_lib/Makefile b/mbtk/libmbtk_lib/Makefile
index 90fc89f..eba855b 100755
--- a/mbtk/libmbtk_lib/Makefile
+++ b/mbtk/libmbtk_lib/Makefile
@@ -23,7 +23,17 @@
LIB_DIR +=
-LIBS += -llog -lubus -lubox -luci -lprop2uci -lrilutil -lblobmsg_json -ldl -lcutils -laudio-apu -lssl -lcrypto -lwpa_client
+LIBS += -llog -lubus -lubox -luci -lprop2uci -lrilutil -lblobmsg_json -ldl -lcutils -laudio-apu -lwpa_client
+
+ifeq ($(BUILD_GCC_VERSION), 13.3)
+$(info SSL not support)
+else
+$(info SSL support)
+DEFINE += -DMBTK_SSL_SUPPORT
+LIBS += -lssl -lcrypto
+endif
+
+CFLAGS += -Wno-error=unused-but-set-variable
ifeq ($(BUILD_LIB_TYPE), shared)
CFLAGS += -shared -Wl,-shared,-Bsymbolic
@@ -47,6 +57,7 @@
#LOCAL_SRC_FILES += $(MY_SRC_LIST)
# common
+# common/mbtk_debug.c
LOCAL_SRC_FILES = \
common/ds_ASBuffer.cpp \
common/ds_ASString.cpp \
@@ -68,7 +79,6 @@
common/mbtk_version.c \
common/mbtk_gpio.c \
common/mbtk_adc.c \
- common/mbtk_debug.c \
common/mbtk_loopbuff.c
# audio
@@ -176,7 +186,7 @@
$(dtarget):$(OBJS)
$(CC) $(CFLAGS) $(DEFINE) $(LIB_DIR) $(LIBS) $(OBJS) -o $@
- @cp -f wifi/libs/*.so $(OUT_DIR)/lib
+ @cp -f wifi/libs/libwpa_client.so $(OUT_DIR)/lib
%.o:%.c
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
diff --git a/mbtk/libmbtk_lib/coap/mbtk_coap.c b/mbtk/libmbtk_lib/coap/mbtk_coap.c
index 2fd96a8..468af5c 100755
--- a/mbtk/libmbtk_lib/coap/mbtk_coap.c
+++ b/mbtk/libmbtk_lib/coap/mbtk_coap.c
@@ -496,8 +496,9 @@
mbtk_ecoap_option_s *option_ptr = coap->options;
while(option_ptr != NULL)
{
- free(option_ptr);
+ mbtk_ecoap_option_s *tmp_ptr = option_ptr;
option_ptr = option_ptr->next;
+ free(tmp_ptr);
}
}
diff --git a/mbtk/libmbtk_lib/ftp/mbtk_ftp_at.c b/mbtk/libmbtk_lib/ftp/mbtk_ftp_at.c
index 958b0d0..fd10045 100755
--- a/mbtk/libmbtk_lib/ftp/mbtk_ftp_at.c
+++ b/mbtk/libmbtk_lib/ftp/mbtk_ftp_at.c
@@ -240,7 +240,7 @@
int mbtk_at_ftp_upload(char *remote_path,char *local_path, int size_byte, int rest_size)
{
int at_ftp_ret=-1;
- int len_size;
+ int len_size = 0;
char send_buf[1024];
mbtk_at_ftp_par_at.at_ftp_handle = mbtk_ftp_init(mbtk_at_ftp_par_at.host, mbtk_at_ftp_par_at.port, mbtk_at_ftp_par_at.auth_type,
diff --git a/mbtk/libmbtk_lib/net/mbtk_net_control.c b/mbtk/libmbtk_lib/net/mbtk_net_control.c
index 458f940..96701e9 100755
--- a/mbtk/libmbtk_lib/net/mbtk_net_control.c
+++ b/mbtk/libmbtk_lib/net/mbtk_net_control.c
@@ -54,7 +54,7 @@
static bool net_control_thread_running = FALSE;
#ifdef MBTK_NET_MONITOR_SUPPORT
-static pthread_t net_control_thread_id = -1;
+static pthread_t net_control_thread_id;
static int net_control_fd = -1;
static char net_if_name[100] = {0};
#endif
@@ -595,7 +595,6 @@
if(mbtk_task_start(&net_control_thread))
{
LOGE("Create thread fail.");
- net_control_thread_id = -1;
net_control_thread_running = FALSE;
return -1;
}
diff --git a/mbtk/libmbtk_lib/net/mbtk_sock.c b/mbtk/libmbtk_lib/net/mbtk_sock.c
index ccd872f..bd12db6 100755
--- a/mbtk/libmbtk_lib/net/mbtk_sock.c
+++ b/mbtk/libmbtk_lib/net/mbtk_sock.c
@@ -96,7 +96,7 @@
addr_in6 = (struct sockaddr_in6 *)curr->ai_addr;
memcpy(&(serverSockAddr.sin6_addr), &(addr_in6->sin6_addr), sizeof(struct in6_addr));
}
- if (connect(sock_info->fd, &serverSockAddr, sizeof(struct sockaddr_in6)) < 0)
+ if (connect(sock_info->fd, (struct sockaddr*)&serverSockAddr, sizeof(struct sockaddr_in6)) < 0)
{
if (EINPROGRESS != errno)
{
diff --git a/mbtk/libmbtk_lib/net/mbtk_sock2.c b/mbtk/libmbtk_lib/net/mbtk_sock2.c
index 45ae0b6..6d2c7fb 100755
--- a/mbtk/libmbtk_lib/net/mbtk_sock2.c
+++ b/mbtk/libmbtk_lib/net/mbtk_sock2.c
@@ -10,7 +10,9 @@
#include <sys/time.h>
#include <fcntl.h>
#include <netdb.h>
+#include <pthread.h>
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
#include <polarssl/net.h>
#include <polarssl/ssl.h>
@@ -34,6 +36,8 @@
#define DFL_CRT_FILE "/client.crt"
#define DFL_KEY_FILE "/client.key"
#endif
+#endif
+
#include <sys/ioctl.h>
#ifdef LOG_TAG
@@ -54,7 +58,7 @@
static int epoll_fd = -1;
static int pipe_fds[2];
static struct epoll_event epoll_events[20];
-static pthread_t sock_thread_id = -1;
+static pthread_t sock_thread_id;
static bool sock_thread_running = FALSE;
static mbtk_sock_s *mbtk_sock[MBTK_HANDLE_MAX_NUM] = {NULL};
@@ -290,6 +294,7 @@
return handle;
}
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
static int mbtk_polarssl_open(int fd ,bool ingnore_cert,mbtk_sock_inter_info_s* inter_info)
{
@@ -657,6 +662,7 @@
}
#endif
+#endif
extern mbtk_sock_session mbtk_sock_open(mbtk_sock_handle handle,mbtk_sock_info *info,
unsigned int timeout,
@@ -849,6 +855,7 @@
}
#endif
if(info->is_support_ssl){
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
if(mbtk_polarssl_open(mbtk_sock[handle]->inter_infos[index_free].fd,info->ingnore_cert,&mbtk_sock[handle]->inter_infos[index_free]) == -1){
LOGE("mbtk_openssl_init fail");
@@ -862,6 +869,8 @@
#endif
+
+#endif
}
*mbtk_errno = MBTK_SOCK_SUCCESS;
@@ -890,11 +899,15 @@
break;
}
}
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
return mbtk_polarssl_open(mbtk_sock[handle]->inter_infos[index_free].fd,ingnore_cert,&mbtk_sock[handle]->inter_infos[index_free]);
#else
return mbtk_openssl_open(mbtk_sock[handle]->inter_infos[index_free].fd,ingnore_cert,&mbtk_sock[handle]->inter_infos[index_free]);
#endif
+#else
+ return -1;
+#endif
}
extern int mbtk_ssl_close_func(mbtk_sock_handle handle ,bool ingnore_cert,mbtk_sock_session fd)
{
@@ -909,7 +922,7 @@
break;
}
}
-
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
if(mbtk_sock[handle]->inter_infos[index_free].ssl!=NULL)
printf("\nmbtk_sock[handle]->inter_infos[index_free].ssl not empty\n");
@@ -919,6 +932,10 @@
printf("\nmbtk_sock[handle]->inter_infos[index_free].ssl not empty\n");
return mbtk_openssl_close(&mbtk_sock[handle]->inter_infos[index_free]);
#endif
+
+#else
+ return -1;
+#endif
}
extern int mbtk_sock_write(mbtk_sock_handle handle,mbtk_sock_session session,
@@ -966,12 +983,17 @@
if(mbtk_sock[handle]->infos[index].type == MBTK_SOCK_TCP) {
while(count < buf_len){
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
len = mbtk_polarssl_write(inter_info->ssl,(const unsigned char*)buffer + count,buf_len - count);
#else
len = mbtk_openssl_write(inter_info->ssl,(const unsigned char *)buffer + count,buf_len - count);
#endif
+
+#else
+ return -1;
+#endif
} else
len = write(inter_info->fd,(char*)buffer + count,buf_len - count);
if(len < 0){
@@ -1075,12 +1097,16 @@
while(count < buf_len){
try_count++;
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
len = mbtk_polarssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#else
len = mbtk_openssl_read(inter_info->ssl,(unsigned char *)buffer + count,buf_len - count);
#endif
+#else
+ return -1;
+#endif
} else
len = read(inter_info->fd,(char*)buffer + count,buf_len - count);
if(len < 0){
@@ -1133,7 +1159,7 @@
while(TRUE){
try_count++;
seraddr_len = sizeof(struct sockaddr_in);
- len = recvfrom(inter_info->fd,buffer,buf_len,0,&seraddr,&seraddr_len);
+ len = recvfrom(inter_info->fd,buffer,buf_len,0,(struct sockaddr*)&seraddr,&seraddr_len);
if(len < 0){
if(errno == EWOULDBLOCK){// No data can read.
if(count > 0) // Read data
@@ -1251,11 +1277,15 @@
while(count < buf_len){
try_count++;
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
len = mbtk_polarssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#else
len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#endif
+#else
+ return -1;
+#endif
} else
len = read(inter_info->fd,(char*)buffer + count,buf_len - count);
*read_line_count = len;
@@ -1325,7 +1355,7 @@
while(TRUE){
try_count++;
seraddr_len = sizeof(struct sockaddr_in);
- len = recvfrom(inter_info->fd,buffer,buf_len,0,&seraddr,&seraddr_len);
+ len = recvfrom(inter_info->fd,buffer,buf_len,0,(struct sockaddr*)&seraddr,&seraddr_len);
if(len < 0){
if(errno == EWOULDBLOCK){// No data can read.
if(count > 0) // Read data
@@ -1427,12 +1457,16 @@
memset(buffer,0x0,buf_len);
while(read_count < buf_len) {
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
len = ssl_read(inter_info->ssl,(unsigned char*)buffer + read_count,buf_len - read_count);
#else
len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer + read_count,buf_len - read_count);
#endif
+#else
+ return -1;
+#endif
} else
len = read(inter_info->fd,(char*)buffer + read_count,buf_len - read_count);
@@ -1455,7 +1489,7 @@
memset(buffer,0x0,buf_len);
while(read_count < buf_len) {
- len = recvfrom(inter_info->fd,buffer + read_count,buf_len - read_count,0,&seraddr,&seraddr_len);
+ len = recvfrom(inter_info->fd,buffer + read_count,buf_len - read_count,0,(struct sockaddr*)&seraddr,&seraddr_len);
if(len > 0) {
read_count += len;
@@ -1518,12 +1552,16 @@
TCP_READ_AGAIN:
memset(buffer,0x0,buf_len);
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
len = ssl_read(inter_info->ssl,(unsigned char*)buffer,buf_len);
#else
len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer,buf_len);
#endif
+#else
+ return -1;
+#endif
} else
len = read(inter_info->fd,(char*)buffer,buf_len);
if(len < 0){
@@ -1543,7 +1581,7 @@
UDP_READ_AGAIN:
memset(buffer,0x0,buf_len);
seraddr_len = sizeof(struct sockaddr_in);
- len = recvfrom(inter_info->fd,buffer,buf_len,0,&seraddr,&seraddr_len);
+ len = recvfrom(inter_info->fd,buffer,buf_len,0,(struct sockaddr*)&seraddr,&seraddr_len);
if(len < 0){
if(errno == EWOULDBLOCK){
usleep(100000);
@@ -1617,6 +1655,7 @@
}
if(mbtk_sock[handle]->infos[index].is_support_ssl){
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
if(mbtk_polarssl_close(inter_info)== -1)
{
@@ -1631,6 +1670,7 @@
}
#endif
+#endif
}
*mbtk_errno = MBTK_SOCK_SUCCESS;
diff --git a/mbtk/libmbtk_lib/net/mbtk_sock_internal.h b/mbtk/libmbtk_lib/net/mbtk_sock_internal.h
index de822bc..a6a6241 100755
--- a/mbtk/libmbtk_lib/net/mbtk_sock_internal.h
+++ b/mbtk/libmbtk_lib/net/mbtk_sock_internal.h
@@ -9,6 +9,7 @@
typedef struct {
int fd;
mbtk_sock_type type; // socket type:TCP or UDP
+#ifdef MBTK_SSL_SUPPORT
#ifdef MBTK_POLARSSL_SUPPORT
entropy_context* entropy;
ctr_drbg_context* ctr_drbg;
@@ -21,6 +22,7 @@
SSL_CTX *ctx;
SSL *ssl;
#endif
+#endif
} mbtk_sock_inter_info_s;
typedef struct {
diff --git a/mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so b/mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so
new file mode 100755
index 0000000..7f492b2
--- /dev/null
+++ b/mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so
Binary files differ
diff --git a/mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so b/mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so
new file mode 100755
index 0000000..0694d94
--- /dev/null
+++ b/mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so
Binary files differ
diff --git a/mbtk/libmbtk_lib/wifi/sta_cli.c b/mbtk/libmbtk_lib/wifi/sta_cli.c
index 9dbd202..1cebc66 100755
--- a/mbtk/libmbtk_lib/wifi/sta_cli.c
+++ b/mbtk/libmbtk_lib/wifi/sta_cli.c
@@ -281,7 +281,7 @@
time_t t;
t = time(NULL);
snprintf(mac,20,
- "%ld",t);
+ "%lld",t);
}
snprintf(name,name_len,"%s-%s",host,mac);
@@ -429,7 +429,7 @@
{
struct timeval now_1;
struct timespec outtime;
- int thread_id = pthread_self();
+ pthread_t thread_id = pthread_self();
LOGE("Thread(%ld) pause.\n",thread_id);
pthread_mutex_lock(&mutex);
gettimeofday(&now_1, NULL);
diff --git a/mbtk/libmbtk_lib/wifi/sta_ctrl.c b/mbtk/libmbtk_lib/wifi/sta_ctrl.c
index cad497c..8d6a88a 100755
--- a/mbtk/libmbtk_lib/wifi/sta_ctrl.c
+++ b/mbtk/libmbtk_lib/wifi/sta_ctrl.c
@@ -47,7 +47,7 @@
static struct wpa_ctrl *sta_ctrl_conn;
static struct wpa_ctrl *sta_mon_conn;
static int sta_ctrl_attached = 0;
-static pthread_t sta_event_thread_id = -1;
+static pthread_t sta_event_thread_id;
static int sta_event_thread_is_running = 0;
static char sta_ctrl_conf_file_path[50];
static char sta_ctrl_ifname[10];
@@ -586,7 +586,6 @@
close(sta_ctrl_pipe_fd[0]);
close(sta_ctrl_pipe_fd[1]);
- sta_event_thread_id = -1;
sta_ctrl_msg = NULL;
// Stop process wpa_supplicant
diff --git a/mbtk/mbtk_adbd/src/main.c b/mbtk/mbtk_adbd/src/main.c
index f52f1d4..4d2564f 100755
--- a/mbtk/mbtk_adbd/src/main.c
+++ b/mbtk/mbtk_adbd/src/main.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdint.h>
#include <string.h>
#include <cutils/properties.h>
#include <time.h>
@@ -156,7 +157,7 @@
}
if(chdir(cmd)) {
- char buff[ADB_BUFF_SIZE] = {0};
+ char buff[ADB_BUFF_SIZE + 10] = {0};
sprintf(buff, "Can't cd to %s", cmd);
if(adb_msg_send(adb_fd, MBTK_ADB_MSG_CMD_RSP_COMPLETE, buff, strlen(buff)) <= 0) {
LOGE("Send MBTK_ADB_MSG_CMD_RSP_COMPLETE fail.");
@@ -269,8 +270,8 @@
} else if(!strncasecmp(shell_cmd, "shell ", 6)) { // Shell command.
LOGD("Kill cmd:%s", shell_cmd + 6);
- char cmd[1024] = {0};
- snprintf(cmd,1024,"kill `pidof %s | awk '{print $1}'`", shell_cmd + 6);
+ char cmd[1024 * 3] = {0};
+ snprintf(cmd,sizeof(cmd),"kill `pidof %s | awk '{print $1}'`", shell_cmd + 6);
mbtk_system(cmd);
} else {
LOGE("Kill Command/AT error.");
diff --git a/mbtk/mbtk_logd/Makefile b/mbtk/mbtk_logd/Makefile
index 2ef7531..22368ba 100755
--- a/mbtk/mbtk_logd/Makefile
+++ b/mbtk/mbtk_logd/Makefile
@@ -9,7 +9,7 @@
LIBS += -lubus -lubox -ljson-c -lblobmsg_json -lmbtk_lib
-CFLAGS +=
+CFLAGS += -Wno-error=unused-but-set-variable -Wno-error=stringop-overflow
DEFINE +=
diff --git a/mbtk/mbtk_logd/main.c b/mbtk/mbtk_logd/main.c
index 4cd4888..d2ba2b8 100755
--- a/mbtk/mbtk_logd/main.c
+++ b/mbtk/mbtk_logd/main.c
@@ -100,8 +100,9 @@
if (_filter_list->tag && _filter_list->tag[0] != '\0') {
free(_filter_list->tag);
}
- free(_filter_list);
+ struct filter_list_t* tmp_filter_list = _filter_list;
_filter_list = _filter_list->next;
+ free(tmp_filter_list);
} else {
break;
}
diff --git a/mbtk/mbtk_logd/socket_read.c b/mbtk/mbtk_logd/socket_read.c
index 7b54051..32e6844 100755
--- a/mbtk/mbtk_logd/socket_read.c
+++ b/mbtk/mbtk_logd/socket_read.c
@@ -12,6 +12,7 @@
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
+#include <string.h>
#include "log_config.h"
diff --git a/mbtk/mbtk_logd/syslog_read.c b/mbtk/mbtk_logd/syslog_read.c
index 04bedb0..2f4c9a7 100755
--- a/mbtk/mbtk_logd/syslog_read.c
+++ b/mbtk/mbtk_logd/syslog_read.c
@@ -91,7 +91,7 @@
static struct file_list_t file_list;
static struct filter_list_t *filter_log = NULL;
static char tmp_log[100] = {0};
-pthread_t attr = -1;
+pthread_t attr;
static const char* getcodetext(int value, CODE *codetable) {
CODE *i;
@@ -432,8 +432,10 @@
while(tmp_filter_list != NULL) {
_filter_list = tmp_filter_list;
- free(tmp_filter_list);
+
+ struct filter_list_t* list_ptr = tmp_filter_list;
tmp_filter_list = _filter_list->next;
+ free(list_ptr);
}
return 0;
diff --git a/mbtk/mbtk_rild_v2/src/atchannel.c b/mbtk/mbtk_rild_v2/src/atchannel.c
index f959a59..80f8e68 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -321,6 +321,7 @@
if(*line == '"')
{
char *line_temp = strdup(line);
+ char *free_ptr = line_temp;
line_temp++;
if(strlen(line_temp) > 0)
{
@@ -332,7 +333,7 @@
}
}
addIntermediate(port, line_temp);
- free(line_temp);
+ free(free_ptr);
}
else
{
@@ -1303,7 +1304,7 @@
* Returns error code from response
* Assumes AT+CMEE=1 (numeric) mode
*/
-int at_get_cme_error(const ATResponse *p_response)
+AT_CME_Error at_get_cme_error(const ATResponse *p_response)
{
int ret;
int err;
diff --git a/mbtk/mbtk_sdk_ready_v2/src/main.c b/mbtk/mbtk_sdk_ready_v2/src/main.c
index f0eef7d..2e15a86 100755
--- a/mbtk/mbtk_sdk_ready_v2/src/main.c
+++ b/mbtk/mbtk_sdk_ready_v2/src/main.c
@@ -1,5 +1,6 @@
#if 1
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
diff --git a/mbtk/mbtk_servicesd_v2/src/main.c b/mbtk/mbtk_servicesd_v2/src/main.c
index f546cd3..0165835 100755
--- a/mbtk/mbtk_servicesd_v2/src/main.c
+++ b/mbtk/mbtk_servicesd_v2/src/main.c
@@ -14,6 +14,7 @@
******************************************************************************/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
diff --git a/mbtk/mbtk_servicesd_v2/src/ntp_service.c b/mbtk/mbtk_servicesd_v2/src/ntp_service.c
index 7772544..7f37214 100755
--- a/mbtk/mbtk_servicesd_v2/src/ntp_service.c
+++ b/mbtk/mbtk_servicesd_v2/src/ntp_service.c
@@ -14,6 +14,7 @@
******************************************************************************/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
diff --git a/mbtk/test/libmbtk_ril/mbtk_ril_test.c b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
index ffa83c6..35c29f3 100755
--- a/mbtk/test/libmbtk_ril/mbtk_ril_test.c
+++ b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
@@ -1269,7 +1269,8 @@
char cmgs[1024] = {0};
char resp[50] = {0};
if(!strcasecmp(cmd, "cmgs")) { // Get
- int mode;
+ int mode = 0;
+ err = 0;
// err = mbtk_sms_cmgs_get(info_handle, &mode);
if(err) {
printf("Error : %d\n", err);
diff --git a/mbtk/test/others/key_ev_demo.c b/mbtk/test/others/key_ev_demo.c
deleted file mode 100755
index 728b5d0..0000000
--- a/mbtk/test/others/key_ev_demo.c
+++ /dev/null
@@ -1,251 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <poll.h>
-#include <errno.h>
-#include <linux/input.h>
-#include <sys/stat.h>
-#include <sys/reboot.h>
-#include <sys/timerfd.h>
-#include <time.h>
-
-#include "mbtk_type.h"
-#include "mbtk_log.h"
-
-
-#define MAX_DEVICES 16
-#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)
-#define POWER_KEY_LONG_PRESS_TIMEOUT 8000 // 8s
-#define POWER_KEY_PRESS_TIMEOUT 2000 // 2s
-
-static struct pollfd ev_fds[MAX_DEVICES];
-static unsigned ev_count = 0;
-
-
-static int ev_init(void)
-{
- DIR *dir;
- struct dirent *de;
- int fd;
-
- fd = open("/dev/rtc0", O_RDONLY);
- if (fd < 0)
- {
- LOGW("open rtc0 error\n");
- }
- else
- {
- ev_fds[ev_count].fd = fd;
- ev_fds[ev_count].events = POLLIN;
- ev_count++;
- LOGI("Monitor /dev/rtc0");
- }
-
- dir = opendir("/dev/input");
- if (dir != NULL)
- {
- LOGI("dir = /dev/input");
- while ((de = readdir(dir)) != NULL)
- {
- if (strncmp(de->d_name, "event", 5))
- continue;
- fd = openat(dirfd(dir), de->d_name, O_RDONLY);
- if (fd < 0)
- continue;
-
- ev_fds[ev_count].fd = fd;
- ev_fds[ev_count].events = POLLIN;
- ioctl(fd, EVIOCSSUSPENDBLOCK, 1);
- ev_count++;
- if (ev_count == MAX_DEVICES)
- break;
-
- LOGI("Monitor /dev/input/%s", de->d_name);
- }
-
- closedir(dir);
- }
- else
- {
- LOGE("opendir() fail.[%d]",errno);
- return -1;
- }
- return 0;
-}
-
-#if 0
-static void ev_exit(void)
-{
- while (ev_count > 0)
- {
- close(ev_fds[--ev_count].fd);
- }
-}
-#endif
-
-/* wait: 0 dont wait; -1 wait forever; >0 wait ms */
-static int ev_get(struct input_event *ev, int wait_ms)
-{
- int r;
- unsigned n;
- unsigned long alarm_data;
-
-// if(wait_ms < 0)
-// {
-// LOGE("poll event return\n");
-// return -1;
-// }
-
- LOGI("Waitting data...");
- r = poll(ev_fds, ev_count, wait_ms);
- LOGI("Get Data:result = %d",r);
-
- if (r > 0)
- {
- for (n = 0; n < ev_count; n++)
- {
- if (ev_fds[n].revents & POLLIN)
- {
- if (n == 0)
- {
- r = read(ev_fds[n].fd, &alarm_data, sizeof(alarm_data));
- LOGD("get form 0 is %ld", alarm_data);
- ev->type = EV_KEY;
- ev->code = KEY_BRL_DOT8;
- ev->value = 1;
- return 0;
- }
- else
- {
- r = read(ev_fds[n].fd, ev, sizeof(*ev));
- if (r == sizeof(*ev))
- return 0;
- }
- }
- }
- }
- return -1;
-}
-
-
-static void power_process(bool down, struct timeval *time)
-{
- printf("POWER_KEY - %s,Time : %ld %ld \n", down ? "DOWN" : "UP", time->tv_sec, time->tv_usec);
-#if 0
- static struct timeval down_time;
- static bool key_down;
- if(down) // Down
- {
- key_down = true;
- power_long_press_timeout = false;
- down_time.tv_sec = time->tv_sec;
- down_time.tv_usec = time->tv_usec;
- signal(SIGALRM, power_key_timer_alrm);
- struct itimerval val;
- // Only time
- val.it_interval.tv_sec = 0;
- val.it_interval.tv_usec = 0;
- // Time
- if(POWER_KEY_LONG_PRESS_TIMEOUT >= 1000)
- {
- val.it_value.tv_sec = POWER_KEY_LONG_PRESS_TIMEOUT/1000;
- val.it_value.tv_usec = POWER_KEY_LONG_PRESS_TIMEOUT%1000;
- }
- else
- {
- val.it_value.tv_sec = 0;
- val.it_value.tv_usec = POWER_KEY_LONG_PRESS_TIMEOUT;
- }
- if (setitimer(ITIMER_REAL, &val, NULL) == -1)
- {
- LOGE("setitimer fail.[%d]",errno);
- return;
- }
- }
- else // UP
- {
- if(key_down)
- {
- // ms
- long time_used = (time->tv_sec - down_time.tv_sec) * 1000 + (time->tv_usec - down_time.tv_usec) / 1000;
- LOGI("Down time[%ld,%ld], Up time[%ld,%ld], time_used = %ld ms",down_time.tv_sec,down_time.tv_usec,
- time->tv_sec,time->tv_usec,time_used);
-
- if(!power_long_press_timeout)
- {
- // Cancel alarm
- struct itimerval value;
- value.it_value.tv_sec = 0;
- value.it_value.tv_usec = 0;
- value.it_interval = value.it_value;
- setitimer(ITIMER_REAL, &value, NULL);
-
- if(time_used <= POWER_KEY_PRESS_TIMEOUT)
- {
- screen_state_change(false);
- }
- else
- {
- LOGI("Press timeout.");
- }
- }
- else
- {
- LOGI("Long Press timeout.");
- }
- }
- else
- {
- LOGI("UP key for screen on.");
- }
-
- key_down = false;
- }
-#endif
-}
-
-
-int main(int argc, char *argv[])
-{
- mbtk_log_init(NULL, "MBTK_KEY");
- // Open dev
- ev_init();
-
- int ret = 0;
- struct input_event ev;
- while(1)
- {
- ret = ev_get(&ev, -1);
- if(ret)
- {
- LOGW("ev_get() fail.");
- continue;
- }
-
- LOGI("ev:time[%ld,%ld],type:%d,code:%d,value:%d",ev.time.tv_sec,ev.time.tv_usec,
- ev.type,ev.code,ev.value);
- if(ev.type != EV_KEY)
- {
- LOGW("event type error.[%d]",ev.type);
- continue;
- }
-
- switch(ev.code)
- {
- case KEY_POWER: // Power key
- {
- power_process(ev.value, &(ev.time));
- break;
- }
- default:
- {
- LOGD("Unknown KEY[%d]",ev.code);
- break;
- }
- }
- }
- return 0;
-}