Fix some dead code and zero division issues found by Clang scan-build.

In convert_string_case() use g_utf8_strup() instead of converting each
character by hand. Hopefully this won't cause any unexpected changes in
behavior.

svn path=/trunk/; revision=36006
This commit is contained in:
Gerald Combs 2011-02-18 22:43:48 +00:00
parent aaeca955a5
commit a6bbdaa849
10 changed files with 117 additions and 146 deletions

View File

@ -2487,7 +2487,6 @@ capture_loop_dispatch(capture_options *capture_opts _U_, loop_data *ld,
#ifndef USE_THREADS #ifndef USE_THREADS
sel_ret = cap_pipe_select(ld->cap_pipe_fd); sel_ret = cap_pipe_select(ld->cap_pipe_fd);
if (sel_ret <= 0) { if (sel_ret <= 0) {
inpkts = 0;
if (sel_ret < 0 && errno != EINTR) { if (sel_ret < 0 && errno != EINTR) {
g_snprintf(errmsg, errmsg_len, g_snprintf(errmsg, errmsg_len,
"Unexpected error from select: %s", strerror(errno)); "Unexpected error from select: %s", strerror(errno));
@ -2659,9 +2658,6 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
gchar *capfile_name; gchar *capfile_name;
gchar *prefix; gchar *prefix;
gboolean is_tempfile; gboolean is_tempfile;
#ifndef _WIN32
int ret;
#endif
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "capture_loop_open_output: %s", g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "capture_loop_open_output: %s",
(capture_opts->save_file) ? capture_opts->save_file : ""); (capture_opts->save_file) ? capture_opts->save_file : "");
@ -2753,9 +2749,6 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
capture_opts->save_file = capfile_name; capture_opts->save_file = capfile_name;
/* capture_opts.save_file is "g_free"ed later, which is equivalent to /* capture_opts.save_file is "g_free"ed later, which is equivalent to
"g_free(capfile_name)". */ "g_free(capfile_name)". */
#ifndef _WIN32
ret = fchown(*save_file_fd, capture_opts->owner, capture_opts->group);
#endif
return TRUE; return TRUE;
} }
@ -2787,9 +2780,6 @@ do_file_switch_or_stop(capture_options *capture_opts,
if (ringbuf_switch_file(&global_ld.pdh, &capture_opts->save_file, if (ringbuf_switch_file(&global_ld.pdh, &capture_opts->save_file,
&global_ld.save_file_fd, &global_ld.err)) { &global_ld.save_file_fd, &global_ld.err)) {
gboolean successful; gboolean successful;
#ifndef _WIN32
int ret;
#endif
/* File switch succeeded: reset the conditions */ /* File switch succeeded: reset the conditions */
global_ld.bytes_written = 0; global_ld.bytes_written = 0;
@ -2818,10 +2808,6 @@ do_file_switch_or_stop(capture_options *capture_opts,
report_packet_count(global_ld.inpkts_to_sync_pipe); report_packet_count(global_ld.inpkts_to_sync_pipe);
global_ld.inpkts_to_sync_pipe = 0; global_ld.inpkts_to_sync_pipe = 0;
report_new_capture_file(capture_opts->save_file); report_new_capture_file(capture_opts->save_file);
#ifndef _WIN32
ret = fchown(global_ld.save_file_fd, capture_opts->owner, capture_opts->group);
#endif
} else { } else {
/* File switch failed: stop here */ /* File switch failed: stop here */
global_ld.go = FALSE; global_ld.go = FALSE;
@ -2841,7 +2827,6 @@ static gboolean
capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats) capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats)
{ {
time_t upd_time, cur_time; time_t upd_time, cur_time;
time_t start_time;
int err_close; int err_close;
int inpkts; int inpkts;
condition *cnd_file_duration = NULL; condition *cnd_file_duration = NULL;
@ -2967,7 +2952,6 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
} }
/* init the time values */ /* init the time values */
start_time = TIME_GET();
upd_time = TIME_GET(); upd_time = TIME_GET();
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO, "Capture loop running!"); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO, "Capture loop running!");

View File

@ -268,7 +268,7 @@ dissect_enttec_dmx_data(tvbuff_t *tvb, guint offset, proto_tree *tree)
} }
if (type == ENTTEC_DATA_TYPE_DMX || type == ENTTEC_DATA_TYPE_RLE) { if ((type == ENTTEC_DATA_TYPE_DMX || type == ENTTEC_DATA_TYPE_RLE) && global_disp_col_count > 0) {
hi = proto_tree_add_item(tree, hi = proto_tree_add_item(tree,
hf_enttec_dmx_data_data, hf_enttec_dmx_data_data,
tvb, tvb,

View File

@ -600,7 +600,6 @@ emem_scrub_memory(char *buf, size_t size, gboolean alloc)
offset++; offset++;
if (offset < size) { if (offset < size) {
*(guint8*)(buf+offset) = (scrubbed_value >> 8) & 0xFF; *(guint8*)(buf+offset) = (scrubbed_value >> 8) & 0xFF;
offset++;
} }
} }
} }

View File

@ -72,7 +72,7 @@ print_nsap_net_buf( const guint8 *ad, int length, gchar *buf, int buf_len)
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x]", cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x]",
ad[ RFC1237_FULLAREA_LEN + RFC1237_SYSTEMID_LEN ] ); ad[ RFC1237_FULLAREA_LEN + RFC1237_SYSTEMID_LEN ] );
if ( length == RFC1237_NSAP_LEN + 1 ) { if ( length == RFC1237_NSAP_LEN + 1 ) {
cur += g_snprintf(cur, (int) (buf_len-(cur-buf)), "-%02x", ad[ length -1 ] ); g_snprintf(cur, (int) (buf_len-(cur-buf)), "-%02x", ad[ length -1 ] );
} }
} }
else { /* probably format as standard */ else { /* probably format as standard */
@ -112,7 +112,7 @@ print_system_id_buf( const guint8 *ad, int length, gchar *buf, int buf_len)
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[6] ); cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[6] );
} }
if ( 8 == length ) { if ( 8 == length ) {
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[7] ); g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[7] );
} }
} }
else { else {

View File

@ -338,7 +338,6 @@ prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(vo
module_t *subtree_module; module_t *subtree_module;
module_t *new_module; module_t *new_module;
char *sep = NULL, *ptr = NULL; char *sep = NULL, *ptr = NULL;
char *csubtree = NULL;
/* /*
* Have we yet created the "Protocols" subtree? * Have we yet created the "Protocols" subtree?
@ -354,7 +353,7 @@ prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(vo
if(subtree) { if(subtree) {
/* take a copy of the buffer */ /* take a copy of the buffer */
ptr = csubtree = g_strdup(subtree); ptr = g_strdup(subtree);
while(ptr && *ptr) { while(ptr && *ptr) {
@ -370,9 +369,6 @@ prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(vo
ptr = sep; ptr = sep;
} }
/* g_free(csubtree); */
} }
protocol = find_protocol_by_id(id); protocol = find_protocol_by_id(id);

View File

@ -7,17 +7,17 @@
* Wireshark - Network traffic analyzer * Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org> * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs * Copyright 1998 Gerald Combs
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -34,9 +34,9 @@
#include "stats_tree.h" #include "stats_tree.h"
/* /*
TODO: TODO:
- sort out the sorting issue - sort out the sorting issue
*/ */
/* used to contain the registered stat trees */ /* used to contain the registered stat trees */
@ -48,9 +48,9 @@ extern void
stats_tree_get_strs_from_node(const stat_node *node, gchar *value, gchar *rate, gchar *percent) stats_tree_get_strs_from_node(const stat_node *node, gchar *value, gchar *rate, gchar *percent)
{ {
float f; float f;
if (value) g_snprintf(value,NUM_BUF_SIZE,"%u",node->counter); if (value) g_snprintf(value,NUM_BUF_SIZE,"%u",node->counter);
if (rate) { if (rate) {
*rate = '\0'; *rate = '\0';
if (node->st->elapsed > 0.0) { if (node->st->elapsed > 0.0) {
@ -58,7 +58,7 @@ stats_tree_get_strs_from_node(const stat_node *node, gchar *value, gchar *rate,
g_snprintf(rate,NUM_BUF_SIZE,"%f",f); g_snprintf(rate,NUM_BUF_SIZE,"%f",f);
} }
} }
if (percent) { if (percent) {
*percent = '\0'; *percent = '\0';
if (node->parent->counter > 0) { if (node->parent->counter > 0) {
@ -88,19 +88,19 @@ stats_tree_branch_max_namelen(const stat_node *node, guint indent)
stat_node *child; stat_node *child;
guint maxlen = 0; guint maxlen = 0;
guint len; guint len;
indent = indent > INDENT_MAX ? INDENT_MAX : indent; indent = indent > INDENT_MAX ? INDENT_MAX : indent;
if (node->children) { if (node->children) {
for (child = node->children; child; child = child->next ) { for (child = node->children; child; child = child->next ) {
len = stats_tree_branch_max_namelen(child,indent+1); len = stats_tree_branch_max_namelen(child,indent+1);
maxlen = len > maxlen ? len : maxlen; maxlen = len > maxlen ? len : maxlen;
} }
} }
len = (guint) strlen(node->name) + indent; len = (guint) strlen(node->name) + indent;
maxlen = len > maxlen ? len : maxlen; maxlen = len > maxlen ? len : maxlen;
return maxlen; return maxlen;
} }
@ -116,34 +116,34 @@ stats_tree_branch_to_str(const stat_node *node, GString *s, guint indent)
static gchar value[NUM_BUF_SIZE]; static gchar value[NUM_BUF_SIZE];
static gchar rate[NUM_BUF_SIZE]; static gchar rate[NUM_BUF_SIZE];
static gchar percent[NUM_BUF_SIZE]; static gchar percent[NUM_BUF_SIZE];
guint i = 0; guint i = 0;
if (indent == 0) { if (indent == 0) {
format = g_strdup_printf(" %%s%%-%us%%12s %%12s %%12s\n",stats_tree_branch_max_namelen(node,0)); format = g_strdup_printf(" %%s%%-%us%%12s %%12s %%12s\n",stats_tree_branch_max_namelen(node,0));
} }
stats_tree_get_strs_from_node(node, value, rate, percent); stats_tree_get_strs_from_node(node, value, rate, percent);
indent = indent > INDENT_MAX ? INDENT_MAX : indent; indent = indent > INDENT_MAX ? INDENT_MAX : indent;
/* fill indentation with indent spaces */ /* fill indentation with indent spaces */
if (indent > 0) { if (indent > 0) {
while(i<indent) while(i<indent)
indentation[i++] = ' '; indentation[i++] = ' ';
} }
indentation[i++] = '\0'; indentation[i] = '\0';
g_string_append_printf(s,format, g_string_append_printf(s,format,
indentation,node->name,value,rate,percent); indentation,node->name,value,rate,percent);
if (node->children) { if (node->children) {
for (child = node->children; child; child = child->next ) { for (child = node->children; child; child = child->next ) {
stats_tree_branch_to_str(child,s,indent+1); stats_tree_branch_to_str(child,s,indent+1);
} }
} }
if (indent == 0) { if (indent == 0) {
g_free(format); g_free(format);
} }
@ -156,7 +156,7 @@ free_stat_node(stat_node *node)
{ {
stat_node *child; stat_node *child;
stat_node *next; stat_node *next;
if (node->children) { if (node->children) {
for (child = node->children; child; child = next ) { for (child = node->children; child; child = next ) {
/* child->next will be gone after free_stat_node, so cache it here */ /* child->next will be gone after free_stat_node, so cache it here */
@ -164,9 +164,9 @@ free_stat_node(stat_node *node)
free_stat_node(child); free_stat_node(child);
} }
} }
if(node->st->cfg->free_node_pr) node->st->cfg->free_node_pr(node); if(node->st->cfg->free_node_pr) node->st->cfg->free_node_pr(node);
if (node->hash) g_hash_table_destroy(node->hash); if (node->hash) g_hash_table_destroy(node->hash);
g_free(node->rng); g_free(node->rng);
@ -180,23 +180,23 @@ stats_tree_free(stats_tree *st)
{ {
stat_node *child; stat_node *child;
stat_node *next; stat_node *next;
g_free(st->filter); g_free(st->filter);
g_hash_table_destroy(st->names); g_hash_table_destroy(st->names);
g_ptr_array_free(st->parents,TRUE); g_ptr_array_free(st->parents,TRUE);
for (child = st->root.children; child; child = next ) { for (child = st->root.children; child; child = next ) {
/* child->next will be gone after free_stat_node, so cache it here */ /* child->next will be gone after free_stat_node, so cache it here */
next = child->next; next = child->next;
free_stat_node(child); free_stat_node(child);
} }
if (st->cfg->free_tree_pr) if (st->cfg->free_tree_pr)
st->cfg->free_tree_pr(st); st->cfg->free_tree_pr(st);
if (st->cfg->cleanup) if (st->cfg->cleanup)
st->cfg->cleanup(st); st->cfg->cleanup(st);
g_free(st); g_free(st);
} }
@ -206,18 +206,18 @@ static void
reset_stat_node(stat_node *node) reset_stat_node(stat_node *node)
{ {
stat_node *child; stat_node *child;
if (node->children) { if (node->children) {
for (child = node->children; child; child = child->next ) for (child = node->children; child; child = child->next )
reset_stat_node(child); reset_stat_node(child);
} }
node->counter = 0; node->counter = 0;
if(node->st->cfg->reset_node) { if(node->st->cfg->reset_node) {
node->st->cfg->reset_node(node); node->st->cfg->reset_node(node);
} }
} }
/* reset the whole stats_tree */ /* reset the whole stats_tree */
@ -225,12 +225,12 @@ extern void
stats_tree_reset(void *p) stats_tree_reset(void *p)
{ {
stats_tree *st = p; stats_tree *st = p;
st->start = -1.0; st->start = -1.0;
st->elapsed = 0.0; st->elapsed = 0.0;
reset_stat_node(&st->root); reset_stat_node(&st->root);
if (st->cfg->reset_tree) { if (st->cfg->reset_tree) {
st->cfg->reset_tree(st); st->cfg->reset_tree(st);
} }
@ -242,16 +242,16 @@ stats_tree_reinit(void *p)
stats_tree *st = p; stats_tree *st = p;
stat_node *child; stat_node *child;
stat_node *next; stat_node *next;
for (child = st->root.children; child; child = next) { for (child = st->root.children; child; child = next) {
/* child->next will be gone after free_stat_node, so cache it here */ /* child->next will be gone after free_stat_node, so cache it here */
next = child->next; next = child->next;
free_stat_node(child); free_stat_node(child);
} }
st->root.children = NULL; st->root.children = NULL;
st->root.counter = 0; st->root.counter = 0;
if (st->cfg->init) { if (st->cfg->init) {
st->cfg->init(st); st->cfg->init(st);
} }
@ -264,23 +264,23 @@ stats_tree_register_with_group(const char *tapname, const char *abbr, const char
stat_tree_packet_cb packet, stat_tree_init_cb init, stat_tree_packet_cb packet, stat_tree_init_cb init,
stat_tree_cleanup_cb cleanup, register_stat_group_t stat_group) stat_tree_cleanup_cb cleanup, register_stat_group_t stat_group)
{ {
stats_tree_cfg *cfg = g_malloc( sizeof(stats_tree_cfg) ); stats_tree_cfg *cfg = g_malloc( sizeof(stats_tree_cfg) );
/* at the very least the abbrev and the packet function should be given */ /* at the very least the abbrev and the packet function should be given */
g_assert( tapname && abbr && packet ); g_assert( tapname && abbr && packet );
cfg->tapname = g_strdup(tapname); cfg->tapname = g_strdup(tapname);
cfg->abbr = g_strdup(abbr); cfg->abbr = g_strdup(abbr);
cfg->name = name ? g_strdup(name) : g_strdup(abbr); cfg->name = name ? g_strdup(name) : g_strdup(abbr);
cfg->stat_group = stat_group; cfg->stat_group = stat_group;
cfg->packet = packet; cfg->packet = packet;
cfg->init = init; cfg->init = init;
cfg->cleanup = cleanup; cfg->cleanup = cleanup;
cfg->flags = flags; cfg->flags = flags;
/* these have to be filled in by implementations */ /* these have to be filled in by implementations */
cfg->setup_node_pr = NULL; cfg->setup_node_pr = NULL;
cfg->new_tree_pr = NULL; cfg->new_tree_pr = NULL;
@ -294,7 +294,7 @@ stats_tree_register_with_group(const char *tapname, const char *abbr, const char
if (!registry) registry = g_hash_table_new(g_str_hash,g_str_equal); if (!registry) registry = g_hash_table_new(g_str_hash,g_str_equal);
g_hash_table_insert(registry,cfg->abbr,cfg); g_hash_table_insert(registry,cfg->abbr,cfg);
} }
/* register a new stats_tree with default group REGISTER_STAT_GROUP_UNSORTED */ /* register a new stats_tree with default group REGISTER_STAT_GROUP_UNSORTED */
@ -321,7 +321,7 @@ stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
st->names = g_hash_table_new(g_str_hash,g_str_equal); st->names = g_hash_table_new(g_str_hash,g_str_equal);
st->parents = g_ptr_array_new(); st->parents = g_ptr_array_new();
st->filter = g_strdup(filter); st->filter = g_strdup(filter);
st->start = -1.0; st->start = -1.0;
st->elapsed = 0.0; st->elapsed = 0.0;
@ -333,11 +333,11 @@ stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
st->root.next = NULL; st->root.next = NULL;
st->root.hash = NULL; st->root.hash = NULL;
st->root.pr = NULL; st->root.pr = NULL;
g_ptr_array_add(st->parents,&st->root); g_ptr_array_add(st->parents,&st->root);
return st; return st;
} }
/* will be the tap packet cb */ /* will be the tap packet cb */
extern int extern int
@ -345,11 +345,11 @@ stats_tree_packet(void *p, packet_info *pinfo, epan_dissect_t *edt, const void *
{ {
stats_tree *st = p; stats_tree *st = p;
double now = nstime_to_msec(&pinfo->fd->rel_ts); double now = nstime_to_msec(&pinfo->fd->rel_ts);
if (st->start < 0.0) st->start = now; if (st->start < 0.0) st->start = now;
st->elapsed = now - st->start; st->elapsed = now - st->start;
if (st->cfg->packet) if (st->cfg->packet)
return st->cfg->packet(st,pinfo,edt,pri); return st->cfg->packet(st,pinfo,edt,pri);
else else
@ -379,7 +379,7 @@ setup_tree_presentation(gpointer k _U_, gpointer v, gpointer p)
{ {
stats_tree_cfg *cfg = v; stats_tree_cfg *cfg = v;
struct _stats_tree_pres_cbs *d = p; struct _stats_tree_pres_cbs *d = p;
cfg->in_use = FALSE; cfg->in_use = FALSE;
cfg->setup_node_pr = d->setup_node_pr; cfg->setup_node_pr = d->setup_node_pr;
cfg->new_tree_pr = d->new_tree_pr; cfg->new_tree_pr = d->new_tree_pr;
@ -389,7 +389,7 @@ setup_tree_presentation(gpointer k _U_, gpointer v, gpointer p)
cfg->draw_tree = d->draw_tree; cfg->draw_tree = d->draw_tree;
cfg->reset_node = d->reset_node; cfg->reset_node = d->reset_node;
cfg->reset_tree = d->reset_tree; cfg->reset_tree = d->reset_tree;
} }
extern void extern void
@ -405,7 +405,7 @@ stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,gpointer),
void *data) void *data)
{ {
static struct _stats_tree_pres_cbs d; static struct _stats_tree_pres_cbs d;
d.setup_node_pr = setup_node_pr; d.setup_node_pr = setup_node_pr;
d.new_tree_pr = new_tree_pr; d.new_tree_pr = new_tree_pr;
d.free_node_pr = free_node_pr; d.free_node_pr = free_node_pr;
@ -414,12 +414,12 @@ stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer,gpointer),
d.draw_tree = draw_tree; d.draw_tree = draw_tree;
d.reset_node = reset_node; d.reset_node = reset_node;
d.reset_tree = reset_tree; d.reset_tree = reset_tree;
if (registry) g_hash_table_foreach(registry,setup_tree_presentation,&d); if (registry) g_hash_table_foreach(registry,setup_tree_presentation,&d);
if (registry_iterator && registry) if (registry_iterator && registry)
g_hash_table_foreach(registry,registry_iterator,data); g_hash_table_foreach(registry,registry_iterator,data);
} }
@ -436,7 +436,7 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id,
stat_node *node = g_malloc (sizeof(stat_node)); stat_node *node = g_malloc (sizeof(stat_node));
stat_node *last_chld = NULL; stat_node *last_chld = NULL;
node->counter = 0; node->counter = 0;
node->name = g_strdup(name); node->name = g_strdup(name);
node->children = NULL; node->children = NULL;
@ -450,45 +450,45 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id,
g_hash_table_insert(st->names, g_hash_table_insert(st->names,
node->name, node->name,
node); node);
g_ptr_array_add(st->parents,node); g_ptr_array_add(st->parents,node);
node->id = st->parents->len - 1; node->id = st->parents->len - 1;
} else { } else {
node->id = -1; node->id = -1;
} }
if (parent_id >= 0 && parent_id < (int) st->parents->len ) { if (parent_id >= 0 && parent_id < (int) st->parents->len ) {
node->parent = g_ptr_array_index(st->parents,parent_id); node->parent = g_ptr_array_index(st->parents,parent_id);
} else { } else {
/* ??? should we set the parent to be root ??? */ /* ??? should we set the parent to be root ??? */
g_assert_not_reached(); g_assert_not_reached();
} }
if (node->parent->children) { if (node->parent->children) {
/* insert as last child */ /* insert as last child */
for (last_chld = node->parent->children; for (last_chld = node->parent->children;
last_chld->next; last_chld->next;
last_chld = last_chld->next ) ; last_chld = last_chld->next ) ;
last_chld->next = node; last_chld->next = node;
} else { } else {
/* insert as first child */ /* insert as first child */
node->parent->children = node; node->parent->children = node;
} }
if(node->parent->hash) { if(node->parent->hash) {
g_hash_table_insert(node->parent->hash,node->name,node); g_hash_table_insert(node->parent->hash,node->name,node);
} }
if (st->cfg->setup_node_pr) { if (st->cfg->setup_node_pr) {
st->cfg->setup_node_pr(node); st->cfg->setup_node_pr(node);
} else { } else {
node->pr = NULL; node->pr = NULL;
} }
return node; return node;
} }
/***/ /***/
@ -497,8 +497,8 @@ extern int
stats_tree_create_node(stats_tree *st, const gchar *name, int parent_id, gboolean with_hash) stats_tree_create_node(stats_tree *st, const gchar *name, int parent_id, gboolean with_hash)
{ {
stat_node *node = new_stat_node(st,name,parent_id,with_hash,TRUE); stat_node *node = new_stat_node(st,name,parent_id,with_hash,TRUE);
if (node) if (node)
return node->id; return node->id;
else else
return 0; return 0;
@ -526,26 +526,26 @@ stats_tree_manip_node(manip_node_mode mode, stats_tree *st, const char *name,
{ {
stat_node *node = NULL; stat_node *node = NULL;
stat_node *parent = NULL; stat_node *parent = NULL;
g_assert( parent_id >= 0 && parent_id < (int) st->parents->len ); g_assert( parent_id >= 0 && parent_id < (int) st->parents->len );
parent = g_ptr_array_index(st->parents,parent_id); parent = g_ptr_array_index(st->parents,parent_id);
if( parent->hash ) { if( parent->hash ) {
node = g_hash_table_lookup(parent->hash,name); node = g_hash_table_lookup(parent->hash,name);
} else { } else {
node = g_hash_table_lookup(st->names,name); node = g_hash_table_lookup(st->names,name);
} }
if ( node == NULL ) if ( node == NULL )
node = new_stat_node(st,name,parent_id,with_hash,with_hash); node = new_stat_node(st,name,parent_id,with_hash,with_hash);
switch (mode) { switch (mode) {
case MN_INCREASE: node->counter += value; break; case MN_INCREASE: node->counter += value; break;
case MN_SET: node->counter = value; break; case MN_SET: node->counter = value; break;
} }
if (node) if (node)
return node->id; return node->id;
else else
return -1; return -1;
@ -560,9 +560,9 @@ stats_tree_get_abbr(const char *optarg)
/* XXX: this fails when tshark is given any options /* XXX: this fails when tshark is given any options
after the -z */ after the -z */
g_assert(optarg != NULL); g_assert(optarg != NULL);
for (i=0; optarg[i] && optarg[i] != ','; i++); for (i=0; optarg[i] && optarg[i] != ','; i++);
if (optarg[i] == ',') { if (optarg[i] == ',') {
return g_strndup(optarg,i); return g_strndup(optarg,i);
} else { } else {
@ -601,7 +601,7 @@ get_range(char *rngstr)
return NULL; return NULL;
} }
/* means we have a non empty string /* means we have a non empty string
* which does not contain a delimiter */ * which does not contain a delimiter */
if (split[1] == NULL) { if (split[1] == NULL) {
g_strfreev(split); g_strfreev(split);
@ -653,7 +653,7 @@ extern int
stats_tree_parent_id_by_name(stats_tree *st, const gchar *parent_name) stats_tree_parent_id_by_name(stats_tree *st, const gchar *parent_name)
{ {
stat_node *node = g_hash_table_lookup(st->names,parent_name); stat_node *node = g_hash_table_lookup(st->names,parent_name);
if (node) if (node)
return node->id; return node->id;
else else
@ -677,46 +677,46 @@ stats_tree_range_node_with_pname(stats_tree *st, const gchar *name,
range_node->rng = get_range(curr_range); range_node->rng = get_range(curr_range);
} }
va_end( list ); va_end( list );
return rng_root->id; return rng_root->id;
} }
extern int extern int
stats_tree_tick_range(stats_tree *st, const gchar *name, int parent_id, stats_tree_tick_range(stats_tree *st, const gchar *name, int parent_id,
int value_in_range) int value_in_range)
{ {
stat_node *node = NULL; stat_node *node = NULL;
stat_node *parent = NULL; stat_node *parent = NULL;
stat_node *child = NULL; stat_node *child = NULL;
gint floor, ceil; gint floor, ceil;
if (parent_id >= 0 && parent_id < (int) st->parents->len) { if (parent_id >= 0 && parent_id < (int) st->parents->len) {
parent = g_ptr_array_index(st->parents,parent_id); parent = g_ptr_array_index(st->parents,parent_id);
} else { } else {
g_assert_not_reached(); g_assert_not_reached();
} }
if( parent->hash ) { if( parent->hash ) {
node = g_hash_table_lookup(parent->hash,name); node = g_hash_table_lookup(parent->hash,name);
} else { } else {
node = g_hash_table_lookup(st->names,name); node = g_hash_table_lookup(st->names,name);
} }
if ( node == NULL ) if ( node == NULL )
g_assert_not_reached(); g_assert_not_reached();
for ( child = node->children; child; child = child->next) { for ( child = node->children; child; child = child->next) {
floor = child->rng->floor; floor = child->rng->floor;
ceil = child->rng->ceil; ceil = child->rng->ceil;
if ( value_in_range >= floor && value_in_range <= ceil ) { if ( value_in_range >= floor && value_in_range <= ceil ) {
child->counter++; child->counter++;
return node->id; return node->id;
} }
} }
return node->id; return node->id;
} }
@ -724,8 +724,8 @@ extern int
stats_tree_create_pivot(stats_tree *st, const gchar *name, int parent_id) stats_tree_create_pivot(stats_tree *st, const gchar *name, int parent_id)
{ {
stat_node *node = new_stat_node(st,name,parent_id,TRUE,TRUE); stat_node *node = new_stat_node(st,name,parent_id,TRUE,TRUE);
if (node) if (node)
return node->id; return node->id;
else else
return 0; return 0;
@ -737,10 +737,10 @@ stats_tree_create_pivot_by_pname(stats_tree *st, const gchar *name,
{ {
int parent_id = stats_tree_parent_id_by_name(st,parent_name); int parent_id = stats_tree_parent_id_by_name(st,parent_name);
stat_node *node; stat_node *node;
node = new_stat_node(st,name,parent_id,TRUE,TRUE); node = new_stat_node(st,name,parent_id,TRUE,TRUE);
if (node) if (node)
return node->id; return node->id;
else else
return 0; return 0;
@ -749,12 +749,12 @@ stats_tree_create_pivot_by_pname(stats_tree *st, const gchar *name,
extern int extern int
stats_tree_tick_pivot(stats_tree *st, int pivot_id, const gchar *pivot_value) stats_tree_tick_pivot(stats_tree *st, int pivot_id, const gchar *pivot_value)
{ {
stat_node *parent = g_ptr_array_index(st->parents,pivot_id); stat_node *parent = g_ptr_array_index(st->parents,pivot_id);
parent->counter++; parent->counter++;
stats_tree_manip_node( MN_INCREASE, st, pivot_value, pivot_id, FALSE, 1); stats_tree_manip_node( MN_INCREASE, st, pivot_value, pivot_id, FALSE, 1);
return pivot_id; return pivot_id;
} }

View File

@ -866,19 +866,12 @@ convert_string_to_hex(const char *string, size_t *nbytes)
char * char *
convert_string_case(const char *string, gboolean case_insensitive) convert_string_case(const char *string, gboolean case_insensitive)
{ {
char *out_string;
const char *p;
char c;
char *q;
if (case_insensitive) { if (case_insensitive) {
out_string = g_malloc(strlen(string) + 1); return g_utf8_strup(string, -1);
for (p = &string[0], q = &out_string[0]; (c = *p) != '\0'; p++, q++) } else {
*q = toupper((unsigned char)*p); return g_strdup(string);
*q = '\0'; }
} else
out_string = g_strdup(string);
return out_string;
} }
char * char *
@ -1044,7 +1037,7 @@ ws_strdup_escape_underscore (const gchar *str)
*q++ = *p++; *q++ = *p++;
} }
*q++ = '\0'; *q = '\0';
return new_str; return new_str;
} }
@ -1073,7 +1066,7 @@ ws_strdup_unescape_underscore (const gchar *str)
else else
p++; p++;
} }
*q++ = '\0'; *q = '\0';
return new_str; return new_str;
} }

7
file.c
View File

@ -1817,7 +1817,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame; frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame;
int selected_frame_num, preceding_frame_num, following_frame_num, prev_frame_num; int selected_frame_num, preceding_frame_num, following_frame_num, prev_frame_num;
gboolean selected_frame_seen; gboolean selected_frame_seen;
int frame_num;
float progbar_val; float progbar_val;
GTimeVal start_time; GTimeVal start_time;
gchar status_str[100]; gchar status_str[100];
@ -1906,7 +1905,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
g_get_current_time(&start_time); g_get_current_time(&start_time);
/* no previous row yet */ /* no previous row yet */
frame_num = -1;
prev_frame_num = -1; prev_frame_num = -1;
prev_frame = NULL; prev_frame = NULL;
@ -3881,7 +3879,6 @@ find_packet(capture_file *cf,
stop_flag = FALSE; stop_flag = FALSE;
g_get_current_time(&start_time); g_get_current_time(&start_time);
fdata = start_fd;
title = cf->sfilter?cf->sfilter:""; title = cf->sfilter?cf->sfilter:"";
for (;;) { for (;;) {
/* Create the progress bar if necessary. /* Create the progress bar if necessary.
@ -4029,7 +4026,9 @@ gboolean
cf_goto_frame(capture_file *cf, guint fnumber) cf_goto_frame(capture_file *cf, guint fnumber)
{ {
frame_data *fdata; frame_data *fdata;
#ifndef NEW_PACKET_LIST
int row; int row;
#endif
for (fdata = cf->plist_start; fdata != NULL && fdata->num < fnumber; fdata = fdata->next) for (fdata = cf->plist_start; fdata != NULL && fdata->num < fnumber; fdata = fdata->next)
; ;
@ -4047,7 +4046,7 @@ cf_goto_frame(capture_file *cf, guint fnumber)
} }
#ifdef NEW_PACKET_LIST #ifdef NEW_PACKET_LIST
row = new_packet_list_find_row_from_data(fdata, TRUE); new_packet_list_find_row_from_data(fdata, TRUE);
#else #else
/* We found that packet, and it's currently being displayed. /* We found that packet, and it's currently being displayed.
Find what row it's in. */ Find what row it's in. */

View File

@ -626,7 +626,7 @@ static void gtk_vumeter_setup_colors (GtkVUMeter *vumeter)
vumeter->b_colors[index].green = vumeter->b_colors[index - 1].green; vumeter->b_colors[index].green = vumeter->b_colors[index - 1].green;
vumeter->b_colors[index].blue = 0; vumeter->b_colors[index].blue = 0;
} }
if (vumeter->scaling == GTK_VUMETER_SCALING_LOG) { if (vumeter->scaling == GTK_VUMETER_SCALING_LOG && (vumeter->colors - second) > 0) {
/* Allocate from Green to Dark Green */ /* Allocate from Green to Dark Green */
f_step = vumeter->f_brightness / 2 / (vumeter->colors - second); f_step = vumeter->f_brightness / 2 / (vumeter->colors - second);
b_step = vumeter->b_brightness / 2 / (vumeter->colors - second); b_step = vumeter->b_brightness / 2 / (vumeter->colors - second);

View File

@ -151,7 +151,7 @@ phs_draw(phs_t *rs, int indentation)
} }
stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, " "); stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, " ");
} }
stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name); g_snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name);
printf("%-40s frames:%d bytes:%" G_GINT64_MODIFIER "d\n",str, rs->frames, rs->bytes); printf("%-40s frames:%d bytes:%" G_GINT64_MODIFIER "d\n",str, rs->frames, rs->bytes);
phs_draw(rs->child, indentation+1); phs_draw(rs->child, indentation+1);
} }