From Cal Turney: Need 6 dec places of SRT precision in WS SRT dialogs and the values should be rounded to the nearest 1us.

From me: 
 -Slight revision of the patch to prevent overflows 
   when time_t is 32 bits (eg: on 32 bit Linux);
 -Other minor changes.

See: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4956

svn path=/trunk/; revision=33721
This commit is contained in:
Bill Meier 2010-08-05 22:14:16 +00:00
parent 79d1d439c7
commit 80fee5052b
3 changed files with 30 additions and 24 deletions

View File

@ -3106,6 +3106,7 @@ Håkon Nessjøen <haakon.nessjoen@gmail.com> {
Digium TDMoE protocol dissector
}
and by:
Pavel Roskin <proski [AT] gnu.org>
@ -3284,6 +3285,7 @@ Chuck Kristofek <chuck.kristofek [AT] ngc.com>
Markus Renz <Markus.Renz [AT] hirschmann.de>
Toshihiro Kataoka <kataoka.toshihiro [AT] gmail.com>
Petr Lautrbach <plautrba [AT] redhat.com>
Cal Turney <turney_cal [AT] emc.com>
Dan Lasley <dlasley[AT]promus.com> gave permission for his
dumpit() hex-dump routine to be used.

View File

@ -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);
}

View File

@ -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,