From c914d509a026163023ee0b02fb50d14865a81d63 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 15 May 2006 05:28:56 +0000 Subject: Fix some compiler warnings. That requires that we define G_GINT64_MODIFIER ourselves if glib.h doesn't define it for us, as that's what should be used to print 64-bit integral values in any calls that use any of the GLib printf functions (directly or indirectly). svn path=/trunk/; revision=18154 --- wiretap/acinclude.m4 | 36 ++++++++++++++++++++++++++++++++++++ wiretap/ber.c | 12 +++++++----- wiretap/configure.in | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 5 deletions(-) (limited to 'wiretap') diff --git a/wiretap/acinclude.m4 b/wiretap/acinclude.m4 index 52f1299d1c..08e232ffe5 100644 --- a/wiretap/acinclude.m4 +++ b/wiretap/acinclude.m4 @@ -234,3 +234,39 @@ AC_DEFUN([AC_WIRETAP_ZLIB_CHECK], LIBS="$ac_save_LIBS" fi ]) + +dnl +dnl Check whether a given format can be used to print 64-bit integers +dnl +AC_DEFUN([AC_WIRETAP_CHECK_64BIT_FORMAT], +[ + AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers]) + AC_RUN_IFELSE( + [ + AC_LANG_SOURCE( + [[ + #include + #include + #include + + main() + { + guint64 t = 1; + char strbuf[16+1]; + g_sprintf(strbuf, "%016$1x", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + ]]) + ], + [ + AC_DEFINE(G_GINT64_MODIFIER, "$1", [Format modifier for printing 64-bit numbers]) + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + $2 + ]) +]) diff --git a/wiretap/ber.c b/wiretap/ber.c index 4bcb6687aa..70183cacb0 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -45,6 +45,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, long *data_offset) { guint8 *buf; + gint64 file_size; int packet_size; struct stat statb; @@ -56,19 +57,20 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, long *data_offse *data_offset = wth->data_offset; - if((packet_size = wtap_file_size(wth, err)) == -1) + if ((file_size = wtap_file_size(wth, err)) == -1) return FALSE; - if (packet_size > WTAP_MAX_PACKET_SIZE) { + if (file_size > WTAP_MAX_PACKET_SIZE) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_RECORD; - *err_info = g_strdup_printf("ber: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); + *err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u", + file_size, WTAP_MAX_PACKET_SIZE); return FALSE; } + packet_size = (int)file_size; buffer_assure_space(wth->frame_buffer, packet_size); buf = buffer_start_ptr(wth->frame_buffer); @@ -92,7 +94,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, long *data_offse return TRUE; } -static gboolean ber_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, +static gboolean ber_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int length, int *err, gchar **err_info _U_) { int packet_size = length; diff --git a/wiretap/configure.in b/wiretap/configure.in index ad14196f2e..1a8c34911a 100644 --- a/wiretap/configure.in +++ b/wiretap/configure.in @@ -175,6 +175,42 @@ AC_CHECK_HEADERS(sys/time.h netinet/in.h unistd.h fcntl.h sys/stat.h sys/types.h # We must know our byte order AC_C_BIGENDIAN +# +# Does GLib define G_GINT64_MODIFIER? +# +AC_MSG_CHECKING([[whether glib.h defines the G_GINT64_MODIFIER macro]]) +AC_COMPILE_IFELSE( + [ + AC_LANG_SOURCE( + [[ + #include + #include + #include + + main() + { + char strbuf[16+1]; + g_sprintf(strbuf, "%" G_GINT64_MODIFIER "x\n", (gint64)1); + } + ]]) + ], + [ + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + AC_WIRETAP_CHECK_64BIT_FORMAT(ll, + [ + AC_WIRETAP_CHECK_64BIT_FORMAT(L, + [ + AC_WIRETAP_CHECK_64BIT_FORMAT(q, + [ + AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) + ]) + ]) + ]) + ]) + # # Look for libpcap, so we can include in libpcap.c if it's # found. -- cgit v1.2.3