Minor cleanup, including:

- Remove unneeded #includes;
- Simplify code slightly;
- Remove unused ett variable and related;
- Remove empty proto_reg_handoff...() functions;
- Fix a few cases of "set but unused".
- Do some whitespace changes.

svn path=/trunk/; revision=43748
This commit is contained in:
Bill Meier 2012-07-16 12:34:33 +00:00
parent 1e95104860
commit f41a04b7ab
5 changed files with 36 additions and 115 deletions

View File

@ -40,16 +40,9 @@
# include "config.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
#include <epan/emem.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
void proto_reg_handoff_dmx_chan(void);
static int proto_dmx_chan = -1;
@ -62,8 +55,8 @@ static int ett_dmx_chan = -1;
* Here are the global variables associated with the preferences for DMX
*/
static gint global_disp_chan_val_type = 0;
static gint global_disp_col_count = 16;
static gint global_disp_chan_nr_type = 0;
static gint global_disp_col_count = 16;
static gint global_disp_chan_nr_type = 0;
static void
dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@ -72,24 +65,24 @@ dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_clear(pinfo->cinfo, COL_INFO);
if (tree != NULL) {
const char* chan_format[] = {
static const char *chan_format[] = {
"%2u%% ",
"0x%02x ",
"%3u "
};
const char* string_format[] = {
static const char *string_format[] = {
"0x%03x: %s",
"%3u: %s"
};
emem_strbuf_t *chan_str = ep_strbuf_new_label("");
proto_item *item;
guint16 length,r,c,row_count;
guint8 v;
unsigned offset = 0;
proto_item *item;
guint16 length,r,c,row_count;
guint8 v;
unsigned offset = 0;
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_chan, tvb,
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_chan, tvb,
offset, -1, FALSE);
proto_tree *dmx_chan_tree = proto_item_add_subtree(ti, ett_dmx_chan);
proto_tree *dmx_chan_tree = proto_item_add_subtree(ti, ett_dmx_chan);
length = tvb_reported_length_remaining(tvb, offset);
@ -123,7 +116,6 @@ dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
item = proto_tree_add_item(dmx_chan_tree, hf_dmx_chan_output_data_filter, tvb,
offset, length, ENC_NA );
PROTO_ITEM_SET_HIDDEN(item);
offset += length;
}
}
@ -198,7 +190,3 @@ proto_register_dmx_chan(void)
col_count, ENC_BIG_ENDIAN);
}
void
proto_reg_handoff_dmx_chan(void)
{
}

View File

@ -40,19 +40,10 @@
# include "config.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#define DMX_SC_SIP 0xCF
void proto_reg_handoff_dmx_sip(void);
static int proto_dmx_sip = -1;
static int hf_dmx_sip_byte_count = -1;
@ -80,8 +71,8 @@ static int ett_dmx_sip = -1;
static guint8
dmx_sip_checksum(tvbuff_t *tvb, unsigned length)
{
guint8 sum = DMX_SC_SIP;
unsigned i;
guint8 sum = DMX_SC_SIP;
unsigned i;
for (i = 0; i < length; i++)
sum += tvb_get_guint8(tvb, i);
return sum;
@ -94,9 +85,9 @@ dissect_dmx_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_clear(pinfo->cinfo, COL_INFO);
if (tree != NULL) {
unsigned offset = 0;
unsigned byte_count;
unsigned checksum, checksum_shouldbe;
unsigned offset = 0;
unsigned byte_count;
unsigned checksum, checksum_shouldbe;
proto_item *item;
proto_tree *checksum_tree;
@ -314,7 +305,3 @@ proto_register_dmx_sip(void)
register_dissector("dmx-sip", dissect_dmx_sip, proto_dmx_sip);
}
void
proto_reg_handoff_dmx_sip(void)
{
}

View File

@ -40,19 +40,10 @@
# include "config.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#define DMX_TEST_PACKET_SIZE 512
#define DMX_TEST_VALUE 0x55
void proto_reg_handoff_dmx_test(void);
#define DMX_TEST_PACKET_SIZE 512
#define DMX_TEST_VALUE 0x55
static int proto_dmx_test = -1;
@ -69,9 +60,9 @@ dissect_dmx_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_clear(pinfo->cinfo, COL_INFO);
if (tree != NULL) {
unsigned offset = 0;
unsigned size, i, test_data_is_ok;
proto_tree* test_data_tree;
unsigned offset = 0;
unsigned size, i, test_data_is_ok;
proto_tree *test_data_tree;
proto_item *item;
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_test, tvb,
@ -151,8 +142,3 @@ proto_register_dmx_test(void)
proto_register_subtree_array(ett, array_length(ett));
register_dissector("dmx-test", dissect_dmx_test, proto_dmx_test);
}
void
proto_reg_handoff_dmx_test(void)
{
}

View File

@ -40,16 +40,7 @@
# include "config.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
void proto_reg_handoff_dmx_text(void);
static int proto_dmx_text = -1;
@ -85,7 +76,6 @@ dissect_dmx_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(dmx_text_tree, hf_dmx_text_string, tvb,
offset, size, ENC_BIG_ENDIAN);
offset += size;
}
}
@ -120,7 +110,3 @@ proto_register_dmx_text(void)
register_dissector("dmx-text", dissect_dmx_text, proto_dmx_text);
}
void
proto_reg_handoff_dmx_text(void)
{
}

View File

@ -4,7 +4,7 @@
* $Id$
*
* This dissector is written by
*
*
* Erwin Rol <erwin@erwinrol.com>
* Copyright 2012 Erwin Rol
*
@ -21,7 +21,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor
@ -41,14 +41,7 @@
# include "config.h"
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#define DMX_SC_DMX 0x00
#define DMX_SC_TEXT 0x17
@ -70,23 +63,21 @@ void proto_reg_handoff_dmx(void);
static int proto_dmx = -1;
static int hf_dmx_start_code = -1;
static int hf_dmx_frame_data = -1;
static int ett_dmx = -1;
static dissector_handle_t rdm_handle;
static dissector_handle_t dmx_chan_handle;
static dissector_handle_t dmx_test_handle;
static dissector_handle_t dmx_text_handle;
static dissector_handle_t dmx_sip_handle;
static dissector_handle_t data_handle;
static void
dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
tvbuff_t *next_tvb = NULL;
unsigned offset = 0;
guint8 start_code;
tvbuff_t *next_tvb;
unsigned offset = 0;
guint8 start_code;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX");
col_clear(pinfo->cinfo, COL_INFO);
@ -96,31 +87,27 @@ dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset, 1, ENC_BIG_ENDIAN);
offset++;
next_tvb = tvb_new_subset_remaining(tvb, offset);
switch (start_code) {
case DMX_SC_DMX:
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(dmx_chan_handle, next_tvb, pinfo, tree);
break;
case DMX_SC_TEXT:
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(dmx_text_handle, next_tvb, pinfo, tree);
break;
case DMX_SC_TEST:
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(dmx_test_handle, next_tvb, pinfo, tree);
break;
case DMX_SC_RDM:
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(rdm_handle, next_tvb, pinfo, tree);
break;
case DMX_SC_SIP:
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(dmx_sip_handle, next_tvb, pinfo, tree);
break;
default:
if (offset < tvb_length(tvb))
proto_tree_add_item(tree, hf_dmx_frame_data, tvb,
offset, -1, ENC_NA);
call_dissector(data_handle, next_tvb, pinfo, tree);
break;
}
}
@ -133,33 +120,20 @@ proto_register_dmx(void)
{ "Start Code", "dmx.start_code",
FT_UINT8, BASE_HEX, VALS(dmx_sc_vals), 0x0,
NULL, HFILL }},
{ &hf_dmx_frame_data,
{ "Frame Data", "dmx.frame_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
};
static gint *ett[] = {
&ett_dmx
};
proto_dmx = proto_register_protocol("DMX", "DMX", "dmx");
proto_register_field_array(proto_dmx, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("dmx", dissect_dmx, proto_dmx);
}
void
proto_reg_handoff_dmx(void)
{
static gboolean dmx_initialized = FALSE;
if (!dmx_initialized) {
rdm_handle = find_dissector("rdm");
dmx_chan_handle = find_dissector("dmx-chan");
dmx_test_handle = find_dissector("dmx-test");
dmx_text_handle = find_dissector("dmx-text");
dmx_sip_handle = find_dissector("dmx-sip");
dmx_initialized = TRUE;
}
rdm_handle = find_dissector("rdm");
dmx_chan_handle = find_dissector("dmx-chan");
dmx_test_handle = find_dissector("dmx-test");
dmx_text_handle = find_dissector("dmx-text");
dmx_sip_handle = find_dissector("dmx-sip");
data_handle = find_dissector("data");
}