aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2018-01-09 13:28:17 +0100
committerAnders Broman <a.broman58@gmail.com>2018-01-09 13:07:32 +0000
commit4e87f6c01a7bd0dc29959492e758eb6fae0a9fc9 (patch)
treee9f51a401c3243349ff2f304c97aa1d64d4a9969 /epan/proto.c
parent5f24a78113ab01b68d36dc7263e23adb39dc1707 (diff)
proto: Small code cleanup in proto_register_protocol
- Remove unneeded assignments - Fix some comments and whitespace Change-Id: I79de66315db29fe7c59fc18f3b3b464ac55121c8 Reviewed-on: https://code.wireshark.org/review/25221 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/epan/proto.c b/epan/proto.c
index a89c901ccb..51a402358e 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -6442,9 +6442,7 @@ proto_register_protocol(const char *name, const char *short_name,
const char *filter_name)
{
protocol_t *protocol;
- const protocol_t *existing_protocol = NULL;
header_field_info *hfinfo;
- int proto_id;
guint i;
gchar c;
gboolean found_invalid;
@@ -6457,15 +6455,13 @@ proto_register_protocol(const char *name, const char *short_name,
* protocol with the same name.
*/
- existing_protocol = (const protocol_t *)g_hash_table_lookup(proto_names, name);
- if (existing_protocol != NULL) {
+ if (g_hash_table_lookup(proto_names, name)) {
/* g_error will terminate the program */
g_error("Duplicate protocol name \"%s\"!"
" This might be caused by an inappropriate plugin or a development error.", name);
}
- existing_protocol = (const protocol_t *)g_hash_table_lookup(proto_short_names, short_name);
- if (existing_protocol != NULL) {
+ if (g_hash_table_lookup(proto_short_names, short_name)) {
g_error("Duplicate protocol short_name \"%s\"!"
" This might be caused by an inappropriate plugin or a development error.", short_name);
}
@@ -6482,27 +6478,28 @@ proto_register_protocol(const char *name, const char *short_name,
" Allowed are lower characters, digits, '-', '_' and '.'."
" This might be caused by an inappropriate plugin or a development error.", filter_name);
}
- existing_protocol = (const protocol_t *)g_hash_table_lookup(proto_filter_names, filter_name);
- if (existing_protocol != NULL) {
+
+ if (g_hash_table_lookup(proto_filter_names, filter_name)) {
g_error("Duplicate protocol filter_name \"%s\"!"
" This might be caused by an inappropriate plugin or a development error.", filter_name);
}
- /* Add this protocol to the list of known protocols; the list
- is sorted by protocol short name. */
+ /*
+ * Add this protocol to the list of known protocols;
+ * the list is sorted by protocol short name.
+ */
protocol = g_new(protocol_t, 1);
protocol->name = name;
protocol->short_name = short_name;
protocol->filter_name = filter_name;
- /*protocol->fields = g_ptr_array_new();*/
- /* Delegate until actually needed and use g_ptr_array_sized_new*/
- protocol->fields = NULL;
+ protocol->fields = NULL; /* Delegate until actually needed */
protocol->is_enabled = TRUE; /* protocol is enabled by default */
protocol->enabled_by_default = TRUE; /* see previous comment */
protocol->can_toggle = TRUE;
protocol->parent_proto_id = -1;
protocol->heur_list = NULL;
- /* list will be sorted later by name, when all protocols completed registering */
+
+ /* List will be sorted later by name, when all protocols completed registering */
protocols = g_list_prepend(protocols, protocol);
g_hash_table_insert(proto_names, (gpointer)name, protocol);
g_hash_table_insert(proto_filter_names, (gpointer)filter_name, protocol);
@@ -6518,11 +6515,10 @@ proto_register_protocol(const char *name, const char *short_name,
hfinfo->bitmask = 0;
hfinfo->ref_type = HF_REF_TYPE_NONE;
hfinfo->blurb = NULL;
- hfinfo->parent = -1; /* this field differentiates protos and fields */
+ hfinfo->parent = -1; /* This field differentiates protos and fields */
- proto_id = proto_register_field_init(hfinfo, hfinfo->parent);
- protocol->proto_id = proto_id;
- return proto_id;
+ protocol->proto_id = proto_register_field_init(hfinfo, hfinfo->parent);
+ return protocol->proto_id;
}
int
@@ -6564,7 +6560,7 @@ proto_register_protocol_in_name_only(const char *name, const char *short_name, c
protocol->name = name;
protocol->short_name = short_name;
protocol->filter_name = filter_name;
- protocol->fields = NULL;
+ protocol->fields = NULL; /* Delegate until actually needed */
/* Enabling and toggling is really determined by parent protocol,
but provide default values here */
@@ -6574,7 +6570,8 @@ proto_register_protocol_in_name_only(const char *name, const char *short_name, c
protocol->parent_proto_id = parent_proto;
protocol->heur_list = NULL;
- /* list will be sorted later by name, when all protocols completed registering */
+
+ /* List will be sorted later by name, when all protocols completed registering */
pino_protocols = g_list_prepend(pino_protocols, protocol);
/* Here we allocate a new header_field_info struct */
@@ -6590,7 +6587,7 @@ proto_register_protocol_in_name_only(const char *name, const char *short_name, c
hfinfo->bitmask = 0;
hfinfo->ref_type = HF_REF_TYPE_NONE;
hfinfo->blurb = NULL;
- hfinfo->parent = -1; /* this field differentiates protos and fields */
+ hfinfo->parent = -1; /* This field differentiates protos and fields */
protocol->proto_id = proto_register_field_init(hfinfo, hfinfo->parent);
return protocol->proto_id;