diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2013-01-31 20:51:15 +0000 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2013-01-31 20:51:15 +0000 |
commit | a50877b1e59b8a1d9f120cf53c503c981e63f4f1 (patch) | |
tree | 48c051e70dd5e5aa1396355b8fce2ed97548838f | |
parent | 98c1748e12d3413f87befc2ffc2ad20a8c0d407a (diff) |
Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
http://www.wireshark.org/download/automated/analysis/scan-build-2013-01-31-1/report-vSXKx6.html#EndPath
use NULL instead of 0 for pointers
remove some unnecessary if (tree) checks
svn path=/trunk/; revision=47395
-rw-r--r-- | epan/dissectors/packet-cups.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/epan/dissectors/packet-cups.c b/epan/dissectors/packet-cups.c index 88de476b05..9f25636a3b 100644 --- a/epan/dissectors/packet-cups.c +++ b/epan/dissectors/packet-cups.c @@ -120,9 +120,9 @@ static const guint8* get_unquoted_string(tvbuff_t *tvb, gint offset, static void dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *cups_tree = 0; - proto_tree *ptype_subtree = 0; - proto_item *ti = 0; + proto_tree *cups_tree = NULL; + proto_tree *ptype_subtree = NULL; + proto_item *ti = NULL; gint offset = 0; gint next_offset; guint len; @@ -133,11 +133,8 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_CUPS); col_clear(pinfo->cinfo, COL_INFO); - if (tree) { - ti = proto_tree_add_item(tree, proto_cups, tvb, offset, -1, - ENC_NA); - cups_tree = proto_item_add_subtree(ti, ett_cups); - } + ti = proto_tree_add_item(tree, proto_cups, tvb, offset, -1, ENC_NA); + cups_tree = proto_item_add_subtree(ti, ett_cups); /* Format (1450 bytes max.): */ /* type state uri ["location" ["info" ["make-and-model"]]]\n */ @@ -145,29 +142,27 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ptype = get_hex_uint(tvb, offset, &next_offset); len = next_offset - offset; if (len != 0) { - if (cups_tree) { - ti = proto_tree_add_uint(cups_tree, hf_cups_ptype, tvb, offset, len, ptype); - ptype_subtree = proto_item_add_subtree(ti, ett_cups_ptype); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_default, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_implicit, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_variable, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_large, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_medium, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_small, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_sort, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_bind, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_cover, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_punch, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_collate, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_copies, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_staple, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_duplex, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_color, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_bw, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_remote, tvb, offset, len, ENC_BIG_ENDIAN); - proto_tree_add_item(ptype_subtree, hf_cups_ptype_class, tvb, offset, len, ENC_BIG_ENDIAN); - } - } + ti = proto_tree_add_uint(cups_tree, hf_cups_ptype, tvb, offset, len, ptype); + ptype_subtree = proto_item_add_subtree(ti, ett_cups_ptype); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_default, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_implicit, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_variable, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_large, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_medium, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_small, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_sort, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_bind, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_cover, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_punch, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_collate, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_copies, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_staple, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_duplex, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_color, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_bw, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_remote, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_class, tvb, offset, len, ENC_BIG_ENDIAN); + } offset = next_offset; if (!skip_space(tvb, offset, &next_offset)) @@ -190,11 +185,10 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) str = get_unquoted_string(tvb, offset, &next_offset, &len); if (str == NULL) return; /* separator/terminator not found */ - if (cups_tree) - proto_tree_add_text(cups_tree, tvb, offset, len, - "URI: %.*s", - (guint16) len, str); - col_add_fstr(pinfo->cinfo, COL_INFO, + proto_tree_add_text(cups_tree, tvb, offset, len, + "URI: %.*s", + (guint16) len, str); + col_add_fstr(pinfo->cinfo, COL_INFO, "%.*s (%s)", (guint16) len, str, val_to_str(state, cups_state_values, "0x%x")); @@ -237,9 +231,6 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_text(cups_tree, tvb, offset+1, len, "Make and model: \"%.*s\"", (guint16) len, str); - offset = next_offset; - - return; } static guint |