diff --git a/AUTHORS b/AUTHORS index 186018bc1d..eec9c5ea51 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3106,6 +3106,7 @@ Håkon Nessjøen { Digium TDMoE protocol dissector } + and by: Pavel Roskin @@ -3284,6 +3285,7 @@ Chuck Kristofek Markus Renz Toshihiro Kataoka Petr Lautrbach +Cal Turney Dan Lasley gave permission for his dumpit() hex-dump routine to be used. diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c index 90abd1fa99..f2ba52eb8b 100644 --- a/gtk/rpc_progs.c +++ b/gtk/rpc_progs.c @@ -51,6 +51,7 @@ #include "gtk/dlg_utils.h" #include "gtk/main.h" +#define NANOSECS_PER_SEC 1000000000 static GtkWidget *win=NULL; static GtkWidget *table=NULL; @@ -249,8 +250,8 @@ rpcprogs_packet(void *dummy _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co rp->tot.secs += delta.secs; rp->tot.nsecs += delta.nsecs; - if(rp->tot.nsecs>1000000000){ - rp->tot.nsecs-=1000000000; + if(rp->tot.nsecs>NANOSECS_PER_SEC){ + rp->tot.nsecs-=NANOSECS_PER_SEC; rp->tot.secs++; } rp->num++; @@ -264,22 +265,21 @@ rpcprogs_draw(void *dummy _U_) { rpc_program_t *rp; int i; -#ifdef G_HAVE_UINT64 guint64 td; -#else - guint32 td; -#endif for(rp=prog_list,i=1;rp;rp=rp->next,i++){ - /* scale it to units of 10us.*/ - /* for long captures with a large tot time, this can overflow on 32bit */ - td=(int)rp->tot.secs; - td=td*100000+(int)rp->tot.nsecs/10000; - if(rp->num){ - td/=rp->num; - } else { + /* Ignore procedures with no calls */ + if(rp->num==0){ td=0; + continue; } + /* Scale the average SRT in units of 1us and round to the nearest us. + tot.secs is a time_t which may be 32 or 64 bits (or even floating) + depending on the platform. After casting tot.secs to a 64 bits int, it + would take a capture with a duration of over 136 *years* to + overflow the secs portion of td. */ + td = ((guint64)(rp->tot.secs))*NANOSECS_PER_SEC + rp->tot.nsecs; + td = ((td / rp->num) + 500) / 1000; g_snprintf(rp->sprogram, sizeof(rp->sprogram), "%s",rpc_prog_name(rp->program)); gtk_label_set_text(GTK_LABEL(rp->wprogram), rp->sprogram); @@ -290,13 +290,13 @@ rpcprogs_draw(void *dummy _U_) g_snprintf(rp->snum, sizeof(rp->snum), "%d",rp->num); gtk_label_set_text(GTK_LABEL(rp->wnum), rp->snum); - g_snprintf(rp->smin, sizeof(rp->smin), "%3d.%05d",(int)rp->min.secs,(int)rp->min.nsecs/10000); + g_snprintf(rp->smin, sizeof(rp->smin), "%3d.%06d",(int)rp->min.secs, (rp->min.nsecs+500)/1000); gtk_label_set_text(GTK_LABEL(rp->wmin), rp->smin); - g_snprintf(rp->smax, sizeof(rp->smax), "%3d.%05d",(int)rp->max.secs,(int)rp->max.nsecs/10000); + g_snprintf(rp->smax, sizeof(rp->smax), "%3d.%06d",(int)rp->max.secs, (rp->max.nsecs+500)/1000); gtk_label_set_text(GTK_LABEL(rp->wmax), rp->smax); - g_snprintf(rp->savg, sizeof(rp->savg), "%3d.%05d",(int)td/100000,(int)td%100000); + g_snprintf(rp->savg, sizeof(rp->savg), "%3d.%06d",(int)(td/1000000),(int)(td%1000000)); gtk_label_set_text(GTK_LABEL(rp->wavg), rp->savg); } diff --git a/gtk/service_response_time_table.c b/gtk/service_response_time_table.c index 1d6c61a3ea..a794f8158b 100644 --- a/gtk/service_response_time_table.c +++ b/gtk/service_response_time_table.c @@ -39,6 +39,8 @@ #include "gtk/filter_utils.h" #include "gtk/gui_utils.h" +#define NANOSECS_PER_SEC 1000000000 + enum { INDEX_COLUMN, @@ -190,7 +192,7 @@ srt_time_func (GtkTreeViewColumn *column _U_, g_object_set(renderer, "text", "", NULL); return; } - str = g_strdup_printf("%3d.%05d", (int)data->secs, data->nsecs/10000); + str = g_strdup_printf("%3d.%06d", (int)data->secs, (data->nsecs+500)/1000); g_object_set(renderer, "text", str, NULL); g_free(str); } @@ -207,8 +209,8 @@ srt_avg_func (GtkTreeViewColumn *column _U_, gint data_column = GPOINTER_TO_INT(user_data); gtk_tree_model_get(model, iter, data_column, &td, -1); - str=g_strdup_printf("%3" G_GINT64_MODIFIER "d.%05" G_GINT64_MODIFIER "d", - td/100000, td%100000); + str=g_strdup_printf("%3d.%06d", + (int)(td/1000000), (int)(td%1000000)); g_object_set(renderer, "text", str, NULL); g_free(str); } @@ -412,12 +414,14 @@ draw_srt_table_data(srt_stat_table *rst) if(rst->procedures[i].stats.num==0){ continue; } + /* Scale the average SRT in units of 1us and round to the nearest us. + tot.secs is a time_t which may be 32 or 64 bits (or even floating) + depending uon the platform. After casting tot.secs to 64 bits, it + would take a capture with a duration of over 136 *years* to + overflow the secs portion of td. */ + td = ((guint64)(rst->procedures[i].stats.tot.secs))*NANOSECS_PER_SEC + rst->procedures[i].stats.tot.nsecs; + td = ((td / rst->procedures[i].stats.num) + 500) / 1000; - /* scale it to units of 10us.*/ - /* for long captures with a large tot time, this can overflow on 32bit */ - td=(int)rst->procedures[i].stats.tot.secs; - td=td*100000+(int)rst->procedures[i].stats.tot.nsecs/10000; - td/=rst->procedures[i].stats.num; gtk_list_store_set(store, &rst->procedures[i].iter, CALLS_COLUMN, rst->procedures[i].stats.num, MIN_SRT_COLUMN, &rst->procedures[i].stats.min,