diff options
author | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-12 15:49:29 +0000 |
---|---|---|
committer | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-12 15:49:29 +0000 |
commit | a97684b7ac47de10fa5a2ebcdc3817949e075d8f (patch) | |
tree | 70f207ae7da5c419ca40ddb8bd9e8cbaf7852e95 | |
parent | 5d2cafbf544b14461f6d4b2a2ff0606b8c1c9f3e (diff) |
Don't assign to a proto_item * if the value won't be used: Coverity 916-918;
Also: use consistent indentation.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36587 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | epan/dissectors/packet-hilscher.c | 201 |
1 files changed, 100 insertions, 101 deletions
diff --git a/epan/dissectors/packet-hilscher.c b/epan/dissectors/packet-hilscher.c index cac5999e72..6ae793c3bd 100644 --- a/epan/dissectors/packet-hilscher.c +++ b/epan/dissectors/packet-hilscher.c @@ -69,53 +69,52 @@ static int hf_gpio_edge = -1; #define INFO_TYPE_OFFSET 14 static const value_string information_type[] = { - { 0x0, "netANALYZER GPIO event" }, - { 0, NULL } + { 0x0, "netANALYZER GPIO event" }, + { 0, NULL } }; static const value_string gpio_number[] = { - { 0x0, "GPIO 0" }, - { 0x1, "GPIO 1" }, - { 0x2, "GPIO 2" }, - { 0x3, "GPIO 3" }, - { 0, NULL } + { 0x0, "GPIO 0" }, + { 0x1, "GPIO 1" }, + { 0x2, "GPIO 2" }, + { 0x3, "GPIO 3" }, + { 0, NULL } }; static const value_string gpio_edge[] = { - { 0x0, "rising edge" }, - { 0x1, "falling edge" }, - { 0, NULL } + { 0x0, "rising edge" }, + { 0x1, "falling edge" }, + { 0, NULL } }; /* netANAYLZER dissector */ static void dissect_hilscher_netanalyzer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) { - proto_item *ti = NULL; - guint gpio_num; - guint gpio_edgex; - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "netANALYZER"); - - if (tree) - ti = proto_tree_add_item(tree, hf_information_type, tvb, offset, 1, FALSE); - - /* GPIO NUMBER */ - offset++; - if (tree) - ti = proto_tree_add_item (tree, hf_gpio_number, tvb, offset, 1, FALSE); - gpio_num = (tvb_get_guint8(tvb, offset) & 0x03); - - /* GPIO EDGE */ - offset++; - if (tree) - ti = proto_tree_add_item (tree, hf_gpio_edge, tvb, offset, 1, FALSE); - gpio_edgex = (tvb_get_guint8(tvb, offset) & 0x01); - - if (gpio_edgex == 0x00) - col_add_fstr(pinfo->cinfo, COL_INFO, "netANALYZER event on GPIO %d (rising edge)", gpio_num); - else - col_add_fstr(pinfo->cinfo, COL_INFO, "netANALYZER event on GPIO %d (falling edge)", gpio_num); + guint gpio_num; + guint gpio_edgex; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "netANALYZER"); + + if (tree) + proto_tree_add_item(tree, hf_information_type, tvb, offset, 1, FALSE); + + /* GPIO NUMBER */ + offset++; + if (tree) + proto_tree_add_item (tree, hf_gpio_number, tvb, offset, 1, FALSE); + gpio_num = (tvb_get_guint8(tvb, offset) & 0x03); + + /* GPIO EDGE */ + offset++; + if (tree) + proto_tree_add_item (tree, hf_gpio_edge, tvb, offset, 1, FALSE); + gpio_edgex = (tvb_get_guint8(tvb, offset) & 0x01); + + if (gpio_edgex == 0x00) + col_add_fstr(pinfo->cinfo, COL_INFO, "netANALYZER event on GPIO %d (rising edge)", gpio_num); + else + col_add_fstr(pinfo->cinfo, COL_INFO, "netANALYZER event on GPIO %d (falling edge)", gpio_num); } @@ -123,50 +122,50 @@ dissect_hilscher_netanalyzer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree static gboolean dissect_hilscher_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint info_type; - gint offset; - - /* Check that there's enough data */ - if (tvb_length(tvb) < 14) - return FALSE; - - /* check for Hilscher frame, this has a unique source MAC from Hilscher range and ethertype 0x88ff - First 14 bytes must be: xx xx xx xx xx xx 00 02 a2 ff ff ff 88 ff */ - if ((tvb_get_guint8(tvb, 6) == 0x00) && - (tvb_get_guint8(tvb, 7) == 0x02) && - (tvb_get_guint8(tvb, 8) == 0xa2) && - (tvb_get_guint8(tvb, 9) == 0xff) && - (tvb_get_guint8(tvb, 10) == 0xff) && - (tvb_get_guint8(tvb, 11) == 0xff) && - (tvb_get_guint8(tvb, 12) == 0x88) && - (tvb_get_guint8(tvb, 13) == 0xff) ) - { - - /* determine type of analyzer */ - offset = INFO_TYPE_OFFSET; - info_type = tvb_get_guint8(tvb, offset); - - switch (info_type) - { - /* this is a netANALYZER frame */ - case 0x00: - dissect_hilscher_netanalyzer(tvb, pinfo, tree, offset); - break; - - /* this is no Hilscher analyzer frame */ - default: - return FALSE; - break; - } - - } - else - { - /* this is no Hilscher analyzer frame */ - return FALSE; - } - - return TRUE; + guint info_type; + gint offset; + + /* Check that there's enough data */ + if (tvb_length(tvb) < 14) + return FALSE; + + /* check for Hilscher frame, this has a unique source MAC from Hilscher range and ethertype 0x88ff + First 14 bytes must be: xx xx xx xx xx xx 00 02 a2 ff ff ff 88 ff */ + if ((tvb_get_guint8(tvb, 6) == 0x00) && + (tvb_get_guint8(tvb, 7) == 0x02) && + (tvb_get_guint8(tvb, 8) == 0xa2) && + (tvb_get_guint8(tvb, 9) == 0xff) && + (tvb_get_guint8(tvb, 10) == 0xff) && + (tvb_get_guint8(tvb, 11) == 0xff) && + (tvb_get_guint8(tvb, 12) == 0x88) && + (tvb_get_guint8(tvb, 13) == 0xff) ) + { + + /* determine type of analyzer */ + offset = INFO_TYPE_OFFSET; + info_type = tvb_get_guint8(tvb, offset); + + switch (info_type) + { + /* this is a netANALYZER frame */ + case 0x00: + dissect_hilscher_netanalyzer(tvb, pinfo, tree, offset); + break; + + /* this is no Hilscher analyzer frame */ + default: + return FALSE; + break; + } + + } + else + { + /* this is no Hilscher analyzer frame */ + return FALSE; + } + + return TRUE; } @@ -174,35 +173,35 @@ dissect_hilscher_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_hilscher(void) { static hf_register_info hf[] = { - { &hf_information_type, - { "Hilscher information block type", "hilscher.information_type", - FT_UINT8, BASE_HEX, VALS(information_type), 0x0, NULL, HFILL } - }, - { &hf_gpio_number, - { "Event on", "hilscher.net_analyzer.gpio_number", FT_UINT8, - BASE_HEX, VALS(gpio_number), 0x0, NULL, HFILL } - }, - { &hf_gpio_edge, - { "Event type", "hilscher.net_analyzer.gpio_edge", FT_UINT8, - BASE_HEX, VALS(gpio_edge), 0x0, NULL, HFILL } - }, + { &hf_information_type, + { "Hilscher information block type", "hilscher.information_type", + FT_UINT8, BASE_HEX, VALS(information_type), 0x0, NULL, HFILL } + }, + { &hf_gpio_number, + { "Event on", "hilscher.net_analyzer.gpio_number", FT_UINT8, + BASE_HEX, VALS(gpio_number), 0x0, NULL, HFILL } + }, + { &hf_gpio_edge, + { "Event type", "hilscher.net_analyzer.gpio_edge", FT_UINT8, + BASE_HEX, VALS(gpio_edge), 0x0, NULL, HFILL } + }, }; static gint *ett[] = { - &ett_information_type, - &ett_gpio_number, - &ett_gpio_edge, + &ett_information_type, + &ett_gpio_number, + &ett_gpio_edge, }; - proto_hilscher = proto_register_protocol ("Hilscher analyzer dissector", /* name */ - "Hilscher", /* short name */ - "hilscher"); /* abbrev */ + proto_hilscher = proto_register_protocol ("Hilscher analyzer dissector", /* name */ + "Hilscher", /* short name */ + "hilscher"); /* abbrev */ hilscher_module = prefs_register_protocol(proto_hilscher, proto_reg_handoff_hilscher); prefs_register_bool_preference(hilscher_module, "enable", "Enable dissector", - "Enable this dissector (default is false)", - &hilscher_enable_dissector); + "Enable this dissector (default is false)", + &hilscher_enable_dissector); proto_register_field_array(proto_hilscher, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -214,8 +213,8 @@ void proto_reg_handoff_hilscher(void) static gboolean prefs_initialized = FALSE; if (!prefs_initialized) { - /* add heuristic dissector */ - heur_dissector_add("eth", dissect_hilscher_heur, proto_hilscher); + /* add heuristic dissector */ + heur_dissector_add("eth", dissect_hilscher_heur, proto_hilscher); prefs_initialized = TRUE; } |