From e548eceeac8a3b57e7f656de89cad2a9913ffd44 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 1 May 2020 14:31:19 -0700 Subject: [PATCH] wiretap: combine common code into a common routine. Change-Id: I7329bea02e2264ffb70515b681609bff91575267 Reviewed-on: https://code.wireshark.org/review/37012 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- wiretap/wtap.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 3fae62170d..3d9ebb44af 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1307,9 +1307,8 @@ wtapng_process_dsb(wtap *wth, wtap_block_t dsb) wth->add_new_secrets(dsb_mand->secrets_type, dsb_mand->secrets_data, dsb_mand->secrets_len); } -gboolean -wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, - gchar **err_info, gint64 *offset) +static void +wtap_init_rec(wtap *wth, wtap_rec *rec) { /* * Set the packet encapsulation to the file's encapsulation @@ -1323,6 +1322,16 @@ wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, */ rec->rec_header.packet_header.pkt_encap = wth->file_encap; rec->tsprec = wth->file_tsprec; +} + +gboolean +wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, + gchar **err_info, gint64 *offset) +{ + /* + * Initialize the record to default values. + */ + wtap_init_rec(wth, rec); *err = 0; *err_info = NULL; @@ -1473,17 +1482,9 @@ wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* - * Set the packet encapsulation to the file's encapsulation - * value; if that's not WTAP_ENCAP_PER_PACKET, it's the - * right answer (and means that the read routine for this - * capture file type doesn't have to set it), and if it - * *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it - * anyway. - * - * Do the same for the packet time stamp resolution. + * Initialize the record to default values. */ - rec->rec_header.packet_header.pkt_encap = wth->file_encap; - rec->tsprec = wth->file_tsprec; + wtap_init_rec(wth, rec); *err = 0; *err_info = NULL;