Wireshark-dev: [Wireshark-dev] Anonymous union in epan/dissectors/packet-scsi-osd.c not valid w
From: Albert Chin <wireshark-dev@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 5 Nov 2006 09:41:51 -0600
On Solaris 2.6, compiling 0.99.4 with the Sun C compiler fails because
anonymous unions are not valid. epan/dissectors/packet-scsi-osd.c has:
typedef struct _scsi_osd_extra_data_t {
guint16 svcaction;
guint8 gsatype;
union {
struct { /* gsatype: attribute list */
guint32 get_list_length;
guint32 get_list_offset;
guint32 get_list_allocation_length;
guint32 retreived_list_offset;
guint32 set_list_length;
guint32 set_list_offset;
};
};
} scsi_osd_extra_data_t;
epan/emem.h had a similar problem awhile ago.
Patch attached.
--
albert chin (china@xxxxxxxxxxxxxxxxxx)
Index: epan/dissectors/packet-scsi-osd.c
===================================================================
--- epan/dissectors/packet-scsi-osd.c (revision 19811)
+++ epan/dissectors/packet-scsi-osd.c (working copy)
@@ -184,8 +184,8 @@
guint32 retreived_list_offset;
guint32 set_list_length;
guint32 set_list_offset;
- };
- };
+ } s;
+ } u;
} scsi_osd_extra_data_t;
static void
@@ -494,33 +494,33 @@
break;
case 3: /* 5.2.2.3 attribute list */
proto_tree_add_item(tree, hf_scsi_osd_get_attributes_list_length, tvb, offset, 4, 0);
- extra_data->get_list_length=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.get_list_length=tvb_get_ntohl(tvb, offset);
offset+=4;
/* 4.12.5 */
- extra_data->get_list_offset=tvb_get_ntohl(tvb, offset);
- extra_data->get_list_offset=(extra_data->get_list_offset&0x0fffffff)<<((extra_data->get_list_offset>>28)&0x0f);
- extra_data->get_list_offset<<=8;
- proto_tree_add_uint(tree, hf_scsi_osd_get_attributes_list_offset, tvb, offset, 4, extra_data->get_list_offset);
+ extra_data->u.s.get_list_offset=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.get_list_offset=(extra_data->u.s.get_list_offset&0x0fffffff)<<((extra_data->u.s.get_list_offset>>28)&0x0f);
+ extra_data->u.s.get_list_offset<<=8;
+ proto_tree_add_uint(tree, hf_scsi_osd_get_attributes_list_offset, tvb, offset, 4, extra_data->u.s.get_list_offset);
offset+=4;
proto_tree_add_item(tree, hf_scsi_osd_get_attributes_allocation_length, tvb, offset, 4, 0);
- extra_data->get_list_allocation_length=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.get_list_allocation_length=tvb_get_ntohl(tvb, offset);
offset+=4;
/* 4.12.5 */
- extra_data->retreived_list_offset=tvb_get_ntohl(tvb, offset);
- extra_data->retreived_list_offset=(extra_data->retreived_list_offset&0x0fffffff)<<((extra_data->retreived_list_offset>>28)&0x0f);
- extra_data->retreived_list_offset<<=8;
- proto_tree_add_uint(tree, hf_scsi_osd_retreived_attributes_offset, tvb, offset, 4, extra_data->retreived_list_offset);
+ extra_data->u.s.retreived_list_offset=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.retreived_list_offset=(extra_data->u.s.retreived_list_offset&0x0fffffff)<<((extra_data->u.s.retreived_list_offset>>28)&0x0f);
+ extra_data->u.s.retreived_list_offset<<=8;
+ proto_tree_add_uint(tree, hf_scsi_osd_retreived_attributes_offset, tvb, offset, 4, extra_data->u.s.retreived_list_offset);
offset+=4;
proto_tree_add_item(tree, hf_scsi_osd_set_attributes_list_length, tvb, offset, 4, 0);
- extra_data->set_list_length=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.set_list_length=tvb_get_ntohl(tvb, offset);
offset+=4;
proto_tree_add_item(tree, hf_scsi_osd_set_attributes_list_offset, tvb, offset, 4, 0);
- extra_data->set_list_offset=tvb_get_ntohl(tvb, offset);
+ extra_data->u.s.set_list_offset=tvb_get_ntohl(tvb, offset);
offset+=4;
/* 4 reserved bytes */
@@ -549,11 +549,11 @@
/*qqq*/
break;
case 3: /* 5.2.2.3 attribute list */
- if(extra_data->get_list_length){
- dissect_osd_attributes_list(pinfo, tvb, extra_data->get_list_offset, tree);
+ if(extra_data->u.s.get_list_length){
+ dissect_osd_attributes_list(pinfo, tvb, extra_data->u.s.get_list_offset, tree);
}
- if(extra_data->set_list_length){
- proto_tree_add_text(tree, tvb, extra_data->set_list_offset, extra_data->set_list_length, "Set Attributes Data");
+ if(extra_data->u.s.set_list_length){
+ proto_tree_add_text(tree, tvb, extra_data->u.s.set_list_offset, extra_data->u.s.set_list_length, "Set Attributes Data");
}
break;
}
@@ -578,8 +578,8 @@
/*qqq*/
break;
case 3: /* 5.2.2.3 attribute list */
- if(extra_data->get_list_allocation_length){
- dissect_osd_attributes_list(pinfo, tvb, extra_data->retreived_list_offset, tree);
+ if(extra_data->u.s.get_list_allocation_length){
+ dissect_osd_attributes_list(pinfo, tvb, extra_data->u.s.retreived_list_offset, tree);
}
break;
}
- Follow-Ups:
- Prev by Date: Re: [Wireshark-dev] contribution: OpenChange dissector for NSPI protocol
- Next by Date: Re: [Wireshark-dev] contribution: OpenChange dissector for NSPI protocol
- Previous by thread: Re: [Wireshark-dev] OSX buildbot: No rule to make target `.deps/lemon.Po'. Stop.
- Next by thread: Re: [Wireshark-dev] Anonymous union in epan/dissectors/packet-scsi-osd.c not valid with Sun C compiler
- Index(es):