提交 a4cc4156 编写于 作者: N nocjj

build: add configure option enable-debug and secure-build

Add enable-debug option ad secure-build option to configure.ac.
enable-debug: add "-g -O0" to CFLAGS
secure-build: add secure compile option
Signed-off-by: NJiajun Chen <1250062498@qq.com>
上级 39a70f92
......@@ -10,6 +10,7 @@ AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_PROG_RANLIB
AM_INIT_AUTOMAKE([subdir-objects])
CC="$CC -std=gnu11"
# Checks for libraries.
AC_CHECK_LIB(ncurses, initscr, [], [echo "missing ncurses support!";exit -1])
......@@ -26,6 +27,18 @@ AC_TYPE_PID_T
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset realpath strstr strtoul])
# AC_ARGS_ENABLES
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [debug program(default is disable)])],
[CFLAGS="-g -O0"],
[CFLAGS="-g -O2"]
)
AC_ARG_ENABLE([secure-build],
[AS_HELP_STRING([--enable-secure-build], [build project with secure flags])],
[CFLAGS="${CFLAGS} -Wl,-z,relro,-z,now -fPIE -fPIC -pie -Werror -Wall -ftrapv -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2"],[]
)
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
......@@ -123,7 +123,7 @@ static int get_id_from_cgroup(pid_t pid)
char *tmp = NULL;
int id = -1;
if (snprintf(path, CGROUP_PATH_SIZE, "/proc/%lu/cgroup", pid) < 0) {
if (snprintf(path, CGROUP_PATH_SIZE, "/proc/%u/cgroup", pid) < 0) {
return id;
}
fp = fopen(path, "r");
......@@ -156,7 +156,7 @@ static int get_child_pid(struct domain *dom)
char *end = NULL;
int i = 0;
if (snprintf(path, TASK_STRING_SIZE, "/proc/%lu/task", dom->pid) < 0) {
if (snprintf(path, TASK_STRING_SIZE, "/proc/%u/task", dom->pid) < 0) {
return -1;
}
dirptr = opendir(path);
......
......@@ -76,11 +76,11 @@ int get_proc_stat(struct domain *dom)
int i = 0;
if (dom->type == ISDOMAIN) {
if (snprintf(path, STAT_PATH_SIZE, "/proc/%lu/stat", dom->pid) < 0) {
if (snprintf(path, STAT_PATH_SIZE, "/proc/%u/stat", dom->pid) < 0) {
return -1;
}
} else {
if (snprintf(path, STAT_PATH_SIZE, "/proc/%lu/task/%lu/stat",
if (snprintf(path, STAT_PATH_SIZE, "/proc/%u/task/%u/stat",
dom->ppid, dom->pid) < 0) {
return -1;
}
......@@ -117,11 +117,13 @@ int get_proc_comm(struct domain *dom)
char path[STAT_PATH_SIZE];
int len;
if (snprintf(path, STAT_PATH_SIZE, "/proc/%lu/comm", dom->pid) < 0) {
if (snprintf(path, STAT_PATH_SIZE, "/proc/%u/comm", dom->pid) < 0) {
return -1;
}
len = read_file(dom->vmname, DOMAIN_NAME_MAX, path);
dom->vmname[len - 1] = '\0';
if (len > 1) {
dom->vmname[len - 1] = '\0';
}
return len;
}
......@@ -60,7 +60,7 @@ int get_vcpu_stat(struct domain *dom)
char pid[PID_STRING_SIZE];
FILE *fp = NULL;
if (snprintf(pid, PID_STRING_SIZE, "%lu", dom->pid) < 0) {
if (snprintf(pid, PID_STRING_SIZE, "%u", dom->pid) < 0) {
return -1;
}
fp = fopen(KVM_VCPU_STAT_PATH, "r");
......
......@@ -276,7 +276,7 @@ static void print_field(int high_light)
{
int x = 3; /* display x local */
int y = 4; /* display y local */
int attr_flag;
unsigned int attr_flag;
for (int i = 0; i < FD_END; i++) {
attr_flag = A_NORMAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册