[CLEAN] remove unused code 16/14616/7
authorNikita Kalyazin <nkalyazin@gmail.com>
Wed, 1 Jan 2014 19:19:13 +0000 (23:19 +0400)
committerNikita Kalyazin <nkalyazin@gmail.com>
Sat, 18 Jan 2014 10:59:41 +0000 (14:59 +0400)
Change-Id: Iee93b03dd870ba4ecb9fe78ca7998650e094efc1
Signed-off-by: Nikita Kalyazin <nkalyazin@gmail.com>
daemon/da_inst.c
daemon/da_protocol.c
daemon/da_protocol_inst.h
daemon/sys_stat.c
daemon/utils.c

index d0dda0a89fc069ca46f1bf42ab5a724f4d9adb7a..a107094ec1a152a73b2350a3d6c2d34696397927 100644 (file)
@@ -42,52 +42,6 @@ char *packed_app_list = NULL;
 char *packed_lib_list = NULL;
 
 uint32_t libs_count;
-// ------------------ prints --------------
-void print_probe_debug(struct probe_list_t *p)
-{
-       LOGI("     size<%d> <0x%016llX, %s> <p=0x%08lX c=0x%08lX n=0x%08lX>\n",
-               p->size,
-               p->func->func_addr,
-               p->func->args,
-               (long unsigned int)p->prev,
-               (long unsigned int)p,
-               (long unsigned int)p->next
-               );
-}
-
-void print_probe_inst_list(struct probe_list_t *list)
-{
-       struct probe_list_t *p;
-
-       for (p = list; p != NULL; p = p->next)
-               print_probe_debug(p);
-}
-
-void print_lib_inst_list(struct lib_list_t *list)
-{
-       struct lib_list_t *p = list;
-
-       for (p = list; p != NULL; p = p->next) {
-               LOGI("lib <%s> size<%d> h0x%08lX\n",
-                       p->lib->bin_path,
-                       p->size,
-                       (long unsigned int)p->hash);
-               print_probe_inst_list(p->list);
-       }
-}
-
-void print_app_inst_list(struct app_list_t *list)
-{
-       struct app_list_t *p;
-       for (p = list; p != NULL; p = p->next) {
-               LOGI("app <%s> size<%d> h0x%08lX\n",
-                       p->app->exe_path,
-                       p->size,
-                       (long unsigned int)p->hash);
-               print_probe_inst_list(p->list);
-       }
-}
-
 
 //----------------------------------- lists ----------------------------------
 
@@ -356,15 +310,6 @@ static int cmp_libs(struct data_list_t *el_1, struct data_list_t *el_2)
                        ) == 0);
 }
 
-// this function for future use
-static int cmp_apps(struct data_list_t *el_1, struct data_list_t *el_2)
-{
-       return (strcmp(
-                       ((struct app_list_t *)el_1)->app->exe_path,
-                       ((struct app_list_t *)el_2)->app->exe_path
-                       ) == 0);
-}
-
 ///////////////////////////////////////////////////////////////////////////
 // function removes from new list all probes which are already installed
 //
@@ -562,8 +507,6 @@ static int generate_msg(struct msg_t **msg, struct lib_list_t *lib_list, struct
                 apps_count = 0;
        char     *p = NULL;
 
-
-       // print_lib_inst_list(lib_list);
        packed_lib_list = pack_lib_list_to_array(lib_list, &libs_size, &libs_count);
        // print_buf(packed_lib_list, libs_size, "LIBS");
 
@@ -633,7 +576,7 @@ int msg_start(struct msg_buf_t *data, struct user_space_inst_t *us_inst,
                LOGE("parse app inst\n");
                return 1;
        }
-       // print_app_inst_list(app_inst_list);
+
        generate_msg(msg, us_inst->lib_inst_list, us_inst->app_inst_list);
 
        if (*msg != NULL) {
index 44fb4dd58922f6085592ee5e07e9e2cc89aaa078..f850101bebcfdb6d91bf40105ddb32123b365010 100644 (file)
@@ -62,7 +62,6 @@ static void inline free_msg(struct msg_t *msg)
 
 struct prof_session_t prof_session;
 
-static void print_app_info(struct app_info_t *app_info);
 static void print_conf(struct conf_t *conf);
 //DEBUG FUNCTIONS
 #define dstr(x) #x
@@ -278,53 +277,6 @@ int parse_int64(struct msg_buf_t *msg, uint64_t *val)
        return 1;
 }
 
-static void strip_args(const char *cmd, char *path)
-{
-       char *bin_end = strchr(cmd, ' ');
-
-       if (!bin_end) {
-               strcpy(path, cmd);
-       } else {
-               size_t binname_len = bin_end - cmd;
-               memcpy(path, cmd, binname_len);
-               path[binname_len] = '\0';
-       }
-}
-
-static int parse_app_info(struct msg_buf_t *msg,
-                              struct app_info_t *app_info)
-{
-       char bin_path[MAX_FILENAME];
-
-       //Application type
-       parse_deb("parse_app_info\n");
-       if (!parse_int32(msg, &app_info->app_type) ||
-               !check_app_type(app_info->app_type))
-       {
-               LOGE("app type error\n");
-               return 0;
-       }
-       //Application ID
-       if (!parse_string(msg, &app_info->app_id) ||
-               !check_app_id(app_info->app_type, app_info->app_id))
-       {
-               LOGE("app id parsing error\n");
-               return 0;
-       }
-       //Applicaion exe path
-       if (!parse_string(msg, &app_info->exe_path)) {
-               LOGE("app info parsing error\n");
-               return 0;
-       }
-       strip_args(app_info->exe_path, bin_path);
-       if (!check_exec_path(bin_path)) {
-               LOGE("app info parsing error\n");
-               return 0;
-       }
-//     print_app_info(app_info);
-       return 1;
-}
-
 static int parse_conf(struct msg_buf_t *msg, struct conf_t *conf)
 {
 
@@ -473,13 +425,6 @@ int parse_replay_event_seq(struct msg_buf_t *msg,
 
 //*REPLAY EVENT PARSE
 
-int get_sys_mem_size(uint32_t *sys_mem_size){
-       struct sysinfo info;
-       sysinfo(&info);
-       *sys_mem_size = info.totalram;
-       return 0;
-}
-
 static int parse_msg_config(struct msg_buf_t *msg_payload,
                              struct conf_t *conf)
 {
@@ -492,18 +437,6 @@ static int parse_msg_config(struct msg_buf_t *msg_payload,
        return 1;
 }
 
-static int parse_msg_binary_info(struct msg_buf_t *msg_payload,
-                             struct app_info_t *app_info)
-{
-       if (!parse_app_info(msg_payload, app_info)) {
-               LOGE("app info parsing error\n");
-               return 0;
-       }
-
-       print_app_info(app_info);
-       return 1;
-}
-
 static void init_parse_control(struct msg_buf_t *buf, struct msg_t *msg)
 {
        buf->payload = msg->payload;
@@ -512,25 +445,11 @@ static void init_parse_control(struct msg_buf_t *buf, struct msg_t *msg)
        buf->cur_pos = msg->payload;
 }
 
-static void reset_app_info(struct app_info_t *app_info)
-{
-       if (app_info->app_id != NULL)
-               free(app_info->app_id);
-       if (app_info->exe_path != NULL)
-               free(app_info->exe_path);
-       memset(app_info, 0, sizeof(*app_info));
-}
-
 static void reset_target_info(struct target_info_t *target_info)
 {
        return;
 }
 
-static void reset_conf(struct conf_t *conf)
-{
-       memset(conf, 0, sizeof(*conf));
-}
-
 static void running_status_on(struct prof_session_t *prof_session)
 {
        prof_session->running_status = 1;
@@ -553,19 +472,6 @@ static void reset_app_inst(struct user_space_inst_t *us_inst)
        us_inst->app_inst_list = NULL;
 }
 
-static void reset_lib_inst(struct user_space_inst_t *us_inst)
-{
-       free_data_list((struct data_list_t **)&us_inst->lib_inst_list);
-       us_inst->lib_num = 0;
-       us_inst->lib_inst_list = NULL;
-}
-
-static void reset_user_space_inst(struct user_space_inst_t *us_inst)
-{
-       reset_app_inst(us_inst);
-       reset_lib_inst(us_inst);
-}
-
 void reset_system_info(struct system_info_t *sys_info)
 {
        if (sys_info->thread_load)
@@ -584,50 +490,6 @@ void init_prof_session(struct prof_session_t *prof_session)
        memset(prof_session, 0, sizeof(*prof_session));
 }
 
-static void reset_prof_session(struct prof_session_t *prof_session)
-{
-       reset_conf(&prof_session->conf);
-       reset_user_space_inst(&prof_session->user_space_inst);
-       reset_replay_event_seq(&prof_session->replay_event_seq);
-       running_status_off(prof_session);
-}
-
-static struct msg_t *gen_binary_info_reply(struct app_info_t *app_info)
-{
-       uint32_t binary_type = get_binary_type(app_info->exe_path);
-       char binary_path[PATH_MAX];
-       struct msg_t *msg;
-       char *p = NULL;
-       uint32_t ret_id = ERR_NO;
-
-       get_build_dir(binary_path, app_info->exe_path);
-
-       if (binary_type == BINARY_TYPE_UNKNOWN) {
-               LOGE("Binary is neither relocatable, nor executable\n");
-               return NULL;
-       }
-
-       msg = malloc(sizeof(*msg) +
-                             sizeof(ret_id) +
-                             sizeof(binary_type) +
-                             strlen(binary_path) + 1);
-       if (!msg) {
-               LOGE("Cannot alloc bin info msg\n");
-               return NULL;
-       }
-
-       msg->id = NMSG_BINARY_INFO_ACK;
-       p = msg->payload;
-
-       pack_int32(p, ret_id);
-       pack_int32(p, binary_type);
-       pack_str(p, binary_path);
-
-       msg->len = p - msg->payload;
-
-       return msg;
-}
-
 static size_t str_array_getsize(const char **strings, size_t len)
 {
        /*!
@@ -1177,19 +1039,6 @@ send_ack:
 
 // testing
 
-static void print_app_info(struct app_info_t *app_info)
-{
-       LOGI("application info=\n");
-       LOGI("\tapp_type=<%d><0x%04X>\n"
-                "\tapp_id=<%s>\n"
-                "\texe_path=<%s>\n",
-                app_info->app_type,
-                app_info->app_type,
-                app_info->app_id,
-                app_info->exe_path
-       );
-}
-
 static void print_conf(struct conf_t *conf)
 {
        char buf[1024];
@@ -1222,20 +1071,3 @@ void print_replay_event(struct replay_event_t *ev, uint32_t num, char *tab)
                ev->ev.value//s32
                );
 }
-
-void print_replay_event_seq(struct replay_event_seq_t *event_seq)
-{
-       uint32_t i = 0;
-       char *tab = "\t";
-
-       LOGI( "%senabled=0x%08X; "\
-               "time_start=0x%08X %08X; "\
-               "count=0x%08X\n",
-               tab,event_seq->enabled,
-               (unsigned int)event_seq->tv.tv_sec,
-               (unsigned int)event_seq->tv.tv_usec,
-               event_seq->event_num);
-       for (i=0;i<event_seq->event_num;i++)
-               print_replay_event(&event_seq->events[i], i+1, tab);
-
-}
index 2d8ec18524ffa7d241e26d070e4eea7fa4119f3c..aaebbce699c1a1f1ff1717e60cca01f25944d276 100644 (file)
 #ifndef __DA_PROTOCOL_INST__
 #define __DA_PROTOCOL_INST__
 
-int parse_us_inst_func(struct msg_buf_t *msg, struct probe_list_t **dest);
-
-int parse_func_inst_list(struct msg_buf_t *msg,
-                               struct data_list_t *dest);
-
-int parse_inst_lib(struct msg_buf_t *msg, struct lib_list_t **dest);
-
 int parse_lib_inst_list(struct msg_buf_t *msg,
                        uint32_t *num,
                        struct lib_list_t **lib_list);
index 78fb2c42500c2e6eaec1f33b768851fd1142ef54..5cd5e3f174ed840075d8faa7638e113083002e84 100644 (file)
@@ -1311,155 +1311,6 @@ static int update_thread_data(int pid)
 // overall information getter functions
 // ========================================================================
 
-// this code is not necessary anymore
-/*
-static void get_app_info(const char* binary_path, char* width,
-               char* height, char* theme, char* version,
-               char* scale, char* removable,
-               char* comment)
-{
-       int fd = 0;
-       int res = 0;
-       int i = 0;
-       int j = 0;
-       char pkg_info_path [PATH_MAX];
-       char buffer [BUFFER_MAX];
-
-       sprintf(pkg_info_path, "/opt/share/applications/%s.desktop", pkg_name);
-
-    fd = open(pkg_info_path, O_RDONLY);
-    if (fd < 0)
-       {
-               LOGE("Cannot open %s", pkg_info_path);
-               return;
-       }
-
-       fcntl( fd, F_SETFD, FD_CLOEXEC );
-
-       LOGI("get_app_info - After open pkg_info_path\n");
-
-       for (;;)
-       {
-               res = read(fd, buffer, BUFFER_MAX);
-               if (res == 0)
-               {
-                       break;
-               }
-               if (res < 0)
-               {
-                       if (errno == EINTR)
-                               continue;
-                       else
-                               break;
-               }
-
-               LOGI("read buffer ===%s===\n", buffer);
-               for (i = 0; i < res; i++)
-               {
-                       if (i < res - 22 && strncmp(&buffer[i], "X-SLP-BaseLayoutWidth=", 22) == 0)
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("width :::: ");
-                                               strncpy(width, &(buffer[i+22]), j-22);
-                                               LOGI("%s\n", width);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 23 && strncmp(&buffer[i], "X-SLP-BaseLayoutHeight=", 23) == 0)
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("height :::: ");
-                                               strncpy(height, &(buffer[i+23]), j-23);
-                                               LOGI("%s\n", height);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 6 && (strncmp(&buffer[i], "theme=", 6) == 0 || strncmp(&buffer[i], "Theme=", 6) == 0))
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("theme :::: ");
-                                               strncpy(theme, &(buffer[i+6]), j-6);
-                                               LOGI("%s\n", theme);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 8 && (strncmp(&buffer[i], "Version=", 8) == 0 || strncmp(&buffer[i], "version=", 8) == 0))
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("version :::: ");
-                                               strncpy(version, &(buffer[i+8]), j-8);
-                                               LOGI("%s\n", version);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 24 && strncmp(&buffer[i], "X-SLP-IsHorizontalScale=", 24) == 0)
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("scale :::: ");
-                                               strncpy(scale, &(buffer[i+24]), j-24);
-                                               LOGI("%s\n", scale);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 16 && strncmp(&buffer[i], "X-SLP-Removable=", 16) == 0)
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("removable :::: ");
-                                               strncpy(removable, &(buffer[i+16]), j-16);
-                                               LOGI("%s\n", removable);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-                       else if (i < res - 8 && (strncmp(&buffer[i], "Comment=", 8) == 0 || strncmp(&buffer[i], "comment=", 8) == 0))
-                       {
-                               for (j = 0; j < res; j ++)
-                               {
-                                       if (buffer[i+j] == '\n' || buffer[i+j] == '\t')
-                                       {
-                                               LOGI("comments :::: ");
-                                               strncpy(comment, &(buffer[i+8]), j-8);
-                                               LOGI("%s\n", comment);
-                                               break;
-                                       }
-                               }
-                               i = i + j;
-                       }
-               }
-       }
-
-       close(fd);
-}
-*/
 static int get_camera_count(void)
 {
        FILE* fp;
@@ -1851,61 +1702,6 @@ static int fill_system_cpu_info(struct system_info_t *sys_info)
        return 0;
 }
 
-
-//fill cpu frequency based on cpu tick count in different cpu frequence states
-int fill_cpu_frequecy(int event_num)
-{
-       // calculate for system cpu frequency
-       float sys_usage = 0.0f;
-       uint64_t ticks = 0, freqsum = 0;
-       int i, j;
-       CPU_t* cpuptr;
-
-       for(i = 0; i < num_of_cpu; i++)
-       {
-               cpuptr = &(cpus[i]);
-
-               if(cpuptr->cur_freq_index == event_num)
-               {
-                       if(cpuptr->sav_freq_index == event_num - 1)
-                       {
-                               for(j = 0; j < num_of_freq; j++)
-                               {
-                                       freqsum += (cpuptr->pfreq[j].freq *
-                                                       (cpuptr->pfreq[j].tick - cpuptr->pfreq[j].tick_sav));
-                                       ticks += (cpuptr->pfreq[j].tick - cpuptr->pfreq[j].tick_sav);
-                               }
-                       }
-                       else
-                       {       // do nothing
-                       }
-
-                       for(j = 0; j < num_of_freq; j++)
-                       {
-                               cpuptr->pfreq[j].tick_sav = cpuptr->pfreq[j].tick;              // restore last tick value
-                       }
-                       cpuptr->sav_freq_index = cpuptr->cur_freq_index;
-               }
-
-#ifdef FOR_EACH_CPU
-               if(ticks != 0)
-               {
-                       if(sys_usage == 0.0f)
-                               sys_usage = (float)freqsum / (float)ticks;
-                       // TODO use sys_usage as cpu #i core freq
-               }
-               else
-               {
-                       //freqbufpos += sprintf(freqbuf + freqbufpos, "%.0f,", sys_usage);
-                       // TODO ?
-               }
-               ticks = 0;
-               freqsum = 0;
-#endif
-       }
-       return -0;
-}
-
 static void skip_lines(FILE * fp, unsigned int count)
 {
        char *buffer = NULL;
@@ -1979,34 +1775,6 @@ static void init_disk_stat(void)
        manager.fd.diskstats = fopen("/proc/diskstats", "r");
 }
 
-//function return partition sector size
-// returns
-//  0 if error
-//  <size> if no errors
-static int get_partition_sector_size(const char * partition_name)
-{
-       int sec_size = 0;
-       FILE *sfp = 0;
-       char sec_size_buff[LARGE_BUFFER];
-
-       sprintf(sec_size_buff, "/sys/block/%s/queue/hw_sector_size", partition_name);
-       sfp = fopen(sec_size_buff, "r");
-       if (sfp == 0) {
-               LOGE("cannot detect sector size for <%s> (%s)\n",
-                               partition_name, sec_size_buff);
-               return 0;
-       }
-       fscanf(sfp, "%d", &sec_size);
-       fclose(sfp);
-       if (sec_size <= 0){
-               LOGE("cannot detect sector size for <%s> (%s)\n",
-                               partition_name, sec_size_buff);
-               return 0;
-       }
-
-       return sec_size;
-}
-
 static void get_disk_stat(uint32_t *reads, uint32_t *sec_reads,
                          uint32_t *writes, uint32_t *sec_writes)
 {
@@ -2036,17 +1804,6 @@ static void get_disk_stat(uint32_t *reads, uint32_t *sec_reads,
                        /* subpartition */
                        skip_tokens(fp, 11);
                } else {
-                       // FIXME it is not good way call this func
-                       // each time to get partition sector size
-                       /*sec_size = get_partition_sector_size(partition);
-                       if (sec_size <= 0){
-                               *read = 0;
-                               *write = 0;
-                               LOGE("get RW error\n");
-                               fclose(fp);
-                               return;
-                       }*/
-
                        //1
                        fscanf(fp, "%" SCNuMAX, &preads);
                        skip_tokens(fp, 1);
index 525ffac119f0df14bf13159315121a0310f225eb..f3fb8d683905caa6f632b7626b6a442371c6dace 100644 (file)
@@ -108,27 +108,6 @@ int64_t str_to_int64(char* str)
        return (res * factor);
 }
 
-int read_line(const int fd, char* ptr, const unsigned int maxlen)
-{
-       unsigned int n = 0;
-       char c[2];
-       int rc;
-
-       while(n != maxlen)
-       {
-               if((rc = read(fd, c, 1)) != 1)
-                       return -1; // eof or read err
-
-               if(*c == '\n')
-               {
-                       ptr[n] = 0;
-                       return n;
-               }
-               ptr[n++] = *c;
-       }
-       return -1; // no space
-}
-
 int smack_set_label_for_self(const char *label)
 {
        int len;
@@ -149,79 +128,6 @@ int smack_set_label_for_self(const char *label)
        return (ret < 0) ? -1 : 0;
 }
 
-void set_appuser_groups(void)
-{
-       int fd = 0;
-       char buffer[5];
-       gid_t t_gid = -1;
-       gid_t groups[APP_GROUPS_MAX] = {0, };
-       int cnt = 0;
-
-       // groups[cnt++] = SID_DEVELOPER;
-       fd = open(APP_GROUP_LIST, O_RDONLY);
-       if(fd < 0)
-       {
-               LOGE("cannot get app's group lists from %s", APP_GROUP_LIST);
-               return;
-       }
-
-       for(;;)
-       {
-               if(read_line(fd, buffer, sizeof buffer) < 0)
-               {
-                       break;
-               }
-
-               t_gid = strtoul(buffer, 0, 10);
-               errno = 0;
-               if(errno != 0)
-               {
-                       LOGE("cannot change string to integer: [%s]\n", buffer);
-                       continue;
-               }
-
-               if(t_gid)
-               {
-                       if(cnt < APP_GROUPS_MAX)
-                       {
-                               groups[cnt++] = t_gid;
-                       }
-                       else
-                       {
-                               LOGE("cannot add groups more than %d", APP_GROUPS_MAX);
-                               break;
-                       }
-               }
-       }
-
-       if(cnt > 0)
-       {
-               if(setgroups(sizeof(groups) / sizeof(groups[0]), groups) != 0)
-               {
-                       fprintf(stderr, "set groups failed errno: %d\n", errno);
-                       close(fd);
-                       exit(1);
-               }
-       }
-       close(fd);
-}
-
-int get_smack_label(const char* execpath, char* buffer, int buflen)
-{
-       char* appid = NULL;
-       int rc;
-
-       rc = smack_lgetlabel(execpath, &appid, SMACK_LABEL_ACCESS);
-       if(rc == 0 && appid != NULL)
-       {
-               strncpy(buffer, appid, (buflen < strlen(appid))? buflen:strlen(appid));
-               free(appid);
-               return 0;
-       }
-       else
-               return -1;
-}
-
 // return 0 if succeed
 // return -1 if error occured
 int remove_indir(const char *dirname)
@@ -253,30 +159,6 @@ int remove_indir(const char *dirname)
        return 0;
 }
 
-// return 0 to normal case
-// return non-zero to error case
-int get_manifest_path(const char* exec_path, char* buf, int buflen)
-{
-       char* chr;
-
-       strcpy(buf, exec_path);
-
-       chr = strrchr(buf, '/');
-       if(chr == NULL)
-               return -1;
-
-       *chr = '\0';
-
-       chr = strrchr(buf, '/');
-       if(chr == NULL)
-               return -1;
-
-       *chr = '\0';
-
-       strcat(buf, MANIFEST_PATH);
-       return 0;
-}
-
 /* execute applcation with executable binary path */
 int exec_app_tizen(const char *app_id, const char *exec_path)
 {