(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c) |
| |
| 3028 | | | find_packet(capture_file *cf, |
| 3029 | | | gboolean (*match_function)(capture_file *, frame_data *, void *), |
| 3030 | | | void *criterion) |
| 3031 | | | { |
| 3032 | | | frame_data *start_fd; |
| 3033 | | | frame_data *fdata; |
| 3034 | | | frame_data *new_fd = NULL; |
| 3035 | | | progdlg_t *progbar = NULL; |
| 3036 | | | gboolean stop_flag; |
| 3037 | | | int count; |
| 3038 | | | int err; |
| 3039 | | | gchar *err_info; |
| 3040 | | | int row; |
| 3041 | | | float progbar_val; |
| 3042 | | | GTimeVal start_time; |
| 3043 | | | gchar status_str[100]; |
| 3044 | | | int progbar_nextstep; |
| 3045 | | | int progbar_quantum; |
| 3046 | | | char *title; |
| 3047 | | | |
| 3048 | | | start_fd = cf->current_frame; |
| 3049 | | | if (start_fd != NULL) { |
| 3050 | | | |
| 3051 | | | |
| 3052 | | | |
| 3053 | | | count = 0; |
| 3054 | | | fdata = start_fd; |
| 3055 | | | |
| 3056 | | | |
| 3057 | | | progbar_nextstep = 0; |
| 3058 | | | |
| 3059 | | | |
| 3060 | | | progbar_quantum = cf->count/N_PROGBAR_UPDATES; |
| 3061 | | | |
| 3062 | | | progbar_val = 0.0f; |
| 3063 | | | |
| 3064 | | | stop_flag = FALSE; |
| 3065 | | | g_get_current_time(&start_time); |
| 3066 | | | |
| 3067 | | | fdata = start_fd; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 3068 | | | title = cf->sfilter?cf->sfilter:""; |
| 3069 | | | for (;;) { |
| 3070 | | | |
| 3071 | | | |
| 3072 | | | |
| 3073 | | | |
| 3074 | | | |
| 3075 | | | if (progbar == NULL) |
| 3076 | | | progbar = delayed_create_progress_dlg("Searching", title, |
| 3077 | | | FALSE, &stop_flag, &start_time, progbar_val); |
| 3078 | | | |
| 3079 | | | |
| 3080 | | | |
| 3081 | | | |
| 3082 | | | |
| 3083 | | | |
| 3084 | | | if (count >= progbar_nextstep) { |
| 3085 | | | |
| 3086 | | | |
| 3087 | | | |
| 3088 | | | g_assert(cf->count > 0);
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
74 | #define g_assert(expr) do { if G_LIKELY (expr) ; else \ |
75 | g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ |
76 | #expr); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
277 | #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
268 | #define _G_BOOLEAN_EXPR(expr) \ |
269 | __extension__ ({ \ |
270 | int _g_boolean_var_; \ |
271 | if (expr) \ |
272 | _g_boolean_var_ = 1; \ |
273 | else \ |
274 | _g_boolean_var_ = 0; \ |
275 | _g_boolean_var_; \ |
276 | }) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 3089 | | | |
| 3090 | | | progbar_val = (gfloat) count / cf->count; |
| 3091 | | | |
| 3092 | | | if (progbar != NULL) { |
| 3093 | | | g_snprintf(status_str, sizeof(status_str), |
| 3094 | | | "%4u of %u packets", count, cf->count); |
| 3095 | | | update_progress_dlg(progbar, progbar_val, status_str); |
| 3096 | | | } |
| 3097 | | | |
| 3098 | | | progbar_nextstep += progbar_quantum; |
| 3099 | | | } |
| 3100 | | | |
| 3101 | | | if (stop_flag) { |
| 3102 | | | |
| 3103 | | | |
| 3104 | | | new_fd = start_fd; |
| 3105 | | | break; |
| 3106 | | | } |
| 3107 | | | |
| 3108 | | | |
| 3109 | | | if (cf->sbackward) { |
| 3110 | | | |
| 3111 | | | fdata = fdata->prev; |
| 3112 | | | if (fdata == NULL) { |
| 3113 | | | |
| 3114 | | | |
| 3115 | | | |
| 3116 | | | |
| 3117 | | | |
| 3118 | | | |
| 3119 | | | |
| 3120 | | | |
| 3121 | | | if (prefs.gui_find_wrap) |
| 3122 | | | { |
| 3123 | | | simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, |
| 3124 | | | "%sBeginning of capture exceeded!%s\n\n" |
| 3125 | | | "Search is continued from the end of the capture.", |
| 3126 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 3127 | | | fdata = cf->plist_end; |
| 3128 | | | } |
| 3129 | | | else |
| 3130 | | | { |
| 3131 | | | simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, |
| 3132 | | | "%sBeginning of capture exceeded!%s\n\n" |
| 3133 | | | "Try searching forwards.", |
| 3134 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 3135 | | | fdata = start_fd; |
| 3136 | | | } |
| 3137 | | | } |
| 3138 | | | } else { |
| 3139 | | | |
| 3140 | | | fdata = fdata->next; |
| 3141 | | | if (fdata == NULL) { |
| 3142 | | | if (prefs.gui_find_wrap) |
| 3143 | | | { |
| 3144 | | | simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, |
| 3145 | | | "%sEnd of capture exceeded!%s\n\n" |
| 3146 | | | "Search is continued from the start of the capture.", |
| 3147 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 3148 | | | fdata = cf->plist; |
| 3149 | | | } |
| 3150 | | | else |
| 3151 | | | { |
| 3152 | | | simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, |
| 3153 | | | "%sEnd of capture exceeded!%s\n\n" |
| 3154 | | | "Try searching backwards.", |
| 3155 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 3156 | | | fdata = start_fd; |
| 3157 | | | } |
| 3158 | | | } |
| 3159 | | | } |
| 3160 | | | |
| 3161 | | | count++; |
| 3162 | | | |
| 3163 | | | |
| 3164 | | | if (fdata->flags.passed_dfilter) { |
| 3165 | | | |
| 3166 | | | if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->, |
| 3167 | | | cf->pd, fdata->cap_len, &err, &err_info)) { |
| 3168 | | | |
| 3169 | | | |
| 3170 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 3171 | | | cf_read_error_message(err, err_info), cf->filename); |
| 3172 | | | new_fd = start_fd; |
| 3173 | | | break; |
| 3174 | | | } |
| 3175 | | | |
| 3176 | | | |
| 3177 | | | if ((*match_function)(cf, fdata, criterion)) { |
| 3178 | | | new_fd = fdata; |
| 3179 | | | break; |
| 3180 | | | } |
| 3181 | | | } |
| 3182 | | | |
| 3183 | | | if (fdata == start_fd) { |
| 3184 | | | |
| 3185 | | | |
| 3186 | | | break; |
| 3187 | | | } |
| 3188 | | | } |
| 3189 | | | |
| 3190 | | | |
| 3191 | | | |
| 3192 | | | if (progbar != NULL) |
| 3193 | | | destroy_progress_dlg(progbar); |
| 3194 | | | } |
| 3195 | | | |
| 3196 | | | if (new_fd != NULL) { |
| 3197 | | | |
| 3198 | | | row = packet_list_find_row_from_data(new_fd); |
| 3199 | | | if (row == -1) { |
| 3200 | | | |
| 3201 | | | |
| 3202 | | | |
| 3203 | | | simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, |
| 3204 | | | "%sEnd of capture exceeded!%s\n\n" |
| 3205 | | | "The capture file is probably not fully loaded.", |
| 3206 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 3207 | | | return FALSE; |
| 3208 | | | } |
| 3209 | | | |
| 3210 | | | |
| 3211 | | | packet_list_set_selected_row(row); |
| 3212 | | | return TRUE; |
| 3213 | | | } else |
| 3214 | | | return FALSE; |
| 3215 | | | } |
| |