[FIX] warnings in swap_us_manager
authorAnastasia Lyupa <a.lyupa@samsung.com>
Wed, 6 Nov 2013 08:25:02 +0000 (12:25 +0400)
committerAnastasia Lyupa <a.lyupa@samsung.com>
Thu, 7 Nov 2013 09:05:32 +0000 (13:05 +0400)
build it with -Werror

Change-Id: Ieb752474cf0cb56ebbba35c5fc38209d558ef257
Signed-off-by: Anastasia Lyupa <a.lyupa@samsung.com>
14 files changed:
build.sh
us_manager/helper.c
us_manager/img/img_file.c
us_manager/img/img_ip.c
us_manager/pf/pf_group.c
us_manager/pf/pf_group.h
us_manager/pf/proc_filters.h
us_manager/sspt/ip.c
us_manager/sspt/sspt.h
us_manager/sspt/sspt_debug.h
us_manager/sspt/sspt_file.c
us_manager/sspt/sspt_file.h
us_manager/sspt/sspt_page.c
us_manager/us_slot_manager.c

index 0f876aa..12cdfad 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -72,7 +72,7 @@ make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${uprobe_dir
 
 us_manager_module_name=swap_us_manager.ko
 make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${us_manager_dir} \
-       extra_cflags="-I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${ksyms_dir}" \
+       extra_cflags="-Werror -I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${ksyms_dir}" \
        modules || exit 1
 
 ks_features_module_name=swap_ks_features.ko
index 10b963c..fb61bb3 100644 (file)
@@ -136,7 +136,6 @@ static struct kretprobe cp_kretprobe = {
 /* Detects when target process removes IPs. */
 static int mr_pre_handler(struct kprobe *p, struct pt_regs *regs)
 {
-       struct sspt_proc *proc = NULL;
        struct task_struct *task;
 
 #if defined(CONFIG_X86)
index 4edf984..e4d05c6 100644 (file)
@@ -90,7 +90,7 @@ int img_file_del_ip(struct img_file *file, unsigned long addr)
 
        ip = find_img_ip(file, addr);
        if (ip == NULL) {
-               printk("Warning: no ip found in img, addr = %p\n", addr);
+               printk("Warning: no ip found in img, addr = %lx\n", addr);
                return -EINVAL;
        }
 
index 224627a..13258b0 100644 (file)
@@ -52,6 +52,6 @@ void free_img_ip(struct img_ip *ip)
 /* debug */
 void img_ip_print(struct img_ip *ip)
 {
-       printk("###            addr=8%x, args=%s\n", ip->addr, ip->args);
+       printk("###            addr=8%lx, args=%s\n", ip->addr, ip->args);
 }
 /* debug */
index fe9e273..841116a 100644 (file)
@@ -255,7 +255,7 @@ void uninstall_proc(struct sspt_proc *proc)
 {
        struct task_struct *task = proc->task;
        struct pf_group *pfg;
-       struct pls_struct *pls;
+       struct pl_struct *pls;
        int i;
 
        list_for_each_entry(pfg, &pfg_list, list) {
@@ -284,7 +284,7 @@ void uninstall_proc(struct sspt_proc *proc)
 
 void call_mm_release(struct task_struct *task)
 {
-       struct sspt_struct *proc;
+       struct sspt_proc *proc;
 
        proc = sspt_proc_get_by_task(task);
        if (proc)
@@ -298,8 +298,6 @@ void uninstall_page(unsigned long addr)
 
 void install_all(void)
 {
-       struct pf_group *pfg;
-       struct sspt_proc *proc;
        struct task_struct *task;
        int tmp_oops_in_progress;
 
@@ -322,10 +320,9 @@ void install_all(void)
 static void clean_pfg(void)
 {
        struct pf_group *pfg, *n;
-       struct proc_filter *filter;
 
        list_for_each_entry_safe(pfg, n, &pfg_list, list) {
-               list_del(&pfg->list);
+               del_pfg_by_list(pfg);
                free_pfg(pfg);
        }
 }
index 05f8fe1..377b59b 100644 (file)
@@ -30,6 +30,7 @@
 
 struct dentry;
 struct pf_group;
+struct sspt_proc;
 
 struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv);
 struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv);
index 94673be..2857419 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/types.h>
 
+struct dentry;
 struct task_struct;
 
 struct proc_filter {
index 928fc06..89f5a59 100644 (file)
@@ -50,7 +50,7 @@ static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs)
        if (rp && get_quiet() == QT_OFF) {
                struct us_ip *ip = container_of(rp, struct us_ip, retprobe);
                unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr;
-               unsigned long ret_addr = ri->ret_addr;
+               unsigned long ret_addr = (unsigned long)ri->ret_addr;
 
 #if defined(CONFIG_ARM)
                addr = ip->offset & 0x01 ? addr | 0x01 : addr;
@@ -64,18 +64,25 @@ static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs)
 
 struct us_ip *create_ip(unsigned long offset, const char *args)
 {
-       struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
-       memset(ip, 0, sizeof(*ip));
+       size_t len = strlen(args) + 1;
+       struct us_ip *ip = kmalloc(sizeof(*ip) + len, GFP_ATOMIC);
 
-       INIT_LIST_HEAD(&ip->list);
-       ip->offset = offset;
+       if (ip != NULL) {
+               memset(ip, 0, sizeof(*ip));
 
-       /* TODO: or copy args?! */
-       ip->args = args;
+               INIT_LIST_HEAD(&ip->list);
+               ip->offset = offset;
+               ip->args = (char *)ip + sizeof(*ip);
 
-       /* retprobe */
-       ip->retprobe.handler = ret_handler;
-       ip->retprobe.entry_handler = entry_handler;
+               /* copy args */
+               memcpy(ip->args, args, len);
+
+               /* retprobe */
+               ip->retprobe.handler = ret_handler;
+               ip->retprobe.entry_handler = entry_handler;
+       } else {
+               printk("Cannot kmalloc in create_ip function!\n");
+       }
 
        return ip;
 }
index 7b527bc..7367f8a 100644 (file)
@@ -37,7 +37,7 @@
 #include <pf/pf_group.h>
 
 
-static int check_vma(struct vm_area_struct *vma)
+static inline int check_vma(struct vm_area_struct *vma)
 {
        return vma->vm_file &&
               !(vma->vm_pgoff != 0 ||
@@ -57,11 +57,11 @@ static inline int sspt_register_usprobe(struct us_ip *ip)
        if (ret) {
                struct sspt_file *file = ip->page->file;
                char *name = file->dentry->d_iname;
-               unsigned long addr =ip->retprobe.up.kp.addr;
+               unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr;
                unsigned long offset = addr - file->vm_start;
 
-               printk("dbi_register_uretprobe() failure %d (%s:%x|%x)\n",
-                      ret, name, offset, ip->retprobe.up.kp.opcode);
+               printk("dbi_register_uretprobe() failure %d (%s:%lx|%lx)\n",
+                      ret, name, offset, (unsigned long)ip->retprobe.up.kp.opcode);
        }
 
        return ret;
index e1832cf..5e5b8f3 100644 (file)
@@ -39,7 +39,7 @@ static inline void print_retprobe(struct uretprobe *rp)
                        (unsigned long)rp->handler);
 }
 
-static inline print_ip(struct us_ip *ip, int i)
+static inline void print_ip(struct us_ip *ip, int i)
 {
        printk("###       addr[%2d]=%lx, R_addr=%lx\n",
                                i, (unsigned long)ip->offset,
index ffcab3d..a82e251 100644 (file)
@@ -234,8 +234,6 @@ int sspt_file_uninstall(struct sspt_file *file, struct task_struct *task, enum U
 
 void sspt_file_set_mapping(struct sspt_file *file, struct vm_area_struct *vma)
 {
-       struct task_struct *task = file->proc->task;
-
        file->vm_start = vma->vm_start;
        file->vm_end = vma->vm_end;
 
index dbc1d08..2c19e1d 100644 (file)
@@ -28,6 +28,7 @@
 #include "ip.h"
 #include <linux/types.h>
 
+enum US_FLAGS;
 struct vm_area_struct;
 
 struct sspt_file {
index d90484d..6dc350f 100644 (file)
@@ -172,7 +172,6 @@ int sspt_unregister_page(struct sspt_page *page,
 
        spin_lock(&page->lock);
 
-splice_and_unlock:
        list_splice(&ip_list_tmp, head);
        spin_unlock(&page->lock);
 
index c45b642..cd8ddfd 100644 (file)
@@ -77,8 +77,6 @@ static void *sm_alloc_us(struct slot_manager *sm)
 
 static void sm_free_us(struct slot_manager *sm, void *ptr)
 {
-       struct task_struct *task = sm->data;
-
        /*
         * E. G.: This code provides kernel dump because of rescheduling while atomic.
         * As workaround, this code was commented. In this case we will have memory leaks
@@ -87,6 +85,8 @@ static void sm_free_us(struct slot_manager *sm, void *ptr)
         * for improving supportability and performance.
         */
 #if 0
+       struct task_struct *task = sm->data;
+
        mm = get_task_mm(task);
        if (mm) {
                down_write(&mm->mmap_sem);