From 3cd7991f7f6bf6a776b50f4ee11812cbedc4454e Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Fri, 27 Nov 2015 11:34:51 +0100 Subject: Fix display of bytes as EBCDIC MSVC compiler does not support properly setting an enum being part of a bit field. For example the following code: pinfo->fd->flags.encoding = PACKET_CHAR_ENC_CHAR_EBCDIC; changes pinfo->fd->flags.encoding from 0x0 to 0xfffffffe instead of 0x1 Let's put back an unsigned int definition (like it is in master-1.12 branch) and add explicit casts where required Bug: 11787 Change-Id: Idae0140fb6c172f1b3dbf10baefc8cfb00128f4c Reviewed-on: https://code.wireshark.org/review/12220 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin (cherry picked from commit 62b03da49a3e6c32f788da375faea2ca47fa2aa9) Reviewed-on: https://code.wireshark.org/review/12229 --- epan/frame_data.h | 3 ++- epan/print.c | 4 ++-- ui/gtk/packet_panes.c | 4 ++-- ui/qt/packet_dialog.cpp | 2 +- ui/qt/packet_list.cpp | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/epan/frame_data.h b/epan/frame_data.h index 2980b04ca9..b0ae6d704c 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -74,7 +74,8 @@ typedef struct _frame_data { struct { unsigned int passed_dfilter : 1; /**< 1 = display, 0 = no display */ unsigned int dependent_of_displayed : 1; /**< 1 if a displayed frame depends on this frame */ - packet_char_enc encoding : 1; /**< Character encoding (ASCII, EBCDIC...) */ + /* Do NOT use packet_char_enc enum here: MSVC compiler does not handle an enum in a bit field properly */ + unsigned int encoding : 1; /**< Character encoding (ASCII, EBCDIC...) */ unsigned int visited : 1; /**< Has this packet been visited yet? 1=Yes,0=No*/ unsigned int marked : 1; /**< 1 = marked by user, 0 = normal */ unsigned int ref_time : 1; /**< 1 = marked as a reference time frame, 0 = normal */ diff --git a/epan/print.c b/epan/print.c index f97c5c3be0..257b2b2c07 100644 --- a/epan/print.c +++ b/epan/print.c @@ -121,7 +121,7 @@ proto_tree_print(print_args_t *print_args, epan_dissect_t *edt, data.stream = stream; data.success = TRUE; data.src_list = edt->pi.data_src; - data.encoding = edt->pi.fd->flags.encoding; + data.encoding = (packet_char_enc)edt->pi.fd->flags.encoding; data.print_dissections = print_args->print_dissections; /* If we're printing the entire packet in hex, don't print uninterpreted data fields in hex as well. */ @@ -901,7 +901,7 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt) return TRUE; cp = tvb_get_ptr(tvb, 0, length); if (!print_hex_data_buffer(stream, cp, length, - edt->pi.fd->flags.encoding)) + (packet_char_enc)edt->pi.fd->flags.encoding)) return FALSE; } return TRUE; diff --git a/ui/gtk/packet_panes.c b/ui/gtk/packet_panes.c index 71de45a3b6..638656e416 100644 --- a/ui/gtk/packet_panes.c +++ b/ui/gtk/packet_panes.c @@ -1006,7 +1006,7 @@ packet_hex_print(GtkWidget *bv, const guint8 *pd, frame_data *fd, /* stig: it should be done only for bitview... */ if (recent.gui_bytes_view != BYTES_BITS) bmask = 0x00; - packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, fd->flags.encoding); + packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, (packet_char_enc)fd->flags.encoding); } void @@ -1047,7 +1047,7 @@ packet_hex_editor_print(GtkWidget *bv, const guint8 *pd, frame_data *fd, int off g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_PROTO_START_KEY, GINT_TO_POINTER(pstart)); g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_PROTO_END_KEY, GINT_TO_POINTER(pend)); - packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, fd->flags.encoding); + packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, (packet_char_enc)fd->flags.encoding); } /* diff --git a/ui/qt/packet_dialog.cpp b/ui/qt/packet_dialog.cpp index e8efeadac5..a562f37f3f 100644 --- a/ui/qt/packet_dialog.cpp +++ b/ui/qt/packet_dialog.cpp @@ -83,7 +83,7 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) source = (struct data_source *)src_le->data; source_name = get_data_source_name(source); byte_view_tab_->addTab(source_name, get_data_source_tvb(source), edt_.tree, proto_tree_, - cap_file_.capFile()->current_frame->flags.encoding); + (packet_char_enc)cap_file_.capFile()->current_frame->flags.encoding); wmem_free(NULL, source_name); } byte_view_tab_->setCurrentIndex(0); diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 4c0ec0bdda..60fadf6d7a 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -475,7 +475,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) { source = (struct data_source *)src_le->data; source_name = get_data_source_name(source); - byte_view_tab_->addTab(source_name, get_data_source_tvb(source), cap_file_->edt->tree, proto_tree_, cap_file_->current_frame->flags.encoding); + byte_view_tab_->addTab(source_name, get_data_source_tvb(source), cap_file_->edt->tree, proto_tree_, (packet_char_enc)cap_file_->current_frame->flags.encoding); wmem_free(NULL, source_name); } byte_view_tab_->setCurrentIndex(0); -- cgit v1.2.1