Global fix sparse warnings for sspt module
authorAlexander Aksenov <a.aksenov@samsung.com>
Thu, 7 Feb 2013 16:23:05 +0000 (20:23 +0400)
committerAlexander Aksenov <a.aksenov@samsung.com>
Thu, 7 Feb 2013 16:23:05 +0000 (20:23 +0400)
12 files changed:
driver/probes_manager.c
driver/sspt/ip.c
driver/sspt/sspt.h
driver/sspt/sspt_debug.h
driver/sspt/sspt_file.c
driver/sspt/sspt_file.h
driver/sspt/sspt_page.c
driver/sspt/sspt_page.h
driver/sspt/sspt_procs.c
driver/sspt/sspt_procs.h
driver/storage.c
driver/us_proc_inst.c

index 647be79..55adc6e 100644 (file)
@@ -394,7 +394,7 @@ remove_probe (unsigned long addr)
        return result;
 }
 
-static DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL;
+DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL;
 
 unsigned long
 def_jprobe_event_pre_handler (kernel_probe_t * probe, struct pt_regs *regs)
index dd2b8bc..c6e59ce 100644 (file)
@@ -82,7 +82,7 @@ struct us_ip *copy_ip(const struct us_ip *ip)
 struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d)
 {
        struct us_ip *ip = create_ip(ip_d->offset);
-       set_ip_jp_handler(ip, ip_d->pre_handler, ip_d->jp_handler);
+       set_ip_jp_handler(ip, ip_d->pre_handler, (void *)ip_d->jp_handler);
 
        if (ip_d->flag_retprobe) {
                set_ip_rp_handler(ip, ip_d->rp_handler);
@@ -96,5 +96,5 @@ struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d)
 void sspt_set_ip_addr(struct us_ip *ip, const struct sspt_page *page, const struct sspt_file *file)
 {
        unsigned long addr = file->vm_start + page->offset + ip->offset;
-       ip->retprobe.kp.addr = ip->jprobe.kp.addr = addr;
+       ip->retprobe.kp.addr = ip->jprobe.kp.addr = (kprobe_opcode_t *)addr;
 }
index dbecd56..1092a6c 100644 (file)
@@ -37,7 +37,7 @@
 
 static void print_proc_probes(const struct sspt_procs *procs);
 
-static struct sspt_procs *get_file_probes(const inst_us_proc_t *task_inst_info)
+static inline struct sspt_procs *get_file_probes(const inst_us_proc_t *task_inst_info)
 {
        struct sspt_procs *procs = sspt_procs_create(task_inst_info->m_f_dentry, 0);
 
@@ -54,7 +54,7 @@ static struct sspt_procs *get_file_probes(const inst_us_proc_t *task_inst_info)
                        struct dentry *dentry = p_libs->m_f_dentry;
                        char *path = p_libs->path;
                        char *name = strrchr(path, '/');
-                       name = name ? ++name : path;
+                       name = name ? name + 1 : path;
 
                        for (k = 0; k < p_libs->ips_count; ++k) {
                                struct ip_data pd;
index 025efd1..1857568 100644 (file)
  *
  */
 
-static void print_jprobe(struct jprobe *jp)
+static inline void print_jprobe(struct jprobe *jp)
 {
-       printk("###         JP: entry=%x, pre_entry=%x\n",
-                       jp->entry, jp->pre_entry);
+       printk("###         JP: entry=%lx, pre_entry=%lx\n",
+                       (unsigned long)jp->entry, (unsigned long)jp->pre_entry);
 }
 
-static void print_retprobe(struct kretprobe *rp)
+static inline void print_retprobe(struct kretprobe *rp)
 {
-       printk("###         RP: handler=%x\n",
-                       rp->handler);
+       printk("###         RP: handler=%lx\n",
+                       (unsigned long)rp->handler);
 }
 
-static void print_page_probes(const struct sspt_page *page)
+static inline void print_page_probes(const struct sspt_page *page)
 {
        int i = 0;
        struct us_ip *ip;
 
-       printk("###     offset=%x\n", page->offset);
+       printk("###     offset=%lx\n", page->offset);
        list_for_each_entry(ip, &page->ip_list, list) {
 
-               printk("###       addr[%2d]=%x, J_addr=%x, R_addr=%x\n",
-                               i, ip->offset, ip->jprobe.kp.addr, ip->retprobe.kp.addr);
+               printk("###       addr[%2d]=%lx, J_addr=%lx, R_addr=%lx\n",
+                               i, (unsigned long)ip->offset, (unsigned long)ip->jprobe.kp.addr,
+                               (unsigned long)ip->retprobe.kp.addr);
                print_jprobe(&ip->jprobe);
                print_retprobe(&ip->retprobe);
                ++i;
        }
 }
 
-static void print_file_probes(const struct sspt_file *file)
+static inline void print_file_probes(const struct sspt_file *file)
 {
        int i;
        unsigned long table_size;
@@ -71,7 +72,7 @@ static void print_file_probes(const struct sspt_file *file)
        table_size = (1 << file->page_probes_hash_bits);
        name = (file->dentry) ? file->dentry->d_iname : NA;
 
-       printk("### print_file_probes: path=%s, d_iname=%s, table_size=%u, vm_start=%x\n",
+       printk("### print_file_probes: path=%s, d_iname=%s, table_size=%lu, vm_start=%lx\n",
                        file->name, name, table_size, file->vm_start);
 
        for (i = 0; i < table_size; ++i) {
@@ -82,7 +83,7 @@ static void print_file_probes(const struct sspt_file *file)
        }
 }
 
-static void print_proc_probes(const struct sspt_procs *procs)
+static inline void print_proc_probes(const struct sspt_procs *procs)
 {
        struct sspt_file *file;
 
@@ -93,7 +94,7 @@ static void print_proc_probes(const struct sspt_procs *procs)
        printk("### print_proc_probes\n");
 }
 
-static void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
+static inline void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
 {
        int i;
        int cnt = task_inst_info->libs_count;
@@ -112,7 +113,7 @@ static void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
                for (j = 0; j < cnt_j; ++j) {
                        us_proc_ip_t *ips = &lib->p_ips[j];
                        unsigned long offset = ips->offset;
-                       printk("###         offset=%x\n", offset);
+                       printk("###         offset=%lx\n", offset);
                }
        }
        printk("### BUNDLE PRINT  END  ###\n");
index 4fee7e6..08697d5 100644 (file)
@@ -36,7 +36,7 @@ static int calculation_hash_bits(int cnt)
        return bits;
 }
 
-struct sspt_file *sspt_file_create(const char *name, struct dentry *dentry, int page_cnt)
+struct sspt_file *sspt_file_create(char *name, struct dentry *dentry, int page_cnt)
 {
        struct sspt_file *obj = kmalloc(sizeof(*obj), GFP_ATOMIC);
 
@@ -82,7 +82,8 @@ void sspt_file_free(struct sspt_file *file)
 
 static void sspt_add_page(struct sspt_file *file, struct sspt_page *page)
 {
-       hlist_add_head(&page->hlist, &file->page_probes_table[hash_ptr(page->offset, file->page_probes_hash_bits)]);
+       hlist_add_head(&page->hlist, &file->page_probes_table[hash_ptr((void *)page->offset,
+                               file->page_probes_hash_bits)]);
 }
 
 struct sspt_file *sspt_file_copy(const struct sspt_file *file)
@@ -135,7 +136,7 @@ static struct sspt_page *sspt_find_page(struct sspt_file *file, unsigned long of
        struct hlist_head *head;
        struct sspt_page *page;
 
-       head = &file->page_probes_table[hash_ptr(offset, file->page_probes_hash_bits)];
+       head = &file->page_probes_table[hash_ptr((void *)offset, file->page_probes_hash_bits)];
        hlist_for_each_entry(page, node, head, hlist) {
                if (page->offset == offset) {
                        return page;
@@ -163,7 +164,7 @@ struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long pa
 
        if (file->vm_start > page || file->vm_end < page) {
                // TODO: or panic?!
-               printk("ERROR: file_p[vm_start..vm_end] <> page: file_p[vm_start=%x, vm_end=%x, path=%s, d_iname=%s] page=%x\n",
+               printk("ERROR: file_p[vm_start..vm_end] <> page: file_p[vm_start=%lx, vm_end=%lx, path=%s, d_iname=%s] page=%lx\n",
                                file->vm_start, file->vm_end, file->name, file->dentry->d_iname, page);
                return NULL;
        }
index bb1fca6..3d4d2e4 100644 (file)
@@ -42,7 +42,7 @@ struct sspt_file {
 };
 
 
-struct sspt_file *sspt_file_create(const char *name, struct dentry *dentry, int page_cnt);
+struct sspt_file *sspt_file_create(char *name, struct dentry *dentry, int page_cnt);
 struct sspt_file *sspt_file_copy(const struct sspt_file *file);
 void sspt_file_free(struct sspt_file *file);
 
index 62acabf..388b03d 100644 (file)
@@ -107,6 +107,6 @@ void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file)
 
        list_for_each_entry(ip, &page->ip_list, list) {
                addr = file->vm_start + page->offset + ip->offset;
-               ip->retprobe.kp.addr = ip->jprobe.kp.addr = addr;
+               ip->retprobe.kp.addr = ip->jprobe.kp.addr = (kprobe_opcode_t *)addr;
        }
 }
index 5d74e5f..26dabc5 100644 (file)
@@ -50,7 +50,7 @@ struct us_ip *sspt_find_ip(struct sspt_page *page, unsigned long offset);
 static inline void sspt_page_assert_install(const struct sspt_page *page)
 {
        if (page->install != 0) {
-               panic("already installed page %x\n", page->offset);
+               panic("already installed page %lx\n", page->offset);
        }
 }
 
index fb585f9..1b8e304 100644 (file)
@@ -84,7 +84,7 @@ static void sspt_procs_add_file(struct sspt_procs *procs, struct sspt_file *file
 }
 
 struct sspt_file *sspt_procs_find_file_or_new(struct sspt_procs *procs,
-               struct dentry *dentry, const char *name)
+               struct dentry *dentry, char *name)
 {
        struct sspt_file *file;
 
@@ -101,7 +101,7 @@ struct sspt_file *sspt_procs_find_file_or_new(struct sspt_procs *procs,
 }
 
 void sspt_procs_add_ip_data(struct sspt_procs *procs, struct dentry* dentry,
-               const char *name, struct ip_data *ip_d)
+               char *name, struct ip_data *ip_d)
 {
        struct sspt_file *file = sspt_procs_find_file_or_new(procs, dentry, name);
        sspt_file_add_ip(file, ip_d);
index aec87d1..5cd1015 100644 (file)
@@ -42,9 +42,9 @@ void sspt_procs_free(struct sspt_procs *procs);
 void sspt_procs_free_all(void);
 
 void sspt_procs_add_ip_data(struct sspt_procs *procs, struct dentry* dentry,
-               const char *name, struct ip_data *ip_d);
+               char *name, struct ip_data *ip_d);
 struct sspt_file *sspt_procs_find_file(struct sspt_procs *procs, struct dentry *dentry);
 struct sspt_file *sspt_procs_find_file_or_new(struct sspt_procs *procs,
-               struct dentry *dentry, const char *name);
+               struct dentry *dentry, char *name);
 
 #endif /* __SSPT_PROC__ */
index d85adf2..ebb4405 100644 (file)
@@ -27,6 +27,7 @@
 #include "handlers_core.h"
 #include "CProfile.h"
 #include "sspt/sspt.h"
+#include "sspt/sspt_debug.h"
 
 #define after_buffer ec_info.buffer_size
 
@@ -609,8 +610,6 @@ void unlink_bundle(void)
        us_proc_info.tgid = 0;
 }
 
-void print_inst_us_proc(const inst_us_proc_t *task_inst_info);
-
 extern struct dentry *dentry_by_path(const char *path);
 
 int link_bundle(void)
index 7d70ba1..4ff1b1a 100644 (file)
@@ -100,7 +100,7 @@ static inline int is_us_instrumentation(void)
        return !!us_proc_info.path;
 }
 
-struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
+static struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
 {
        struct sspt_procs *procs, *tmp;
 
@@ -122,12 +122,12 @@ struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
        return NULL;
 }
 
-void add_proc_probes(struct task_struct *task, struct sspt_procs *procs)
+static void add_proc_probes(struct task_struct *task, struct sspt_procs *procs)
 {
        list_add_tail(&procs->list, &proc_probes_list);
 }
 
-struct sspt_procs *get_proc_probes_by_task_or_new(struct task_struct *task)
+static struct sspt_procs *get_proc_probes_by_task_or_new(struct task_struct *task)
 {
        struct sspt_procs *procs = get_proc_probes_by_task(task);
        if (procs == NULL) {
@@ -231,7 +231,7 @@ static int find_task_by_path (const char *path, struct task_struct **p_task, str
        struct mm_struct *mm;
        struct dentry *dentry = dentry_by_path(path);
 
-       *p_task = 0;
+       *p_task = NULL;
 
        /* find corresponding dir entry, this is also check for valid path */
        // TODO: test - try to instrument process with non-existing path
@@ -296,218 +296,6 @@ static int find_task_by_path (const char *path, struct task_struct **p_task, str
        return 0;
 }
 
-
-static void us_vtp_event_pre_handler (us_proc_vtp_t * vtp, struct pt_regs *regs)
-{
-       __get_cpu_var(gpVtp) = vtp;
-       __get_cpu_var(gpCurVtpRegs) = regs;
-}
-
-static void us_vtp_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
-{
-       us_proc_vtp_t *vtp = __get_cpu_var(gpVtp);
-#if !defined(CONFIG_X86)
-       struct pt_regs *regs = __get_cpu_var(gpCurVtpRegs);
-#endif
-       char fmt[4];
-       unsigned long vaddr;
-       long ival;
-       char cval, *sval;
-       us_proc_vtp_data_t *vtp_data;
-unsigned long ll;
-       fmt[0] = 'p';
-       fmt[3] = 0;
-       fmt[2] = 's';
-
-       list_for_each_entry_rcu (vtp_data, &vtp->list, list) {
-               //              DPRINTF ("[%d]proc %s(%d): %lx", nCount++, current->comm, current->pid, vtp->addr);
-               fmt[1] = vtp_data->type;
-               if (vtp_data->reg == -1)
-                       vaddr = vtp_data->off;
-               else
-                       vaddr = ARCH_REG_VAL (regs, vtp_data->reg) + vtp_data->off;
-               //              DPRINTF ("VTP type '%c'", vtp_data->type);
-               switch (vtp_data->type)
-               {
-                       case 'd':
-                       case 'x':
-                       case 'p':
-                               if (read_proc_vm_atomic (current, vaddr, &ival, sizeof (ival)) < sizeof (ival))
-                                       EPRINTF ("failed to read vm of proc %s/%u addr %lu!", current->comm, current->pid, vaddr);
-                               else
-                                       pack_event_info (VTP_PROBE_ID, RECORD_ENTRY, fmt, vtp->jprobe.kp.addr, ival, vtp_data->name);
-                               break;
-                       case 'f':
-                               if (read_proc_vm_atomic (current, vaddr, &ival, sizeof (ival)) < sizeof (ival))
-                                       EPRINTF ("failed to read vm of proc %s/%u addr %lu!", current->comm, current->pid, vaddr);
-                               else
-                                       pack_event_info (VTP_PROBE_ID, RECORD_ENTRY, fmt, vtp->jprobe.kp.addr, ival, vtp_data->name);
-                               break;
-                       case 'c':
-                               if (read_proc_vm_atomic (current, vaddr, &cval, sizeof (cval)) < sizeof (cval))
-                                       EPRINTF ("failed to read vm of proc %s/%u addr %lu!", current->comm, current->pid, vaddr);
-                               else
-                                       pack_event_info (VTP_PROBE_ID, RECORD_ENTRY, fmt, vtp->jprobe.kp.addr, cval, vtp_data->name);
-                               break;
-                       case 's':
-                               if (current->active_mm) {
-                                       struct page *page;
-                                       struct vm_area_struct *vma;
-                                       void *maddr;
-                                       int len;
-                                       if (get_user_pages_atomic (current, current->active_mm, vaddr, 1, 0, 1, &page, &vma) <= 0) {
-                                               EPRINTF ("get_user_pages_atomic failed for proc %s/%u addr %lu!", current->comm, current->pid, vaddr);
-                                               break;
-                                       }
-                                       maddr = kmap_atomic (page, KM_USER0);
-                                       len = strlen (maddr + (vaddr & ~PAGE_MASK));
-                                       sval = kmalloc (len + 1, GFP_KERNEL);
-                                       if (!sval)
-                                               EPRINTF ("failed to alloc memory for string in proc %s/%u addr %lu!", current->comm, current->pid, vaddr);
-                                       else {
-                                               copy_from_user_page (vma, page, vaddr, sval, maddr + (vaddr & ~PAGE_MASK), len + 1);
-                                               pack_event_info (VTP_PROBE_ID, RECORD_ENTRY, fmt, vtp->jprobe.kp.addr, sval,  vtp_data->name);
-                                               kfree (sval);
-                                       }
-                                       kunmap_atomic (maddr, KM_USER0);
-                                       page_cache_release (page);
-                               }
-                               else
-                                       EPRINTF ("task %s/%u has no mm!", current->comm, current->pid);
-                               break;
-                       default:
-                               EPRINTF ("unknown variable type '%c'", vtp_data->type);
-               }
-       }
-       dbi_uprobe_return ();
-}
-
-static int install_mapped_ips (struct task_struct *task, inst_us_proc_t* task_inst_info, int atomic)
-{
-       struct vm_area_struct *vma;
-       int i, k, err;
-       unsigned long addr;
-       unsigned int old_ips_count, old_vtps_count;
-       struct task_struct *t;
-       struct mm_struct *mm;
-
-       mm = atomic ? task->active_mm : get_task_mm (task);
-       if (!mm) {
-               return task_inst_info->unres_ips_count + task_inst_info->unres_vtps_count;
-       }
-       old_ips_count = task_inst_info->unres_ips_count;
-       old_vtps_count = task_inst_info->unres_vtps_count;
-       if(!atomic)
-               down_read (&mm->mmap_sem);
-       vma = mm->mmap;
-       while (vma) {
-               // skip non-text section
-#ifndef __ANDROID
-               if (vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC) || !vma->vm_file || (vma->vm_flags & VM_ACCOUNT) ||
-                       !(vma->vm_flags & (VM_WRITE | VM_MAYWRITE)) ||
-                       !(vma->vm_flags & (VM_READ | VM_MAYREAD))) {
-#else // __ANDROID
-               if (vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC) || !vma->vm_file) {
-#endif // __ANDROID
-                       vma = vma->vm_next;
-                       continue;
-               }
-               /**
-                * After process was forked, some time it inherits parent process environment.
-                * We need to renew instrumentation when we detect that process gets own environment.
-                */
-               for (i = 0; i < task_inst_info->libs_count; i++) {
-//                     struct path tmp_path;
-//                     tmp_path.dentry = task_inst_info->p_libs[i].m_f_dentry;
-//                     tmp_path.mnt = task_inst_info->p_libs[i].m_vfs_mount;
-//                     char* p_path = d_path ( &tmp_path, path_buffer, 255 );
-//                     DPRINTF("f_dentry:%x m_f_dentry:%x path:%s", vma->vm_file->f_dentry,
-//                             task_inst_info->p_libs[i].m_f_dentry, p_path );
-
-                       //TODO: test - try to instrument non-existing libs
-                       if (vma->vm_file->f_dentry == task_inst_info->p_libs[i].m_f_dentry) {
-//                             DPRINTF("vm_flags:%x loaded:%x ips_count:%d vtps_count:%d",
-//                                             vma->vm_flags, task_inst_info->p_libs[i].loaded,
-//                                             task_inst_info->p_libs[i].ips_count, task_inst_info->p_libs[i].vtps_count );
-                               if (!task_inst_info->p_libs[i].loaded) {
-//                                     DPRINTF("!VM_EXECUTABLE && !loaded");
-                                       char *p;
-                                       int app_flag = (vma->vm_file->f_dentry == task_inst_info->m_f_dentry);
-                                       DPRINTF ("post dyn lib event %s/%s", current->comm, task_inst_info->p_libs[i].path);
-                                       // if we installed something, post library info for those IPs
-                                       p = strrchr(task_inst_info->p_libs[i].path, '/');
-                                       if(!p)
-                                               p = task_inst_info->p_libs[i].path;
-                                       else
-                                               p++;
-                                       task_inst_info->p_libs[i].loaded = 1;
-                                       task_inst_info->p_libs[i].vma_start = vma->vm_start;
-                                       task_inst_info->p_libs[i].vma_end = vma->vm_end;
-                                       task_inst_info->p_libs[i].vma_flag = vma->vm_flags;
-                                       pack_event_info (DYN_LIB_PROBE_ID, RECORD_ENTRY, "dspdd",
-                                                       task->tgid, p, vma->vm_start, vma->vm_end-vma->vm_start, app_flag);
-                               }
-                               for (k = 0; k < task_inst_info->p_libs[i].ips_count; k++) {
-                                       DPRINTF("ips_count current:%d", k);
-                                       if (!task_inst_info->p_libs[i].p_ips[k].installed) {
-                                               DPRINTF("!installed");
-                                               addr = task_inst_info->p_libs[i].p_ips[k].offset;
-                                               addr += vma->vm_start;
-                                               if (page_present (mm, addr)) {
-                                                       DPRINTF ("pid %d, %s sym is loaded at %lx/%lx.",
-                                                               task->pid, task_inst_info->p_libs[i].path,
-                                                               task_inst_info->p_libs[i].p_ips[k].offset, addr);
-                                                       task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr = (kprobe_opcode_t *) addr;
-                                                       task_inst_info->p_libs[i].p_ips[k].retprobe.kp.addr = (kprobe_opcode_t *) addr;
-                                                       task_inst_info->unres_ips_count--;
-                                                       err = register_usprobe(task, &task_inst_info->p_libs[i].p_ips[k], atomic);
-                                                       if (err != 0) {
-                                                               DPRINTF ("failed to install IP at %lx/%p. Error %d!",
-                                                                       task_inst_info->p_libs[i].p_ips[k].offset,
-                                                                       task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr, err);
-                                                       }
-                                               }
-                                       }
-                               }
-                               for (k = 0; k < task_inst_info->p_libs[i].vtps_count; k++) {
-                                       DPRINTF("vtps_count current:%d", k);
-                                       if (!task_inst_info->p_libs[i].p_vtps[k].installed) {
-                                               DPRINTF("!installed");
-                                               addr = task_inst_info->p_libs[i].p_vtps[k].addr;
-                                               if (!(vma->vm_flags & VM_EXECUTABLE))
-                                                       addr += vma->vm_start;
-                                               if (page_present (mm, addr)) {
-                                                       DPRINTF ("pid %d, %s sym is loaded at %lx/%lx.",
-                                                               task->pid, task_inst_info->p_libs[i].path,
-                                                               task_inst_info->p_libs[i].p_ips[k].offset, addr);
-                                                       task_inst_info->p_libs[i].p_vtps[k].jprobe.kp.tgid = task_inst_info->tgid;
-                                                       task_inst_info->p_libs[i].p_vtps[k].jprobe.kp.addr = (kprobe_opcode_t *) addr;
-                                                       task_inst_info->p_libs[i].p_vtps[k].jprobe.entry = (kprobe_opcode_t *) us_vtp_event_handler;
-                                                       task_inst_info->p_libs[i].p_vtps[k].jprobe.pre_entry = (kprobe_pre_entry_handler_t) us_vtp_event_pre_handler;
-                                                       task_inst_info->p_libs[i].p_vtps[k].jprobe.priv_arg = &task_inst_info->p_libs[i].p_vtps[k];
-                                                       task_inst_info->p_libs[i].p_vtps[k].installed = 1;
-                                                       task_inst_info->unres_vtps_count--;
-                                                       err = dbi_register_ujprobe(task, &task_inst_info->p_libs[i].p_vtps[k].jprobe, atomic);
-                                                       if ( err != 0 ) {
-                                                               EPRINTF ("failed to install VTP at %p. Error %d!",
-                                                                               task_inst_info->p_libs[i].p_vtps[k].jprobe.kp.addr, err);
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               vma = vma->vm_next;
-       }
-
-       if (!atomic) {
-               up_read (&mm->mmap_sem);
-               mmput (mm);
-       }
-       return task_inst_info->unres_ips_count + task_inst_info->unres_vtps_count;
-}
-
 static void set_mapping_file(struct sspt_file *file,
                const struct sspt_procs *procs,
                const struct task_struct *task,
@@ -575,45 +363,6 @@ int install_otg_ip(unsigned long addr,
 }
 EXPORT_SYMBOL_GPL(install_otg_ip);
 
-
-static int uninstall_mapped_ips (struct task_struct *task,  inst_us_proc_t* task_inst_info, int atomic)
-{
-       int i, k, err;
-
-       for (i = 0; i < task_inst_info->libs_count; i++)
-       {
-               DPRINTF ("clear lib %s.", task_inst_info->p_libs[i].path);
-               for (k = 0; k < task_inst_info->p_libs[i].ips_count; k++)
-               {
-                       if (task_inst_info->p_libs[i].p_ips[k].installed)
-                       {
-                               DPRINTF ("remove IP at %p.", task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr);
-                               err = unregister_usprobe (task, &task_inst_info->p_libs[i].p_ips[k], atomic, 0);
-                               if (err != 0)
-                               {
-                                       EPRINTF ("failed to uninstall IP at %p. Error %d!", task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr, err);
-                                       continue;
-                               }
-                               task_inst_info->unres_ips_count++;
-                       }
-               }
-               for (k = 0; k < task_inst_info->p_libs[i].vtps_count; k++)
-               {
-                       if (task_inst_info->p_libs[i].p_vtps[k].installed)
-                       {
-                               dbi_unregister_ujprobe (task, &task_inst_info->p_libs[i].p_vtps[k].jprobe, atomic);
-                               task_inst_info->unres_vtps_count++;
-                               task_inst_info->p_libs[i].p_vtps[k].installed = 0;
-                       }
-               }
-               task_inst_info->p_libs[i].loaded = 0;
-       }
-
-       DPRINTF ("Ures IPs  %d.", task_inst_info->unres_ips_count);
-       DPRINTF ("Ures VTPs %d.", task_inst_info->unres_vtps_count);
-       return 0;
-}
-
 static int uninstall_kernel_probe (unsigned long addr, int uflag, int kflag, kernel_probe_t ** pprobe)
 {
        kernel_probe_t *probe = NULL;
@@ -650,8 +399,7 @@ static int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs
 int deinst_usr_space_proc (void)
 {
        int iRet = 0, found = 0;
-       struct task_struct *task = 0;
-       inst_us_proc_t *task_inst_info = NULL;
+       struct task_struct *task = NULL;
 
        if (!is_us_instrumentation()) {
                return 0;
@@ -772,7 +520,7 @@ static void install_proc_probes(struct task_struct *task, struct sspt_procs *pro
 int inst_usr_space_proc (void)
 {
        int ret, i;
-       struct task_struct *task = 0;
+       struct task_struct *task = NULL;
 
        if (!is_us_instrumentation()) {
                return 0;
@@ -923,7 +671,7 @@ void print_vma(struct mm_struct *mm);
 
 static int register_us_page_probe(struct sspt_page *page,
                const struct sspt_file *file,
-               const struct task_struct *task)
+               struct task_struct *task)
 {
        int err = 0;
        struct us_ip *ip;
@@ -931,10 +679,10 @@ static int register_us_page_probe(struct sspt_page *page,
        spin_lock(&page->lock);
 
        if (sspt_page_is_install(page)) {
-               printk("page %x in %s task[tgid=%u, pid=%u] already installed\n",
+               printk("page %lx in %s task[tgid=%u, pid=%u] already installed\n",
                                page->offset, file->dentry->d_iname, task->tgid, task->pid);
                print_vma(task->mm);
-               return 0;
+               goto unlock;
        }
 
        sspt_page_assert_install(page);
@@ -944,18 +692,19 @@ static int register_us_page_probe(struct sspt_page *page,
                err = register_usprobe_my(task, ip);
                if (err != 0) {
                        //TODO: ERROR
-                       return err;
+                       goto unlock;
                }
        }
 
        sspt_page_installed(page);
 
+unlock:
        spin_unlock(&page->lock);
 
-       return 0;
+       return err;
 }
 
-static int unregister_us_page_probe(const struct task_struct *task,
+static int unregister_us_page_probe(struct task_struct *task,
                struct sspt_page *page, enum US_FLAGS flag)
 {
        int err = 0;
@@ -996,7 +745,7 @@ static void install_page_probes(unsigned long page_addr, struct task_struct *tas
                struct dentry *dentry = vma->vm_file->f_dentry;
                struct sspt_file *file = sspt_procs_find_file(procs, dentry);
                if (file) {
-                       struct page_probes *page;
+                       struct sspt_page *page;
                        if (!file->loaded) {
                                set_mapping_file(file, procs, task, vma);
                                file->loaded = 1;
@@ -1103,7 +852,7 @@ static int unregister_us_file_probes(struct task_struct *task, struct sspt_file
 
 static int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs *procs, enum US_FLAGS flag)
 {
-       int err;
+       int err = 0;
        struct sspt_file *file;
 
        list_for_each_entry_rcu(file, &procs->file_list, list) {
@@ -1117,7 +866,7 @@ static int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs
        return err;
 }
 
-static pid_t find_proc_by_task(const struct task_struct *task, const struct dentry *dentry)
+static pid_t find_proc_by_task(const struct task_struct *task, struct dentry *dentry)
 {
        struct vm_area_struct *vma;
        struct mm_struct *mm = task->active_mm;
@@ -1150,7 +899,6 @@ void do_page_fault_ret_pre_code (void)
 {
        struct task_struct *task = current->group_leader;
        struct mm_struct *mm = task->mm;
-       struct vm_area_struct *vma = 0;
        struct sspt_procs *procs = NULL;
        /*
         * Because process threads have same address space
@@ -1229,11 +977,6 @@ void do_exit_probe_pre_code (void)
 }
 EXPORT_SYMBOL_GPL(do_exit_probe_pre_code);
 
-int check_vma_area(struct vm_area_struct *vma, unsigned long start, unsigned long end)
-{
-       return (vma->vm_start >= start && vma->vm_end <= end);
-}
-
 void print_vma(struct mm_struct *mm)
 {
        struct vm_area_struct *vma;
@@ -1244,9 +987,9 @@ void print_vma(struct mm_struct *mm)
                char *x = vma->vm_flags & VM_EXEC ? "x" : "-";
                char *r = vma->vm_flags & VM_READ ? "r" : "-";
                char *w = vma->vm_flags & VM_WRITE ? "w" : "-";
-               char *name = vma->vm_file ? vma->vm_file->f_dentry->d_iname : "N/A";
+               char *name = vma->vm_file ? (char *)vma->vm_file->f_dentry->d_iname : "N/A";
 
-               printk("### [%8x..%8x] %s%s%s pgoff=\'%8u\' %s\n",
+               printk("### [%8lx..%8lx] %s%s%s pgoff=\'%8lu\' %s\n",
                                vma->vm_start, vma->vm_end, x, r, w, vma->vm_pgoff, name);
        }
        printk("### print_vma:  END\n");
@@ -1256,7 +999,6 @@ static int remove_unmap_probes(struct task_struct *task, struct sspt_procs *proc
 {
        struct mm_struct *mm = task->mm;
        struct vm_area_struct *vma;
-       unsigned long end, pointer, step;
 
        if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE - start) {
                return -EINVAL;
@@ -1318,7 +1060,7 @@ void do_munmap_probe_pre_code(struct mm_struct *mm, unsigned long start, size_t
 
        if (procs) {
                if (remove_unmap_probes(task, procs, start, len)) {
-                       printk("ERROR do_munmap: start=%x, len=%x\n", start, len);
+                       printk("ERROR do_munmap: start=%lx, len=%x\n", start, len);
                }
        }
 }
@@ -1424,7 +1166,7 @@ void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned lon
        dbi_uprobe_return ();
 }
 
-void send_plt(struct us_ip *ip)
+static void send_plt(struct us_ip *ip)
 {
        unsigned long addr = (unsigned long)ip->jprobe.kp.addr;
        struct vm_area_struct *vma = find_vma(current->mm, addr);
@@ -1437,7 +1179,7 @@ void send_plt(struct us_ip *ip)
                                ip->got_addr + vma->vm_start;
 
                if (!read_proc_vm_atomic(current, real_got, &real_addr, sizeof(real_addr))) {
-                       printk("Failed to read got %p at memory address %p!\n", ip->got_addr, real_got);
+                       printk("Failed to read got %lx at memory address %lx!\n", ip->got_addr, real_got);
                        return;
                }
 
@@ -1445,7 +1187,7 @@ void send_plt(struct us_ip *ip)
                if (vma && (vma->vm_start <= real_addr) && (vma->vm_end > real_addr)) {
                        name = vma->vm_file ? vma->vm_file->f_dentry->d_iname : NULL;
                } else {
-                       printk("Failed to get vma, includes %x address\n", real_addr);
+                       printk("Failed to get vma, includes %lx address\n", real_addr);
                        return;
                }