From fe5248717faa1c99a4d0c761fa8da63afffc5d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 17 Dec 2021 20:05:19 +0000 Subject: [PATCH] Replace g_snprintf() with snprintf() Use macros from inttypes.h with format strings. --- capinfos.c | 82 ++++----- capture/capture-pcap-util.c | 10 +- capture/capture-wpcap.c | 8 +- capture/capture_sync.c | 38 ++--- capture/iface_monitor.c | 2 +- doc/README.stats_tree | 4 +- dumpcap.c | 156 +++++++++--------- editcap.c | 4 +- extcap.c | 2 +- extcap/androiddump.c | 22 +-- extcap/sdjournal.c | 6 +- file.c | 26 +-- fuzz/fuzzshark.c | 2 +- plugins/epan/ethercat/packet-ams.c | 2 +- plugins/epan/ethercat/packet-ecatmb.c | 50 +++--- .../epan/ethercat/packet-ethercat-datagram.c | 22 +-- plugins/epan/ethercat/packet-ioraw.c | 2 +- plugins/epan/ethercat/packet-nv.c | 6 +- plugins/epan/irda/packet-irda.c | 6 +- plugins/epan/mate/mate_grammar.lemon | 2 +- plugins/epan/mate/mate_setup.c | 2 +- plugins/epan/mate/mate_util.c | 6 +- plugins/epan/opcua/opcua_simpletypes.c | 2 +- plugins/epan/profinet/packet-pn-ptcp.c | 6 +- plugins/epan/profinet/packet-pn-rt.c | 6 +- plugins/epan/stats_tree/pinfo_stats_tree.c | 2 +- rawshark.c | 4 +- reordercap.c | 2 +- ringbuffer.c | 2 +- sharkd_session.c | 26 +-- text2pcap.c | 2 +- tfshark.c | 18 +- tools/checkAPIs.pl | 2 +- tshark.c | 16 +- ui/capture.c | 12 +- ui/cli/tap-endpoints.c | 12 +- ui/cli/tap-exportobject.c | 2 +- ui/cli/tap-follow.c | 2 +- ui/cli/tap-iostat.c | 26 +-- ui/cli/tap-iousers.c | 12 +- ui/cli/tap-protohierstat.c | 8 +- ui/cli/tap-rpcprogs.c | 4 +- ui/cli/tap-rtp.c | 2 +- ui/cli/tap-simple_stattable.c | 2 +- ui/proto_hier_stats.c | 2 +- ui/qt/follow_stream_dialog.cpp | 4 +- ui/qt/main.cpp | 16 +- ui/qt/models/export_objects_model.cpp | 2 +- ui/qt/sctp_chunk_statistics_dialog.cpp | 4 +- ui/qt/show_packet_bytes_dialog.cpp | 2 +- ui/summary.c | 2 +- ui/traffic_table_ui.c | 4 +- wiretap/ascend_parser.lemon | 2 +- wiretap/blf.c | 2 +- wiretap/catapult_dct2000.c | 6 +- wiretap/daintree-sna.c | 2 +- wiretap/erf.c | 6 +- wiretap/ipfix.c | 4 +- wiretap/iseries.c | 2 +- wiretap/k12.c | 6 +- wiretap/k12text.l | 8 +- wiretap/log3gpp.c | 6 +- wiretap/netscreen.c | 2 +- wiretap/observer.c | 4 +- wiretap/pcapng.c | 10 +- wiretap/stanag4607.c | 4 +- wiretap/wtap.c | 8 +- wsutil/wmem/wmem_interval_tree.c | 2 + 68 files changed, 371 insertions(+), 369 deletions(-) diff --git a/capinfos.c b/capinfos.c index 8cc7af9b4e..06572c626b 100644 --- a/capinfos.c +++ b/capinfos.c @@ -335,53 +335,53 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) switch (tsprecision) { case WTAP_TSPREC_SEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64, (gint64)timer->secs); break; case WTAP_TSPREC_DSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%01d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%01d", (gint64)timer->secs, decimal_point, timer->nsecs / 100000000); break; case WTAP_TSPREC_CSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%02d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%02d", (gint64)timer->secs, decimal_point, timer->nsecs / 10000000); break; case WTAP_TSPREC_MSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%03d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%03d", (gint64)timer->secs, decimal_point, timer->nsecs / 1000000); break; case WTAP_TSPREC_USEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%06d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%06d", (gint64)timer->secs, decimal_point, timer->nsecs / 1000); break; case WTAP_TSPREC_NSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%09d", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%09d", (gint64)timer->secs, decimal_point, timer->nsecs); break; default: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "Unknown precision %d", tsprecision); break; @@ -390,13 +390,13 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) } else { ti_tm = localtime(&timer->secs); if (ti_tm == NULL) { - g_snprintf(time_string_buf, sizeof time_string_buf, "Not representable"); + snprintf(time_string_buf, sizeof time_string_buf, "Not representable"); return time_string_buf; } switch (tsprecision) { case WTAP_TSPREC_SEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -407,7 +407,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; case WTAP_TSPREC_DSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d%s%01d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -420,7 +420,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; case WTAP_TSPREC_CSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d%s%02d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -433,7 +433,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; case WTAP_TSPREC_MSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d%s%03d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -446,7 +446,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; case WTAP_TSPREC_USEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d%s%06d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -459,7 +459,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; case WTAP_TSPREC_NSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "%04d-%02d-%02d %02d:%02d:%02d%s%09d", ti_tm->tm_year + 1900, ti_tm->tm_mon + 1, @@ -472,7 +472,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) break; default: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "Unknown precision %d", tsprecision); break; @@ -481,7 +481,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info) } } - g_snprintf(time_string_buf, sizeof time_string_buf, "n/a"); + snprintf(time_string_buf, sizeof time_string_buf, "n/a"); return time_string_buf; } @@ -505,16 +505,16 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb switch (tsprecision) { case WTAP_TSPREC_SEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%s", (gint64)timer->secs, second, timer->secs == 1 ? "" : plural); break; case WTAP_TSPREC_DSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%01d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%01d%s%s", (gint64)timer->secs, decimal_point, timer->nsecs / 100000000, @@ -523,8 +523,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb break; case WTAP_TSPREC_CSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%02d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%02d%s%s", (gint64)timer->secs, decimal_point, timer->nsecs / 10000000, @@ -533,8 +533,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb break; case WTAP_TSPREC_MSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%03d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%03d%s%s", (gint64)timer->secs, decimal_point, timer->nsecs / 1000000, @@ -543,8 +543,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb break; case WTAP_TSPREC_USEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%06d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%06d%s%s", (gint64)timer->secs, decimal_point, timer->nsecs / 1000, @@ -553,8 +553,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb break; case WTAP_TSPREC_NSEC: - g_snprintf(time_string_buf, sizeof time_string_buf, - "%"G_GINT64_MODIFIER"d%s%09d%s%s", + snprintf(time_string_buf, sizeof time_string_buf, + "%"PRId64"%s%09d%s%s", (gint64)timer->secs, decimal_point, timer->nsecs, @@ -563,7 +563,7 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb break; default: - g_snprintf(time_string_buf, sizeof time_string_buf, + snprintf(time_string_buf, sizeof time_string_buf, "Unknown precision %d", tsprecision); break; @@ -571,7 +571,7 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb return time_string_buf; } - g_snprintf(time_string_buf, sizeof time_string_buf, "n/a"); + snprintf(time_string_buf, sizeof time_string_buf, "n/a"); return time_string_buf; } @@ -682,7 +682,7 @@ print_stats(const gchar *filename, capture_info *cf_info) if (cap_file_size) { printf ("File size: "); if (machine_readable) { - printf ("%" G_GINT64_MODIFIER "d bytes\n", cf_info->filesize); + printf ("%" PRId64 " bytes\n", cf_info->filesize); } else { size_string = format_size(cf_info->filesize, FORMAT_SIZE_UNIT_BYTES, 0); printf ("%s\n", size_string); @@ -692,7 +692,7 @@ print_stats(const gchar *filename, capture_info *cf_info) if (cap_data_size) { printf ("Data size: "); if (machine_readable) { - printf ("%" G_GINT64_MODIFIER "u bytes\n", cf_info->packet_bytes); + printf ("%" PRIu64 " bytes\n", cf_info->packet_bytes); } else { size_string = format_size(cf_info->packet_bytes, FORMAT_SIZE_UNIT_BYTES, 0); printf ("%s\n", size_string); @@ -951,14 +951,14 @@ print_stats_table(const gchar *filename, capture_info *cf_info) if (cap_file_size) { putsep(); putquote(); - printf("%" G_GINT64_MODIFIER "d", cf_info->filesize); + printf("%" PRId64, cf_info->filesize); putquote(); } if (cap_data_size) { putsep(); putquote(); - printf("%" G_GINT64_MODIFIER "u", cf_info->packet_bytes); + printf("%" PRIu64, cf_info->packet_bytes); putquote(); } @@ -1158,7 +1158,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) { int i; for (i = 0; i < (int) length; i++) { - g_snprintf(str+(i*2), 3, "%02x", hash[i]); + snprintf(str+(i*2), 3, "%02x", hash[i]); } } diff --git a/capture/capture-pcap-util.c b/capture/capture-pcap-util.c index cd837fbb9d..146915f4eb 100644 --- a/capture/capture-pcap-util.c +++ b/capture/capture-pcap-util.c @@ -386,7 +386,7 @@ if_info_get(const char *name) descr_size = sizeof (descr_prefix) + 10; description = g_malloc(descr_size); if (description != NULL) { - g_snprintf(description, descr_size, + snprintf(description, descr_size, "%s%ld", descr_prefix, busnum); } } @@ -889,14 +889,14 @@ set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name, if (pcap_set_datalink(pcap_h, datalink) == 0) return TRUE; /* no error */ set_datalink_err_str = pcap_geterr(pcap_h); - g_snprintf(errmsg, (gulong) errmsg_len, "Unable to set data link type on interface '%s' (%s).", + snprintf(errmsg, (gulong) errmsg_len, "Unable to set data link type on interface '%s' (%s).", name, set_datalink_err_str); /* * If the error isn't "XXX is not one of the DLTs supported by this device", * tell the user to tell the Wireshark developers about it. */ if (strstr(set_datalink_err_str, "is not one of the DLTs supported by this device") == NULL) - g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, + snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, "%s", please_report_bug()); else secondary_errmsg[0] = '\0'; @@ -1366,10 +1366,10 @@ open_capture_device_pcap_create( */ *open_status = CAP_DEVICE_OPEN_WARNING_GENERIC; if (status == PCAP_WARNING) { - g_snprintf(*open_status_str, sizeof *open_status_str, + snprintf(*open_status_str, sizeof *open_status_str, "Warning: %s", pcap_geterr(pcap_h)); } else { - g_snprintf(*open_status_str, sizeof *open_status_str, + snprintf(*open_status_str, sizeof *open_status_str, "Warning: %s", pcap_statustostr(status)); } } else { diff --git a/capture/capture-wpcap.c b/capture/capture-wpcap.c index 45098e7be4..a6a9797f28 100644 --- a/capture/capture-wpcap.c +++ b/capture/capture-wpcap.c @@ -263,7 +263,7 @@ convert_errbuf_to_utf8(char *errbuf) } errbuf[PCAP_ERRBUF_SIZE - 1] = '\0'; utf8_err = local_code_page_str_to_utf8(errbuf); - g_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s", utf8_err); + snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s", utf8_err); g_free(utf8_err); } @@ -374,7 +374,7 @@ pcap_open_live(const char *a, int b, int c, int d, char *errbuf) { pcap_t *p; if (!has_wpcap) { - g_snprintf(errbuf, PCAP_ERRBUF_SIZE, + snprintf(errbuf, PCAP_ERRBUF_SIZE, "unable to load Npcap or WinPcap (wpcap.dll); can't open %s to capture", a); return NULL; @@ -409,7 +409,7 @@ pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *errb { pcap_t *ret; if (!has_wpcap) { - g_snprintf(errbuf, PCAP_ERRBUF_SIZE, + snprintf(errbuf, PCAP_ERRBUF_SIZE, "unable to load Npcap or WinPcap (wpcap.dll); can't open %s to capture", a); return NULL; @@ -563,7 +563,7 @@ pcap_statustostr(int a) } /* XXX copy routine from pcap.c ??? */ - (void)g_snprintf(ebuf, sizeof ebuf, "Don't have pcap_statustostr(), can't translate error: %d", a); + (void)snprintf(ebuf, sizeof ebuf, "Don't have pcap_statustostr(), can't translate error: %d", a); return(ebuf); } diff --git a/capture/capture_sync.c b/capture/capture_sync.c index 32b064713a..8db0f42280 100644 --- a/capture/capture_sync.c +++ b/capture/capture_sync.c @@ -270,56 +270,56 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (capture_opts->has_autostop_filesize) { char sfilesize[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize); + snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize); argv = sync_pipe_add_arg(argv, &argc, sfilesize); } if (capture_opts->has_file_duration) { char sfile_duration[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(sfile_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->file_duration); + snprintf(sfile_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->file_duration); argv = sync_pipe_add_arg(argv, &argc, sfile_duration); } if (capture_opts->has_file_interval) { char sfile_interval[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(sfile_interval, ARGV_NUMBER_LEN, "interval:%d",capture_opts->file_interval); + snprintf(sfile_interval, ARGV_NUMBER_LEN, "interval:%d",capture_opts->file_interval); argv = sync_pipe_add_arg(argv, &argc, sfile_interval); } if (capture_opts->has_file_packets) { char sfile_packets[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(sfile_packets, ARGV_NUMBER_LEN, "packets:%d",capture_opts->file_packets); + snprintf(sfile_packets, ARGV_NUMBER_LEN, "packets:%d",capture_opts->file_packets); argv = sync_pipe_add_arg(argv, &argc, sfile_packets); } if (capture_opts->has_ring_num_files) { char sring_num_files[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(sring_num_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->ring_num_files); + snprintf(sring_num_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->ring_num_files); argv = sync_pipe_add_arg(argv, &argc, sring_num_files); } if (capture_opts->has_nametimenum) { char nametimenum[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-b"); - g_snprintf(nametimenum, ARGV_NUMBER_LEN, "nametimenum:2"); + snprintf(nametimenum, ARGV_NUMBER_LEN, "nametimenum:2"); argv = sync_pipe_add_arg(argv, &argc, nametimenum); } if (capture_opts->has_autostop_files) { char sautostop_files[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-a"); - g_snprintf(sautostop_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->autostop_files); + snprintf(sautostop_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->autostop_files); argv = sync_pipe_add_arg(argv, &argc, sautostop_files); } } else { if (capture_opts->has_autostop_filesize) { char sautostop_filesize[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-a"); - g_snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize); + snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize); argv = sync_pipe_add_arg(argv, &argc, sautostop_filesize); } } @@ -327,14 +327,14 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (capture_opts->has_autostop_packets) { char scount[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-c"); - g_snprintf(scount, ARGV_NUMBER_LEN, "%d",capture_opts->autostop_packets); + snprintf(scount, ARGV_NUMBER_LEN, "%d",capture_opts->autostop_packets); argv = sync_pipe_add_arg(argv, &argc, scount); } if (capture_opts->has_autostop_duration) { char sautostop_duration[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-a"); - g_snprintf(sautostop_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->autostop_duration); + snprintf(sautostop_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->autostop_duration); argv = sync_pipe_add_arg(argv, &argc, sautostop_duration); } @@ -349,7 +349,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (interface_opts->extcap_fifo != NULL) { #ifdef _WIN32 - char *pipe = g_strdup_printf("%s%" G_GUINTPTR_FORMAT, EXTCAP_PIPE_PREFIX, interface_opts->extcap_pipe_h); + char *pipe = g_strdup_printf("%s%" PRIuPTR, EXTCAP_PIPE_PREFIX, interface_opts->extcap_pipe_h); argv = sync_pipe_add_arg(argv, &argc, pipe); g_free(pipe); #else @@ -375,7 +375,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (interface_opts->has_snaplen) { char ssnap[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-s"); - g_snprintf(ssnap, ARGV_NUMBER_LEN, "%d", interface_opts->snaplen); + snprintf(ssnap, ARGV_NUMBER_LEN, "%d", interface_opts->snaplen); argv = sync_pipe_add_arg(argv, &argc, ssnap); } @@ -398,7 +398,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, argv = sync_pipe_add_arg(argv, &argc, "-B"); if(interface_opts->buffer_size == 0x00) interface_opts->buffer_size = DEFAULT_CAPTURE_BUFFER_SIZE; - g_snprintf(buffer_size, ARGV_NUMBER_LEN, "%d", interface_opts->buffer_size); + snprintf(buffer_size, ARGV_NUMBER_LEN, "%d", interface_opts->buffer_size); argv = sync_pipe_add_arg(argv, &argc, buffer_size); } #endif @@ -419,7 +419,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (interface_opts->auth_type == CAPTURE_AUTH_PWD) { char sauth[256]; argv = sync_pipe_add_arg(argv, &argc, "-A"); - g_snprintf(sauth, sizeof(sauth), "%s:%s", + snprintf(sauth, sizeof(sauth), "%s:%s", interface_opts->auth_username, interface_opts->auth_password); argv = sync_pipe_add_arg(argv, &argc, sauth); @@ -430,7 +430,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, if (interface_opts->sampling_method != CAPTURE_SAMP_NONE) { char ssampling[ARGV_NUMBER_LEN]; argv = sync_pipe_add_arg(argv, &argc, "-m"); - g_snprintf(ssampling, ARGV_NUMBER_LEN, "%s:%d", + snprintf(ssampling, ARGV_NUMBER_LEN, "%s:%d", interface_opts->sampling_method == CAPTURE_SAMP_BY_COUNT ? "count" : interface_opts->sampling_method == CAPTURE_SAMP_BY_TIMER ? "timer" : "undef", @@ -448,7 +448,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, #ifndef DEBUG_CHILD argv = sync_pipe_add_arg(argv, &argc, "-Z"); #ifdef _WIN32 - g_snprintf(control_id, ARGV_NUMBER_LEN, "%d", GetCurrentProcessId()); + snprintf(control_id, ARGV_NUMBER_LEN, "%d", GetCurrentProcessId()); argv = sync_pipe_add_arg(argv, &argc, control_id); #else argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); @@ -595,7 +595,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments, dup2(sync_pipe[PIPE_WRITE], 2); ws_close(sync_pipe[PIPE_READ]); execv(argv[0], argv); - g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", + snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", argv[0], g_strerror(errno)); sync_pipe_errmsg_to_parent(2, errmsg, ""); @@ -834,7 +834,7 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd, ws_close(sync_pipe[PIPE_READ]); ws_close(sync_pipe[PIPE_WRITE]); execv(argv[0], argv); - g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", + snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", argv[0], g_strerror(errno)); sync_pipe_errmsg_to_parent(2, errmsg, ""); @@ -1965,7 +1965,7 @@ sync_pipe_signame(int sig) default: /* Returning a static buffer is ok in the context we use it here */ - g_snprintf(sigmsg_buf, sizeof sigmsg_buf, "Signal %d", sig); + snprintf(sigmsg_buf, sizeof sigmsg_buf, "Signal %d", sig); sigmsg = sigmsg_buf; break; } diff --git a/capture/iface_monitor.c b/capture/iface_monitor.c index e67c551c7c..f742a664a6 100644 --- a/capture/iface_monitor.c +++ b/capture/iface_monitor.c @@ -275,7 +275,7 @@ iface_mon_event(void) return; } evd = (struct net_event_data *)&kem->event_data[0]; - g_snprintf(ifr_name, IFNAMSIZ, "%s%u", evd->if_name, evd->if_unit); + snprintf(ifr_name, IFNAMSIZ, "%s%u", evd->if_name, evd->if_unit); /* * Check type of event. diff --git a/doc/README.stats_tree b/doc/README.stats_tree index 0a7e53da3d..d064906309 100644 --- a/doc/README.stats_tree +++ b/doc/README.stats_tree @@ -81,11 +81,11 @@ udp_term_stats_tree_packet(stats_tree *st, /* st as it was passed to us */ /* we then tick a node for this src_addr:src_port if the node doesn't exists it will be created */ - g_snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_src),udphdr->sport); + snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_src),udphdr->sport); tick_stat_node(st, str, st_udp_term, FALSE); /* same thing for dst */ - g_snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_dst),udphdr->dport); + snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_dst),udphdr->dport); tick_stat_node(st, str, st_udp_term, FALSE); return 1; diff --git a/dumpcap.c b/dumpcap.c index fbc8a76db0..d4baf7a30b 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -642,10 +642,10 @@ get_capture_device_open_failure_messages(cap_device_open_status open_status, char *secondary_errmsg, size_t secondary_errmsg_len) { - g_snprintf(errmsg, (gulong) errmsg_len, + snprintf(errmsg, (gulong) errmsg_len, "The capture session could not be initiated on capture device \"%s\" (%s).", iface, open_status_str); - g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, "%s", + snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, "%s", get_pcap_failure_secondary_error_message(open_status, open_status_str)); } @@ -725,7 +725,7 @@ show_filter_code(capture_options *capture_opts) /* OK, try to compile the capture filter. */ if (!compile_capture_filter(interface_opts->name, pcap_h, &fcode, interface_opts->cfilter)) { - g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_h)); + snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_h)); pcap_close(pcap_h); report_cfilter_error(capture_opts, j, errmsg); return FALSE; @@ -1363,7 +1363,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm /* Skip the initial "TCP@" in the pipename. */ if (ws_socket_ptoa(&sa, pipename + 4, DEF_TCP_PORT) < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated because" "\"%s\" is not a valid socket specification", pipename); pcap_src->cap_pipe_err = PIPERR; @@ -1371,7 +1371,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm } if ((fd = (int)socket(sa.ss_family, SOCK_STREAM, 0)) < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated because" " the socket couldn't be created due to the socket error: \n" #ifdef _WIN32 @@ -1388,7 +1388,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm else sa_len = sizeof(struct sockaddr_in); if (connect(fd, (struct sockaddr *)&sa, sa_len) < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated because" " the socket couldn't be connected due to the socket error: \n" #ifdef _WIN32 @@ -1447,14 +1447,14 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl) sz = pcap_src->cap_pipe_bytes_to_read - pcap_src->cap_pipe_bytes_read; while (bytes_read < sz) { if (fd == -1) { - g_snprintf(errmsg, (gulong)errmsgl, "Invalid file descriptor."); + snprintf(errmsg, (gulong)errmsgl, "Invalid file descriptor."); pcap_src->cap_pipe_err = PIPNEXIST; return -1; } sel_ret = cap_pipe_select(fd); if (sel_ret < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Unexpected error from select: %s.", g_strerror(errno)); pcap_src->cap_pipe_err = PIPERR; return -1; @@ -1463,7 +1463,7 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl) sz-bytes_read, pcap_src->from_cap_socket); if (b <= 0) { if (b == 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file reading from pipe or socket."); pcap_src->cap_pipe_err = PIPEOF; } else { @@ -1473,11 +1473,11 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl) */ DWORD lastError = WSAGetLastError(); errno = lastError; - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe or socket: %s.", win32strerror(lastError)); #else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe or socket: %s.", g_strerror(errno)); #endif @@ -1566,7 +1566,7 @@ cap_pipe_open_live(char *pipename, if (errno == ENOENT || errno == ENOTDIR) pcap_src->cap_pipe_err = PIPNEXIST; else { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated " "due to error getting information on pipe or socket: %s.", g_strerror(errno)); pcap_src->cap_pipe_err = PIPERR; @@ -1576,7 +1576,7 @@ cap_pipe_open_live(char *pipename, if (S_ISFIFO(pipe_stat.st_mode)) { fd = ws_open(pipename, O_RDONLY | O_NONBLOCK, 0000 /* no creation so don't matter */); if (fd == -1) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated " "due to error on pipe open: %s.", g_strerror(errno)); pcap_src->cap_pipe_err = PIPERR; @@ -1585,7 +1585,7 @@ cap_pipe_open_live(char *pipename, } else if (S_ISSOCK(pipe_stat.st_mode)) { fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated " "due to error on socket create: %s.", g_strerror(errno)); pcap_src->cap_pipe_err = PIPERR; @@ -1617,7 +1617,7 @@ cap_pipe_open_live(char *pipename, */ if (g_strlcpy(sa.sun_path, pipename, sizeof sa.sun_path) > sizeof sa.sun_path) { /* Path name too long */ - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session coud not be initiated " "due to error on socket connect: Path name too long."); pcap_src->cap_pipe_err = PIPERR; @@ -1626,7 +1626,7 @@ cap_pipe_open_live(char *pipename, } b = connect(fd, (struct sockaddr *)&sa, sizeof sa); if (b == -1) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session coud not be initiated " "due to error on socket connect: %s.", g_strerror(errno)); pcap_src->cap_pipe_err = PIPERR; @@ -1641,7 +1641,7 @@ cap_pipe_open_live(char *pipename, */ pcap_src->cap_pipe_err = PIPNEXIST; } else { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated because\n" "\"%s\" is neither an interface nor a socket nor a pipe.", pipename); pcap_src->cap_pipe_err = PIPERR; @@ -1650,7 +1650,7 @@ cap_pipe_open_live(char *pipename, } #else /* _WIN32 */ - if (sscanf(pipename, EXTCAP_PIPE_PREFIX "%" G_GUINTPTR_FORMAT, &extcap_pipe_handle) == 1) + if (sscanf(pipename, EXTCAP_PIPE_PREFIX "%" PRIuPTR, &extcap_pipe_handle) == 1) { /* The client is already connected to extcap pipe. * We have inherited the handle from parent process. @@ -1674,7 +1674,7 @@ cap_pipe_open_live(char *pipename, g_free(pncopy); if (!pos) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session could not be initiated because\n" "\"%s\" is neither an interface nor a pipe.", pipename); pcap_src->cap_pipe_err = PIPNEXIST; @@ -1691,7 +1691,7 @@ cap_pipe_open_live(char *pipename, break; if (GetLastError() != ERROR_PIPE_BUSY) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session on \"%s\" could not be started " "due to error on pipe open: %s.", pipename, win32strerror(GetLastError())); @@ -1700,7 +1700,7 @@ cap_pipe_open_live(char *pipename, } if (!WaitNamedPipe(utf_8to16(pipename), 30 * 1000)) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The capture session on \"%s\" timed out during " "pipe open: %s.", pipename, win32strerror(GetLastError())); @@ -1747,7 +1747,7 @@ cap_pipe_open_live(char *pipename, while (bytes_read < sizeof magic) { sel_ret = cap_pipe_select(fd); if (sel_ret < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Unexpected error from select: %s.", g_strerror(errno)); goto error; @@ -1761,10 +1761,10 @@ cap_pipe_open_live(char *pipename, if (b <= 0) { if (b == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file on pipe magic during open."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error on pipe magic during open: %s.", g_strerror(errno)); goto error; @@ -1785,10 +1785,10 @@ cap_pipe_open_live(char *pipename, if (pcap_src->cap_pipe_bytes_read <= 0) { if (pcap_src->cap_pipe_bytes_read == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file on pipe magic during open."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error on pipe magic during open: %s.", g_strerror(errno)); goto error; @@ -1841,9 +1841,9 @@ cap_pipe_open_live(char *pipename, default: /* Not a pcapng file, and either not a pcap type we know about or not a pcap file, either. */ - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Data written to the pipe is neither in a supported pcap format nor in pcapng format."); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", + snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", not_our_bug); goto error; } @@ -1898,7 +1898,7 @@ pcap_pipe_open_live(int fd, while (bytes_read < sizeof(struct pcap_hdr)) { sel_ret = cap_pipe_select(fd); if (sel_ret < 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Unexpected error from select: %s.", g_strerror(errno)); goto error; @@ -1908,13 +1908,13 @@ pcap_pipe_open_live(int fd, pcap_src->from_cap_socket); if (b <= 0) { if (b == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file on pipe header during open."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error on pipe header during open: %s.", g_strerror(errno)); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, + snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", not_our_bug); goto error; } @@ -1927,13 +1927,13 @@ pcap_pipe_open_live(int fd, pipe_read_sync(pcap_src, hdr, sizeof(struct pcap_hdr)); if (pcap_src->cap_pipe_bytes_read <= 0) { if (pcap_src->cap_pipe_bytes_read == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file on pipe header during open."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error on pipe header header during open: %s.", g_strerror(errno)); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", + snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", not_our_bug); goto error; } @@ -1969,10 +1969,10 @@ pcap_pipe_open_live(int fd, } if (hdr->version_major < 2) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "The old pcap format version %d.%d is not supported.", hdr->version_major, hdr->version_minor); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", + snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s", not_our_bug); goto error; } @@ -2016,10 +2016,10 @@ pcapng_read_shb(capture_src *pcap_src, sizeof(pcapng_section_header_block_t)); if (pcap_src->cap_pipe_bytes_read <= 0) { if (pcap_src->cap_pipe_bytes_read == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file reading from pipe or socket."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe or socket: %s.", g_strerror(errno)); return -1; @@ -2069,13 +2069,13 @@ pcapng_read_shb(capture_src *pcap_src, #define OUR_ENDIAN "little" #define IFACE_ENDIAN "big" #endif - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Interface %u is " IFACE_ENDIAN " endian but we're " OUR_ENDIAN " endian.", pcap_src->interface_id); return -1; default: /* Not a pcapng type we know about, or not pcapng at all. */ - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Unrecognized pcapng format or not pcapng data."); return -1; } @@ -2229,10 +2229,10 @@ pcapng_pipe_open_live(int fd, sizeof(bh->block_total_length)); if (pcap_src->cap_pipe_bytes_read <= 0) { if (pcap_src->cap_pipe_bytes_read == 0) - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "End of file reading from pipe or socket."); else - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe or socket: %s.", g_strerror(errno)); goto error; @@ -2243,7 +2243,7 @@ pcapng_pipe_open_live(int fd, } #endif if ((bh->block_total_length & 0x03) != 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "block_total_length read from pipe is %u, which is not a multiple of 4.", bh->block_total_length); goto error; @@ -2400,7 +2400,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er break; default: - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "pcap_pipe_dispatch: invalid state"); result = PD_ERR; @@ -2425,7 +2425,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er * STATE_EXPECT_DATA) as that would not fit in the buffer and * instead stop with an error. */ - g_snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)", + snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)", ld->packets_captured+1, pcap_info->rechdr.hdr.incl_len); break; } @@ -2492,7 +2492,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er return -1; case PD_PIPE_ERR: - g_snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s", + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s", #ifdef _WIN32 win32strerror(GetLastError())); #else @@ -2636,7 +2636,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t break; default: - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "pcapng_pipe_dispatch: invalid state"); result = PD_ERR; @@ -2667,7 +2667,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t } if ((bh->block_total_length & 0x03) != 0) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "Total length of pcapng block read from pipe is %u, which is not a multiple of 4.", bh->block_total_length); break; @@ -2679,7 +2679,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t * STATE_EXPECT_DATA) as that would not fit in the buffer and * instead stop with an error. */ - g_snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)", + snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)", ld->packets_captured+1, bh->block_total_length); break; } @@ -2706,7 +2706,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t /* The record always has at least the block total length following the header */ if (bh->block_total_length < sizeof(pcapng_block_header_t)+sizeof(guint32)) { - g_snprintf(errmsg, (gulong)errmsgl, + snprintf(errmsg, (gulong)errmsgl, "malformed pcapng block_total_length < minimum"); pcap_src->cap_pipe_err = PIPEOF; return -1; @@ -2740,7 +2740,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t return -1; case PD_PIPE_ERR: - g_snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s", + snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s", #ifdef _WIN32 win32strerror(GetLastError())); #else @@ -2773,7 +2773,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, if ((use_threads == FALSE) && (capture_opts->ifaces->len > 1)) { - g_snprintf(errmsg, (gulong) errmsg_len, + snprintf(errmsg, (gulong) errmsg_len, "Using threads is required for capturing on multiple interfaces."); return FALSE; } @@ -2783,7 +2783,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i); pcap_src = g_new0(capture_src, 1); if (pcap_src == NULL) { - g_snprintf(errmsg, (gulong) errmsg_len, + snprintf(errmsg, (gulong) errmsg_len, "Could not allocate memory."); return FALSE; } @@ -3176,7 +3176,7 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err if ((capture_opts->use_pcapng == FALSE) && (capture_opts->ifaces->len > 1)) { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "Using PCAPNG is required for capturing on multiple interfaces. Use the -n option."); return FALSE; } @@ -3232,12 +3232,12 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err /* We couldn't set up to write to the capture file. */ /* XXX - use cf_open_error_message from tshark instead? */ if (err < 0) { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "The file to which the capture would be" " saved (\"%s\") could not be opened: Error %d.", capture_opts->save_file, err); } else { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "The file to which the capture would be" " saved (\"%s\") could not be opened: %s.", capture_opts->save_file, g_strerror(err)); @@ -3333,7 +3333,7 @@ capture_loop_dispatch(loop_data *ld, sel_ret = cap_pipe_select(pcap_src->cap_pipe_fd); if (sel_ret <= 0) { if (sel_ret < 0 && errno != EINTR) { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "Unexpected error from select: %s", g_strerror(errno)); report_capture_error(errmsg, please_report_bug()); ld->go = FALSE; @@ -3406,7 +3406,7 @@ capture_loop_dispatch(loop_data *ld, } } else { if (sel_ret < 0 && errno != EINTR) { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "Unexpected error from select: %s", g_strerror(errno)); report_capture_error(errmsg, please_report_bug()); ld->go = FALSE; @@ -3543,7 +3543,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, if (capture_opts->output_to_pipe == TRUE) { /* either "-" or named pipe */ if (capture_opts->multi_files_on) { /* ringbuffer is enabled; that doesn't work with standard output or a named pipe */ - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "Ring buffer requested, but capture is being written to standard output or to a named pipe."); g_free(capfile_name); return FALSE; @@ -3579,7 +3579,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, } if (capture_opts->print_file_names) { if (!ringbuf_set_print_name(capture_opts->print_name_to, NULL)) { - g_snprintf(errmsg, errmsg_len, "Could not write filenames to %s: %s.\n", + snprintf(errmsg, errmsg_len, "Could not write filenames to %s: %s.\n", capture_opts->print_name_to, g_strerror(errno)); g_free(capfile_name); @@ -3673,7 +3673,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, /* did we fail to open the output file? */ if (*save_file_fd == -1) { if (is_tempfile) { - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "The temporary file to which the capture would be saved (\"%s\") " "could not be opened: %s.", capfile_name, err_tempfile->message); g_error_free(err_tempfile); @@ -3685,7 +3685,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, ringbuf_error_cleanup(); } - g_snprintf(errmsg, errmsg_len, + snprintf(errmsg, errmsg_len, "The file to which the capture would be saved (\"%s\") " "could not be opened: %s.", capfile_name, g_strerror(errno)); @@ -3945,13 +3945,13 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct case INITFILTER_BAD_FILTER: cfilter_error = TRUE; error_index = i; - g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_src->pcap_h)); + snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_src->pcap_h)); goto error; case INITFILTER_OTHER_ERROR: - g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).", + snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).", pcap_geterr(pcap_src->pcap_h)); - g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug()); + snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug()); goto error; } } @@ -4340,7 +4340,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct /* Let the parent process know. */ pcap_dropped += stats->ps_drop; } else { - g_snprintf(errmsg, sizeof(errmsg), + snprintf(errmsg, sizeof(errmsg), "Can't get packet-drop statistics: %s", pcap_geterr(pcap_src->pcap_h)); report_capture_error(errmsg, please_report_bug()); @@ -4415,44 +4415,44 @@ capture_loop_get_errmsg(char *errmsg, size_t errmsglen, char *secondary_errmsg, switch (err) { case ENOSPC: - g_snprintf(errmsg, (gulong)errmsglen, + snprintf(errmsg, (gulong)errmsglen, "Not all the packets could be written to the file" " to which the capture was being saved\n" "(\"%s\") because there is no space left on the file system\n" "on which that file resides.", fname); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s", + snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s", find_space); break; #ifdef EDQUOT case EDQUOT: - g_snprintf(errmsg, (gulong)errmsglen, + snprintf(errmsg, (gulong)errmsglen, "Not all the packets could be written to the file" " to which the capture was being saved\n" "(\"%s\") because you are too close to, or over," " your disk quota\n" "on the file system on which that file resides.", fname); - g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s", + snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s", find_space); break; #endif default: if (is_close) { - g_snprintf(errmsg, (gulong)errmsglen, + snprintf(errmsg, (gulong)errmsglen, "The file to which the capture was being saved\n" "(\"%s\") could not be closed: %s.", fname, g_strerror(err)); } else { - g_snprintf(errmsg, (gulong)errmsglen, + snprintf(errmsg, (gulong)errmsglen, "An error occurred while writing to the file" " to which the capture was being saved\n" "(\"%s\"): %s.", fname, g_strerror(err)); } - g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, + snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s", please_report_bug()); break; } @@ -4671,7 +4671,7 @@ capture_loop_queue_packet_cb(u_char *pcap_src_p, const struct pcap_pkthdr *phdr, } /* I don't want to hold the mutex over the debug output. So the output may be wrong */ - ws_info("Queue size is now %" G_GINT64_MODIFIER "d bytes (%" G_GINT64_MODIFIER "d packets)", + ws_info("Queue size is now %" PRId64 " bytes (%" PRId64 " packets)", pcap_queue_bytes, pcap_queue_packets); } @@ -4728,7 +4728,7 @@ capture_loop_queue_pcapng_cb(capture_src *pcap_src, const pcapng_block_header_t } /* I don't want to hold the mutex over the debug output. So the output may be wrong */ - ws_info("Queue size is now %" G_GINT64_MODIFIER "d bytes (%" G_GINT64_MODIFIER "d packets)", + ws_info("Queue size is now %" PRId64 " bytes (%" PRId64 " packets)", pcap_queue_bytes, pcap_queue_packets); } @@ -5622,7 +5622,7 @@ report_packet_count(unsigned int packet_count) static unsigned int count = 0; if (capture_child) { - g_snprintf(count_str, sizeof(count_str), "%u", packet_count); + snprintf(count_str, sizeof(count_str), "%u", packet_count); ws_debug("Packets: %s", count_str); pipe_write_block(2, SP_PACKET_COUNT, count_str); } else { @@ -5683,7 +5683,7 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg) if (i < capture_opts->ifaces->len) { if (capture_child) { - g_snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg); + snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg); ws_debug("Capture filter error: %s", errmsg); pipe_write_block(2, SP_BAD_FILTER, tmp); } else { diff --git a/editcap.c b/editcap.c index 5a31da761e..591af0a1ce 100644 --- a/editcap.c +++ b/editcap.c @@ -196,7 +196,7 @@ abs_time_to_str_with_sec_resolution(const nstime_t *abs_time) tmp = localtime(&abs_time->secs); if (tmp) { - g_snprintf(buf, 16, "%d%02d%02d%02d%02d%02d", + snprintf(buf, 16, "%d%02d%02d%02d%02d%02d", tmp->tm_year + 1900, tmp->tm_mon+1, tmp->tm_mday, @@ -218,7 +218,7 @@ fileset_get_filename_by_pattern(guint idx, const wtap_rec *rec, gchar *timestr; gchar *abs_str; - g_snprintf(filenum, sizeof(filenum), "%05u", idx % RINGBUFFER_MAX_NUM_FILES); + snprintf(filenum, sizeof(filenum), "%05u", idx % RINGBUFFER_MAX_NUM_FILES); if (rec->presence_flags & WTAP_HAS_TS) { timestr = abs_time_to_str_with_sec_resolution(&rec->ts); abs_str = g_strconcat(fprefix, "_", filenum, "_", timestr, fsuffix, NULL); diff --git a/extcap.c b/extcap.c index 3c3975ac7b..45f6405fce 100644 --- a/extcap.c +++ b/extcap.c @@ -1534,7 +1534,7 @@ static gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, HANDLE *ha } else { - ws_debug("Wireshark Created pipe =>(%s) handle (%" G_GUINTPTR_FORMAT ")", pipename, *handle_out); + ws_debug("Wireshark Created pipe =>(%s) handle (%" PRIuPTR ")", pipename, *handle_out); *fifo = g_strdup(pipename); } diff --git a/extcap/androiddump.c b/extcap/androiddump.c index 85479cf7ec..9c6175dd2b 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -658,7 +658,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, return NULL; } - g_snprintf(buffer, (gulong)buffer_length, ADB_HEX4_FORMAT, adb_service_length); + snprintf(buffer, (gulong)buffer_length, ADB_HEX4_FORMAT, adb_service_length); result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { ws_warning("Error while sending <%s> length to ADB daemon", adb_service); @@ -746,7 +746,7 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch size_t adb_service_length; adb_service_length = strlen(adb_service); - g_snprintf(buffer, buffer_length, ADB_HEX4_FORMAT, adb_service_length); + snprintf(buffer, buffer_length, ADB_HEX4_FORMAT, adb_service_length); result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { @@ -812,7 +812,7 @@ static int adb_send(socket_handle_t sock, const char *adb_service) { size_t adb_service_length; adb_service_length = strlen(adb_service); - g_snprintf(buffer, sizeof(buffer), ADB_HEX4_FORMAT, adb_service_length); + snprintf(buffer, sizeof(buffer), ADB_HEX4_FORMAT, adb_service_length); result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { @@ -869,7 +869,7 @@ adb_connect_transport(const char *server_ip, unsigned short *server_tcp_port, if (!serial_number) { transport = adb_transport_any; } else { - result = g_snprintf(transport_buf, sizeof(transport_buf), adb_transport_serial_templace, serial_number); + result = snprintf(transport_buf, sizeof(transport_buf), adb_transport_serial_templace, serial_number); if (result <= 0 || result > (int)sizeof(transport_buf)) { ws_warning("Error while completing adb packet for transport"); closesocket(sock); @@ -969,7 +969,7 @@ static int add_tcpdump_interfaces(extcap_parameters * extcap_conf, const char *a gchar *flags = g_match_info_fetch_named(match, "flags"); if (!flags_supported || (flags && strstr(flags, "Up"))) { - g_snprintf(iface_name, sizeof(iface_name), INTERFACE_ANDROID_TCPDUMP_FORMAT, iface); + snprintf(iface_name, sizeof(iface_name), INTERFACE_ANDROID_TCPDUMP_FORMAT, iface); new_interface(extcap_conf, iface_name, iface, serial_number, "Android tcpdump"); } g_free(flags); @@ -1150,7 +1150,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) { ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); - result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); + result = snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); if (result <= 0 || result > (int)sizeof(check_port_buf)) { ws_warning("Error while completing adb packet"); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_6; @@ -1225,7 +1225,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) { ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); - result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); + result = snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); if (result <= 0 || result > (int)sizeof(check_port_buf)) { ws_warning("Error while completing adb packet"); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_9; @@ -1648,7 +1648,7 @@ static int adb_forward(char *serial_number, const char *adb_server_ip, unsigned if (sock == INVALID_SOCKET) return EXIT_CODE_INVALID_SOCKET_5; - result = g_snprintf(helpful_packet, PACKET_LENGTH, adb_forward_template, (serial_number) ? "host-serial:" : "host", (serial_number) ? serial_number: "", local_tcp_port, server_tcp_port); + result = snprintf(helpful_packet, PACKET_LENGTH, adb_forward_template, (serial_number) ? "host-serial:" : "host", (serial_number) ? serial_number: "", local_tcp_port, server_tcp_port); if (result <= 0 || result > PACKET_LENGTH) { ws_warning("Error while completing adb packet"); closesocket(sock); @@ -1740,7 +1740,7 @@ static int capture_android_bluetooth_external_parser(char *interface, if (sock == INVALID_SOCKET) return EXIT_CODE_INVALID_SOCKET_6; - result = g_snprintf((char *) buffer, PACKET_LENGTH, adb_tcp_bluedroid_external_parser_template, *bt_server_tcp_port); + result = snprintf((char *) buffer, PACKET_LENGTH, adb_tcp_bluedroid_external_parser_template, *bt_server_tcp_port); if (result <= 0 || result > PACKET_LENGTH) { ws_warning("Error while completing adb packet"); closesocket(sock); @@ -2061,7 +2061,7 @@ static int capture_android_logcat_text(char *interface, char *fifo, if (!logcat_custom_parameter) logcat_custom_parameter = ""; - result = g_snprintf((char *) packet, PACKET_LENGTH, adb_logcat_template, logcat_buffer, logcat_log_buffer, logcat_custom_parameter); + result = snprintf((char *) packet, PACKET_LENGTH, adb_logcat_template, logcat_buffer, logcat_log_buffer, logcat_custom_parameter); if (result <= 0 || result > PACKET_LENGTH) { ws_warning("Error while completing adb packet"); closesocket(sock); @@ -2358,7 +2358,7 @@ static int capture_android_tcpdump(char *interface, char *fifo, return EXIT_CODE_INVALID_SOCKET_11; } - g_snprintf(tcpdump_cmd, sizeof(tcpdump_cmd), adb_shell_tcpdump_format, iface); + snprintf(tcpdump_cmd, sizeof(tcpdump_cmd), adb_shell_tcpdump_format, iface); g_free(iface); result = adb_send(sock, tcpdump_cmd); if (result) { diff --git a/extcap/sdjournal.c b/extcap/sdjournal.c index 90a330c64c..f5ad03d723 100644 --- a/extcap/sdjournal.c +++ b/extcap/sdjournal.c @@ -105,7 +105,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) ws_warning("Error fetching cursor: %s", g_strerror(jr)); goto end; } - data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__CURSOR=%s\n", cursor); + data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__CURSOR=%s\n", cursor); free(cursor); jr = sd_journal_get_realtime_usec(jnl, &pkt_rt_ts); @@ -113,7 +113,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) ws_warning("Error fetching realtime timestamp: %s", g_strerror(jr)); goto end; } - data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__REALTIME_TIMESTAMP=%" G_GUINT64_FORMAT "\n", pkt_rt_ts); + data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__REALTIME_TIMESTAMP=%" PRIu64 "\n", pkt_rt_ts); jr = sd_journal_get_monotonic_usec(jnl, &mono_ts, &boot_id); if (jr < 0) { @@ -121,7 +121,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) goto end; } sd_id128_to_string(boot_id, boot_id_str + strlen(FLD_BOOT_ID)); - data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__MONOTONIC_TIMESTAMP=%" G_GUINT64_FORMAT "\n%s\n", mono_ts, boot_id_str); + data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__MONOTONIC_TIMESTAMP=%" PRIu64 "\n%s\n", mono_ts, boot_id_str); ws_debug("Entry header is %u bytes", data_end); SD_JOURNAL_FOREACH_DATA(jnl, fld_data, fld_len) { diff --git a/file.c b/file.c index 78c45eca7d..cc95946e4c 100644 --- a/file.c +++ b/file.c @@ -483,8 +483,8 @@ calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_s progbar_val = 1.0f; } - g_snprintf(status_str, status_size, - "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB", + snprintf(status_str, status_size, + "%" PRId64 "KB of %" PRId64 "KB", file_pos / 1024, size / 1024); return progbar_val; @@ -1376,8 +1376,8 @@ merge_callback(merge_event event, int num _U_, if (cb_data->progbar != NULL) { gchar status_str[100]; - g_snprintf(status_str, sizeof(status_str), - "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB", + snprintf(status_str, sizeof(status_str), + "%" PRId64 "KB of %" PRId64 "KB", file_pos / 1024, cb_data->f_len / 1024); update_progress_dlg(cb_data->progbar, progbar_val, status_str); } @@ -1813,7 +1813,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb progbar_val = (gfloat) count / frames_count; if (progbar != NULL) { - g_snprintf(status_str, sizeof(status_str), + snprintf(status_str, sizeof(status_str), "%4u of %u frames", count, frames_count); update_progress_dlg(progbar, progbar_val, status_str); } @@ -2168,7 +2168,7 @@ process_specified_records(capture_file *cf, packet_range_t *range, ws_assert(cf->count > 0); progbar_val = (gfloat) progbar_count / cf->count; - g_snprintf(progbar_status_str, sizeof(progbar_status_str), + snprintf(progbar_status_str, sizeof(progbar_status_str), "%4u of %u packets", progbar_count, cf->count); update_progress_dlg(progbar, progbar_val, progbar_status_str); @@ -2380,7 +2380,7 @@ print_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec, Buffer *buf, * We generate bookmarks, if the output format supports them. * The name is "__frameN__". */ - g_snprintf(bookmark_name, sizeof bookmark_name, "__frame%u__", fdata->num); + snprintf(bookmark_name, sizeof bookmark_name, "__frame%u__", fdata->num); if (args->print_args->print_summary) { if (!args->print_args->print_col_headings) @@ -2411,9 +2411,9 @@ print_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec, Buffer *buf, /* Right-justify the packet number column. */ if (col_item->col_fmt == COL_NUMBER) - g_snprintf(cp, column_len+1, "%*s", args->col_widths[i], col_item->col_data); + snprintf(cp, column_len+1, "%*s", args->col_widths[i], col_item->col_data); else - g_snprintf(cp, column_len+1, "%-*s", args->col_widths[i], col_item->col_data); + snprintf(cp, column_len+1, "%-*s", args->col_widths[i], col_item->col_data); cp += column_len; if (i != args->num_visible_cols - 1) *cp++ = ' '; @@ -2434,7 +2434,7 @@ print_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec, Buffer *buf, * Generate a bookmark, using "Frame N" as the title, as we're not * printing the summary line. */ - g_snprintf(bookmark_title, sizeof bookmark_title, "Frame %u", fdata->num); + snprintf(bookmark_title, sizeof bookmark_title, "Frame %u", fdata->num); if (!print_bookmark(args->print_args->stream, bookmark_name, bookmark_title)) goto fail; @@ -2598,9 +2598,9 @@ cf_print_packets(capture_file *cf, print_args_t *print_args, /* Right-justify the packet number column. */ /* if (cf->cinfo.col_fmt[i] == COL_NUMBER) - g_snprintf(cp, column_len+1, "%*s", callback_args.col_widths[visible_col_count], cf->cinfo.columns[i].col_title); + snprintf(cp, column_len+1, "%*s", callback_args.col_widths[visible_col_count], cf->cinfo.columns[i].col_title); else*/ - g_snprintf(cp, column_len+1, "%-*s", callback_args.col_widths[visible_col_count], cf->cinfo.columns[i].col_title); + snprintf(cp, column_len+1, "%-*s", callback_args.col_widths[visible_col_count], cf->cinfo.columns[i].col_title); cp += column_len; if (i != cf->cinfo.num_cols - 1) *cp++ = ' '; @@ -3662,7 +3662,7 @@ find_packet(capture_file *cf, ws_match_function match_function, progbar_val = (gfloat) count / cf->count; - g_snprintf(status_str, sizeof(status_str), + snprintf(status_str, sizeof(status_str), "%4u of %u packets", count, cf->count); update_progress_dlg(progbar, progbar_val, status_str); diff --git a/fuzz/fuzzshark.c b/fuzz/fuzzshark.c index 162f23f56a..2c5a754ea4 100644 --- a/fuzz/fuzzshark.c +++ b/fuzz/fuzzshark.c @@ -79,7 +79,7 @@ fuzzshark_pref_set(const char *name, const char *value) prefs_set_pref_e ret; - g_snprintf(pref, sizeof(pref), "%s:%s", name, value); + snprintf(pref, sizeof(pref), "%s:%s", name, value); ret = prefs_set_pref(pref, &errmsg); g_free(errmsg); diff --git a/plugins/epan/ethercat/packet-ams.c b/plugins/epan/ethercat/packet-ams.c index 2c9a7f7b9f..46a598d0b4 100644 --- a/plugins/epan/ethercat/packet-ams.c +++ b/plugins/epan/ethercat/packet-ams.c @@ -372,7 +372,7 @@ static const value_string AMS_CommandId_vals[] = static void NetIdFormater(tvbuff_t *tvb, guint offset, char *szText, gint nMax) { - g_snprintf ( szText, nMax, "%d.%d.%d.%d.%d.%d", tvb_get_guint8(tvb, offset), + snprintf ( szText, nMax, "%d.%d.%d.%d.%d.%d", tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2), tvb_get_guint8(tvb, offset+3), diff --git a/plugins/epan/ethercat/packet-ecatmb.c b/plugins/epan/ethercat/packet-ecatmb.c index 8192d3e523..05c6380868 100644 --- a/plugins/epan/ethercat/packet-ecatmb.c +++ b/plugins/epan/ethercat/packet-ecatmb.c @@ -338,22 +338,22 @@ static void CANopenSdoReqFormatter(PETHERCAT_SDO_HEADER pSdo, char *szText, gint switch ( pSdo->anSdoHeaderUnion.Idq.Ccs ) { case SDO_CCS_INITIATE_DOWNLOAD: - g_snprintf ( szText, nMax, "SDO Req : 'Initiate Download' (%d) Idx=0x%x Sub=%d", pSdo->anSdoHeaderUnion.Idq.Ccs, pSdo->Index, pSdo->SubIndex); + snprintf ( szText, nMax, "SDO Req : 'Initiate Download' (%d) Idx=0x%x Sub=%d", pSdo->anSdoHeaderUnion.Idq.Ccs, pSdo->Index, pSdo->SubIndex); break; case SDO_CCS_INITIATE_UPLOAD: - g_snprintf ( szText, nMax, "SDO Req : 'Initiate Upload' (%d) Idx=0x%x Sub=%d", pSdo->anSdoHeaderUnion.Idq.Ccs, pSdo->Index, pSdo->SubIndex); + snprintf ( szText, nMax, "SDO Req : 'Initiate Upload' (%d) Idx=0x%x Sub=%d", pSdo->anSdoHeaderUnion.Idq.Ccs, pSdo->Index, pSdo->SubIndex); break; case SDO_CCS_DOWNLOAD_SEGMENT: - g_snprintf ( szText, nMax, "SDO Req : 'Download Segment' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); + snprintf ( szText, nMax, "SDO Req : 'Download Segment' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); break; case SDO_CCS_UPLOAD_SEGMENT: - g_snprintf ( szText, nMax, "SDO Req : 'Upload Segment' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); + snprintf ( szText, nMax, "SDO Req : 'Upload Segment' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); break; case SDO_CCS_ABORT_TRANSFER: - g_snprintf ( szText, nMax, "SDO Req : 'Abort Transfer' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); + snprintf ( szText, nMax, "SDO Req : 'Abort Transfer' (%d)", pSdo->anSdoHeaderUnion.Idq.Ccs); break; default: - g_snprintf ( szText, nMax, "SDO Req : Ccs %d", pSdo->anSdoHeaderUnion.Idq.Ccs); + snprintf ( szText, nMax, "SDO Req : Ccs %d", pSdo->anSdoHeaderUnion.Idq.Ccs); } } @@ -378,37 +378,37 @@ static void FoeFormatter(tvbuff_t *tvb, gint offset, char *szText, gint nMax, gu switch ( foe.OpMode ) { case ECAT_FOE_OPMODE_RRQ: - g_snprintf ( szText, nMax, "FoE RRQ (%d) : '%s'", foe.aFoeHeaderDataUnion.FileLength, tmp); + snprintf ( szText, nMax, "FoE RRQ (%d) : '%s'", foe.aFoeHeaderDataUnion.FileLength, tmp); break; case ECAT_FOE_OPMODE_WRQ: - g_snprintf ( szText, nMax, "FoE WRQ (%d) : '%s'", foe.aFoeHeaderDataUnion.FileLength, tmp); + snprintf ( szText, nMax, "FoE WRQ (%d) : '%s'", foe.aFoeHeaderDataUnion.FileLength, tmp); break; case ECAT_FOE_OPMODE_DATA: - g_snprintf ( szText, nMax, "FoE DATA (%d) : %d Bytes", foe.aFoeHeaderDataUnion.v.PacketNo, foe_length-ETHERCAT_FOE_HEADER_LEN); + snprintf ( szText, nMax, "FoE DATA (%d) : %d Bytes", foe.aFoeHeaderDataUnion.v.PacketNo, foe_length-ETHERCAT_FOE_HEADER_LEN); break; case ECAT_FOE_OPMODE_ACK: - g_snprintf ( szText, nMax, "FoE ACK (%d)", foe.aFoeHeaderDataUnion.v.PacketNo); + snprintf ( szText, nMax, "FoE ACK (%d)", foe.aFoeHeaderDataUnion.v.PacketNo); break; case ECAT_FOE_OPMODE_ERR: - g_snprintf ( szText, nMax, "FoE ERR (%d) : '%s'", foe.aFoeHeaderDataUnion.ErrorCode, tmp); + snprintf ( szText, nMax, "FoE ERR (%d) : '%s'", foe.aFoeHeaderDataUnion.ErrorCode, tmp); break; case ECAT_FOE_OPMODE_BUSY: if ( foe.aFoeHeaderDataUnion.v2.Entire > 0 ) - g_snprintf ( szText, nMax, "FoE BUSY (%d%%)", ((guint32)foe.aFoeHeaderDataUnion.v2.Done*100)/foe.aFoeHeaderDataUnion.v2.Entire); + snprintf ( szText, nMax, "FoE BUSY (%d%%)", ((guint32)foe.aFoeHeaderDataUnion.v2.Done*100)/foe.aFoeHeaderDataUnion.v2.Entire); else - g_snprintf ( szText, nMax, "FoE BUSY (%d/%d)", foe.aFoeHeaderDataUnion.v2.Done, foe.aFoeHeaderDataUnion.v2.Entire); + snprintf ( szText, nMax, "FoE BUSY (%d/%d)", foe.aFoeHeaderDataUnion.v2.Done, foe.aFoeHeaderDataUnion.v2.Entire); break; default: - g_snprintf ( szText, nMax, "FoE Unknown"); + snprintf ( szText, nMax, "FoE Unknown"); } } static void SoEIdToString( char* txt, guint16 id, int nMax) { if ( id & 0x8000 ) - g_snprintf(txt, nMax, "P-%d-%04d", (id>>12) & 0x0007, id & 0x0FFF ); + snprintf(txt, nMax, "P-%d-%04d", (id>>12) & 0x0007, id & 0x0FFF ); else - g_snprintf(txt, nMax, "S-%d-%04d", id>>12, id & 0x0FFF ); + snprintf(txt, nMax, "S-%d-%04d", id>>12, id & 0x0FFF ); } static void SoeFormatter(tvbuff_t *tvb, gint offset, char *szText, gint nMax, guint soe_length) @@ -444,32 +444,32 @@ static void SoeFormatter(tvbuff_t *tvb, gint offset, char *szText, gint nMax, gu switch ( soe.anSoeHeaderControlUnion.v.OpCode ) { case ECAT_SOE_OPCODE_RRQ: - g_snprintf ( szText, nMax, "SoE: RRQ (%s, '%s')", tmp, elm); + snprintf ( szText, nMax, "SoE: RRQ (%s, '%s')", tmp, elm); break; case ECAT_SOE_OPCODE_RRS: - g_snprintf ( szText, nMax, "SoE: RRS (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); + snprintf ( szText, nMax, "SoE: RRS (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); break; case ECAT_SOE_OPCODE_WRS: - g_snprintf ( szText, nMax, "SoE: WRS (%s, '%s')", tmp, elm); + snprintf ( szText, nMax, "SoE: WRS (%s, '%s')", tmp, elm); break; case ECAT_SOE_OPCODE_WRQ: - g_snprintf ( szText, nMax, "SoE: WRQ (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); + snprintf ( szText, nMax, "SoE: WRQ (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); break; case ECAT_SOE_OPCODE_NFC: - g_snprintf ( szText, nMax, "SoE: NFC (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); + snprintf ( szText, nMax, "SoE: NFC (%s, '%s') : %u Bytes", tmp, elm, (guint)(soe_length-ETHERCAT_SOE_HEADER_LEN)); break; case 6: - g_snprintf ( szText, nMax, "SoE: EMGCY"); + snprintf ( szText, nMax, "SoE: EMGCY"); break; default: - g_snprintf ( szText, nMax, "SoE:"); + snprintf ( szText, nMax, "SoE:"); } } else - g_snprintf ( szText, nMax, "SoE: FragmentsLeft %d", soe.anSoeHeaderDataUnion.FragmentsLeft); + snprintf ( szText, nMax, "SoE: FragmentsLeft %d", soe.anSoeHeaderDataUnion.FragmentsLeft); } else - g_snprintf ( szText, nMax, "SoE: Error %04x", tvb_get_letohs(tvb, offset)); + snprintf ( szText, nMax, "SoE: Error %04x", tvb_get_letohs(tvb, offset)); } /* ethercat mailbox */ diff --git a/plugins/epan/ethercat/packet-ethercat-datagram.c b/plugins/epan/ethercat/packet-ethercat-datagram.c index 09ae5faa0b..083563c012 100644 --- a/plugins/epan/ethercat/packet-ethercat-datagram.c +++ b/plugins/epan/ethercat/packet-ethercat-datagram.c @@ -1330,26 +1330,26 @@ static void EcSummaryFormater(guint32 datalength, tvbuff_t *tvb, gint offset, ch { guint16 len = ecFirst.len&0x07ff; guint16 cnt = get_wc(&ecFirst, tvb, offset); - g_snprintf ( szText, nMax, "'%s': Len: %d, Adp 0x%x, Ado 0x%x, Wc %d ", + snprintf ( szText, nMax, "'%s': Len: %d, Adp 0x%x, Ado 0x%x, Wc %d ", convertEcCmdToText(ecFirst.cmd, EcCmdShort), len, ecFirst.anAddrUnion.a.adp, ecFirst.anAddrUnion.a.ado, cnt ); } else if ( nSub == 2 ) { - g_snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d ", + snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d ", nSub, convertEcCmdToText(nCmds[0], EcCmdShort), nLens[0], convertEcCmdToText(nCmds[1], EcCmdShort), nLens[1]); } else if ( nSub == 3 ) { - g_snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d, '%s': len %d", + snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d, '%s': len %d", nSub, convertEcCmdToText(nCmds[0], EcCmdShort), nLens[0], convertEcCmdToText(nCmds[1], EcCmdShort), nLens[1], convertEcCmdToText(nCmds[2], EcCmdShort), nLens[2]); } else if ( nSub == 4 ) { - g_snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d, '%s': len %d, '%s': len %d", + snprintf ( szText, nMax, "%d Cmds, '%s': len %d, '%s': len %d, '%s': len %d, '%s': len %d", nSub, convertEcCmdToText(nCmds[0], EcCmdShort), nLens[0], convertEcCmdToText(nCmds[1], EcCmdShort), nLens[1], convertEcCmdToText(nCmds[2], EcCmdShort), nLens[2], convertEcCmdToText(nCmds[3], EcCmdShort), nLens[3]); } else - g_snprintf ( szText, nMax, "%d Cmds, SumLen %d, '%s'... ", + snprintf ( szText, nMax, "%d Cmds, SumLen %d, '%s'... ", nSub, nLen, convertEcCmdToText(ecFirst.cmd, EcCmdShort)); } @@ -1359,9 +1359,9 @@ static void EcCmdFormatter(guint8 cmd, char *szText, gint nMax) const gchar *szCmd = try_val_to_str_idx((guint32)cmd, EcCmdLong, &idx); if ( idx != -1 ) - g_snprintf(szText, nMax, "Cmd : %d (%s)", cmd, szCmd); + snprintf(szText, nMax, "Cmd : %d (%s)", cmd, szCmd); else - g_snprintf(szText, nMax, "Cmd : %d (Unknown command)", cmd); + snprintf(szText, nMax, "Cmd : %d (Unknown command)", cmd); } @@ -1388,20 +1388,20 @@ static void EcSubFormatter(tvbuff_t *tvb, gint offset, char *szText, gint nMax) case EC_CMD_TYPE_BRW: case EC_CMD_TYPE_ARMW: case EC_CMD_TYPE_FRMW: - g_snprintf ( szText, nMax, "EtherCAT datagram: Cmd: '%s' (%d), Len: %d, Adp 0x%x, Ado 0x%x, Cnt %d", + snprintf ( szText, nMax, "EtherCAT datagram: Cmd: '%s' (%d), Len: %d, Adp 0x%x, Ado 0x%x, Cnt %d", convertEcCmdToText(ecParser.cmd, EcCmdShort), ecParser.cmd, len, ecParser.anAddrUnion.a.adp, ecParser.anAddrUnion.a.ado, cnt); break; case EC_CMD_TYPE_LRD: case EC_CMD_TYPE_LWR: case EC_CMD_TYPE_LRW: - g_snprintf ( szText, nMax, "EtherCAT datagram: Cmd: '%s' (%d), Len: %d, Addr 0x%x, Cnt %d", + snprintf ( szText, nMax, "EtherCAT datagram: Cmd: '%s' (%d), Len: %d, Addr 0x%x, Cnt %d", convertEcCmdToText(ecParser.cmd, EcCmdShort), ecParser.cmd, len, ecParser.anAddrUnion.addr, cnt); break; case EC_CMD_TYPE_EXT: - g_snprintf ( szText, nMax, "EtherCAT datagram: Cmd: 'EXT' (%d), Len: %d", ecParser.cmd, len); + snprintf ( szText, nMax, "EtherCAT datagram: Cmd: 'EXT' (%d), Len: %d", ecParser.cmd, len); break; default: - g_snprintf ( szText, nMax, "EtherCAT datagram: Cmd: 'Unknown' (%d), Len: %d", ecParser.cmd, len); + snprintf ( szText, nMax, "EtherCAT datagram: Cmd: 'Unknown' (%d), Len: %d", ecParser.cmd, len); } } diff --git a/plugins/epan/ethercat/packet-ioraw.c b/plugins/epan/ethercat/packet-ioraw.c index 273e085918..3122db1c8e 100644 --- a/plugins/epan/ethercat/packet-ioraw.c +++ b/plugins/epan/ethercat/packet-ioraw.c @@ -33,7 +33,7 @@ static int hf_ioraw_data = -1; /*ioraw*/ static void IoRawSummaryFormater( char *szText, int nMax) { - g_snprintf ( szText, nMax, "Raw IO Data" ); + snprintf ( szText, nMax, "Raw IO Data" ); } static int dissect_ioraw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) diff --git a/plugins/epan/ethercat/packet-nv.c b/plugins/epan/ethercat/packet-nv.c index d66f2d2578..12965ee40c 100644 --- a/plugins/epan/ethercat/packet-nv.c +++ b/plugins/epan/ethercat/packet-nv.c @@ -47,7 +47,7 @@ static void NvSummaryFormater(tvbuff_t *tvb, gint offset, char *szText, int nMax { guint32 nvOffset = offset; - g_snprintf ( szText, nMax, "Network Vars from %d.%d.%d.%d.%d.%d - %d Var(s)", + snprintf ( szText, nMax, "Network Vars from %d.%d.%d.%d.%d.%d - %d Var(s)", tvb_get_guint8(tvb, nvOffset), tvb_get_guint8(tvb, nvOffset+1), tvb_get_guint8(tvb, nvOffset+2), @@ -61,7 +61,7 @@ static void NvPublisherFormater(tvbuff_t *tvb, gint offset, char *szText, int nM { guint32 nvOffset = offset; - g_snprintf ( szText, nMax, "Publisher %d.%d.%d.%d.%d.%d", + snprintf ( szText, nMax, "Publisher %d.%d.%d.%d.%d.%d", tvb_get_guint8(tvb, nvOffset), tvb_get_guint8(tvb, nvOffset+1), tvb_get_guint8(tvb, nvOffset+2), @@ -72,7 +72,7 @@ static void NvPublisherFormater(tvbuff_t *tvb, gint offset, char *szText, int nM static void NvVarHeaderFormater(tvbuff_t *tvb, gint offset, char *szText, int nMax) { - g_snprintf ( szText, nMax, "Variable - Id = %d, Length = %d", + snprintf ( szText, nMax, "Variable - Id = %d, Length = %d", tvb_get_letohs(tvb, offset), tvb_get_letohs(tvb, offset+4)); } diff --git a/plugins/epan/irda/packet-irda.c b/plugins/epan/irda/packet-irda.c index 79dc458b96..2a6ac60499 100644 --- a/plugins/epan/irda/packet-irda.c +++ b/plugins/epan/irda/packet-irda.c @@ -492,7 +492,7 @@ static guint dissect_ttp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, gb head = tvb_get_guint8(tvb, offset); - g_snprintf(buf, 128, ", Credit=%d", head & ~TTP_PARAMETERS); + snprintf(buf, 128, ", Credit=%d", head & ~TTP_PARAMETERS); col_append_str(pinfo->cinfo, COL_INFO, buf); if (root) @@ -743,7 +743,7 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro break; case IAS_OCT_SEQ: - g_snprintf(buf, 300, ", %d Octets", tvb_get_ntohs(tvb, offset + 7)); + snprintf(buf, 300, ", %d Octets", tvb_get_ntohs(tvb, offset + 7)); break; case IAS_STRING: @@ -1764,7 +1764,7 @@ static void dissect_irlap(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root) circuit_id = tvb_get_guint8(tvb, 0); /* initially set address columns to connection address */ - g_snprintf(addr, sizeof(addr)-1, "0x%02X", circuit_id >> 1); + snprintf(addr, sizeof(addr)-1, "0x%02X", circuit_id >> 1); col_add_str(pinfo->cinfo, COL_DEF_SRC, addr); col_add_str(pinfo->cinfo, COL_DEF_DST, addr); diff --git a/plugins/epan/mate/mate_grammar.lemon b/plugins/epan/mate/mate_grammar.lemon index 73b320d8d6..ef8289ea8f 100644 --- a/plugins/epan/mate/mate_grammar.lemon +++ b/plugins/epan/mate/mate_grammar.lemon @@ -79,7 +79,7 @@ static void configuration_error(mate_config* mc, const gchar* fmt, ...) { va_list list; va_start( list, fmt ); - g_vsnprintf(error_buffer,sizeof(error_buffer),fmt,list); + vsnprintf(error_buffer,sizeof(error_buffer),fmt,list); va_end( list ); i = (gint) mc->config_stack->len; diff --git a/plugins/epan/mate/mate_setup.c b/plugins/epan/mate/mate_setup.c index 727b536bd7..3f88abbd2d 100644 --- a/plugins/epan/mate/mate_setup.c +++ b/plugins/epan/mate/mate_setup.c @@ -21,7 +21,7 @@ static void report_error(mate_config* mc, const gchar* fmt, ...) { va_list list; va_start( list, fmt ); - g_vsnprintf(error_buffer,DEBUG_BUFFER_SIZE,fmt,list); + vsnprintf(error_buffer,DEBUG_BUFFER_SIZE,fmt,list); va_end( list ); g_string_append(mc->config_error,error_buffer); diff --git a/plugins/epan/mate/mate_util.c b/plugins/epan/mate/mate_util.c index 6bc6f63f5d..30a4f098b4 100644 --- a/plugins/epan/mate/mate_util.c +++ b/plugins/epan/mate/mate_util.c @@ -38,7 +38,7 @@ void dbg_print(const gint* which, gint how, FILE* where, const gchar* fmt, ... ) if ( ! which || *which < how ) return; va_start( list, fmt ); - g_vsnprintf(debug_buffer,DEBUG_BUFFER_SIZE,fmt,list); + vsnprintf(debug_buffer,DEBUG_BUFFER_SIZE,fmt,list); va_end( list ); if (! where) { @@ -193,7 +193,7 @@ gchar* scs_subscribe_printf(SCS_collection* c, gchar* fmt, ...) { static gchar buf[SCS_HUGE_SIZE]; va_start( list, fmt ); - g_vsnprintf(buf, SCS_HUGE_SIZE, fmt, list); + vsnprintf(buf, SCS_HUGE_SIZE, fmt, list); va_end( list ); return scs_subscribe(c,buf); @@ -1559,7 +1559,7 @@ extern LoAL* loal_from_file(gchar* filename) { i = 0; name[i++] = c; name[i] = '\0'; - g_snprintf(linenum_buf,MAX_ITEM_LEN,"%s:%u",filename,linenum); + snprintf(linenum_buf,MAX_ITEM_LEN,"%s:%u",filename,linenum); curr = new_avpl(linenum_buf); continue; case '#': diff --git a/plugins/epan/opcua/opcua_simpletypes.c b/plugins/epan/opcua/opcua_simpletypes.c index 945b528794..dc1bb0457b 100644 --- a/plugins/epan/opcua/opcua_simpletypes.c +++ b/plugins/epan/opcua/opcua_simpletypes.c @@ -1134,7 +1134,7 @@ void parseArrayComplex(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint for (i=0; icinfo, COL_INFO, "%s, Seq=%3u, Delay=%11" G_GINT64_MODIFIER "uns", + col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq=%3u, Delay=%11" PRIu64 "ns", name, seq_id, delay1ns_64); - proto_item_append_text(item, "%s: Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", + proto_item_append_text(item, "%s: Sequence=%u, Delay=%" PRIu64 "ns", name_short, seq_id, delay1ns_64); - proto_item_append_text(header_item, ": Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", + proto_item_append_text(header_item, ": Sequence=%u, Delay=%" PRIu64 "ns", seq_id, delay1ns_64); if (delay1ns_64 != 0) diff --git a/plugins/epan/profinet/packet-pn-rt.c b/plugins/epan/profinet/packet-pn-rt.c index b03e946647..9564c55590 100644 --- a/plugins/epan/profinet/packet-pn-rt.c +++ b/plugins/epan/profinet/packet-pn-rt.c @@ -843,7 +843,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U u8DataStatus = tvb_get_guint8(tvb, pdu_len - 2); u8TransferStatus = tvb_get_guint8(tvb, pdu_len - 1); - g_snprintf (szFieldSummary, sizeof(szFieldSummary), + snprintf (szFieldSummary, sizeof(szFieldSummary), "%sID:0x%04x, Len:%4u, Cycle:%5u (%s,%s,%s,%s)", pszProtAddInfo, u16FrameID, pdu_len - 2 - 4, u16CycleCounter, (u8DataStatus & 0x04) ? "Valid" : "Invalid", @@ -860,7 +860,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U u8TransferStatus = 0; /* acyclic transfer has no fields at the end */ - g_snprintf (szFieldSummary, sizeof(szFieldSummary), + snprintf (szFieldSummary, sizeof(szFieldSummary), "%sID:0x%04x, Len:%4u", pszProtAddInfo, u16FrameID, pdu_len - 2); @@ -907,7 +907,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U /* update column info now */ if (u16FrameID == 0xFE02) { - g_snprintf(szFieldSummary, sizeof(szFieldSummary), "%s", ""); + snprintf(szFieldSummary, sizeof(szFieldSummary), "%s", ""); } col_add_str(pinfo->cinfo, COL_INFO, szFieldSummary); col_set_str(pinfo->cinfo, COL_PROTOCOL, pszProtShort); diff --git a/plugins/epan/stats_tree/pinfo_stats_tree.c b/plugins/epan/stats_tree/pinfo_stats_tree.c index 4600918ce4..ce715c887b 100644 --- a/plugins/epan/stats_tree/pinfo_stats_tree.c +++ b/plugins/epan/stats_tree/pinfo_stats_tree.c @@ -230,7 +230,7 @@ static tap_packet_status dsts_stats_tree_packet(stats_tree *st, packet_info *pin tick_stat_node(st, st_str, 0, FALSE); ip_dst_node = tick_stat_node(st, address_to_str(pinfo->pool, &pinfo->net_dst), st_node, TRUE); protocol_node = tick_stat_node(st, port_type_to_str(pinfo->ptype), ip_dst_node, TRUE); - g_snprintf(str, sizeof(str) - 1, "%u", pinfo->destport); + snprintf(str, sizeof(str) - 1, "%u", pinfo->destport); tick_stat_node(st, str, protocol_node, TRUE); return TAP_PACKET_REDRAW; } diff --git a/rawshark.c b/rawshark.c index 24fde246c2..9af3899e42 100644 --- a/rawshark.c +++ b/rawshark.c @@ -971,7 +971,7 @@ process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset, /* The user sends an empty packet when he wants to get output from us even if we don't currently have packets to process. We spit out a line with the timestamp and the text "void" */ - printf("%lu %" G_GUINT64_FORMAT " %d void -\n", (unsigned long int)cf->count, + printf("%lu %" PRIu64 " %d void -\n", (unsigned long int)cf->count, (guint64)rec->ts.secs, rec->ts.nsecs); fflush(stdout); @@ -1104,7 +1104,7 @@ static void field_display_to_string(header_field_info *hfi, char* buf, int size) } else { - g_snprintf(buf, size, "(Bit count: %d)", hfi->display); + snprintf(buf, size, "(Bit count: %d)", hfi->display); } } diff --git a/reordercap.c b/reordercap.c index c818772d7b..256a1dd326 100644 --- a/reordercap.c +++ b/reordercap.c @@ -84,7 +84,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, int err; gchar *err_info; - DEBUG_PRINT("\nDumping frame (offset=%" G_GINT64_MODIFIER "u)\n", + DEBUG_PRINT("\nDumping frame (offset=%" PRIu64 ")\n", frame->offset); diff --git a/ringbuffer.c b/ringbuffer.c index 4893236837..ddd1dea4a8 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -227,7 +227,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err) #endif current_time = time(NULL); - g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES); + snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES); tm = localtime(¤t_time); if (tm != NULL) strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", tm); diff --git a/sharkd_session.c b/sharkd_session.c index 31163f5d82..32aaa1e505 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -1125,7 +1125,7 @@ sharkd_session_process_status(void) gint64 file_size = wtap_file_size(cfile.provider.wth, NULL); if (file_size > 0) - sharkd_json_value_anyf("filesize", "%" G_GINT64_FORMAT, file_size); + sharkd_json_value_anyf("filesize", "%" PRId64, file_size); } sharkd_json_result_epilogue(); @@ -2191,11 +2191,11 @@ sharkd_session_process_tap_conv_cb(void *arg) wmem_free(NULL, dst_port); } - sharkd_json_value_anyf("rxf", "%" G_GUINT64_FORMAT, iui->rx_frames); - sharkd_json_value_anyf("rxb", "%" G_GUINT64_FORMAT, iui->rx_bytes); + sharkd_json_value_anyf("rxf", "%" PRIu64, iui->rx_frames); + sharkd_json_value_anyf("rxb", "%" PRIu64, iui->rx_bytes); - sharkd_json_value_anyf("txf", "%" G_GUINT64_FORMAT, iui->tx_frames); - sharkd_json_value_anyf("txb", "%" G_GUINT64_FORMAT, iui->tx_bytes); + sharkd_json_value_anyf("txf", "%" PRIu64, iui->tx_frames); + sharkd_json_value_anyf("txb", "%" PRIu64, iui->tx_bytes); sharkd_json_value_anyf("start", "%.9f", nstime_to_sec(&iui->start_time)); sharkd_json_value_anyf("stop", "%.9f", nstime_to_sec(&iui->stop_time)); @@ -2237,11 +2237,11 @@ sharkd_session_process_tap_conv_cb(void *arg) wmem_free(NULL, port_str); } - sharkd_json_value_anyf("rxf", "%" G_GUINT64_FORMAT, host->rx_frames); - sharkd_json_value_anyf("rxb", "%" G_GUINT64_FORMAT, host->rx_bytes); + sharkd_json_value_anyf("rxf", "%" PRIu64, host->rx_frames); + sharkd_json_value_anyf("rxb", "%" PRIu64, host->rx_bytes); - sharkd_json_value_anyf("txf", "%" G_GUINT64_FORMAT, host->tx_frames); - sharkd_json_value_anyf("txb", "%" G_GUINT64_FORMAT, host->tx_bytes); + sharkd_json_value_anyf("txf", "%" PRIu64, host->tx_frames); + sharkd_json_value_anyf("txb", "%" PRIu64, host->tx_bytes); filter_str = get_hostlist_filter(host); if (filter_str) @@ -3881,7 +3881,7 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count) { if (st.frames != 0) { - sharkd_json_value_anyf(NULL, "[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", idx, st.frames, st.bytes); + sharkd_json_value_anyf(NULL, "[%" PRId64 ",%u,%" PRIu64 "]", idx, st.frames, st.bytes); } idx = new_idx; @@ -3901,13 +3901,13 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count) if (st.frames != 0) { - sharkd_json_value_anyf(NULL, "[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", idx, st.frames, st.bytes); + sharkd_json_value_anyf(NULL, "[%" PRId64 ",%u,%" PRIu64 "]", idx, st.frames, st.bytes); } sharkd_json_array_close(); - sharkd_json_value_anyf("last", "%" G_GINT64_FORMAT, max_idx); + sharkd_json_value_anyf("last", "%" PRId64, max_idx); sharkd_json_value_anyf("frames", "%u", st_total.frames); - sharkd_json_value_anyf("bytes", "%" G_GUINT64_FORMAT, st_total.bytes); + sharkd_json_value_anyf("bytes", "%" PRIu64, st_total.bytes); sharkd_json_result_epilogue(); } diff --git a/text2pcap.c b/text2pcap.c index 33a4e840cc..b96115f494 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -1938,7 +1938,7 @@ main(int argc, char *argv[]) if (debug) fprintf(stderr, "\n-------------------------\n"); if (!quiet) { - fprintf(stderr, "Read %u potential packet%s, wrote %u packet%s (%" G_GINT64_MODIFIER "u byte%s).\n", + fprintf(stderr, "Read %u potential packet%s, wrote %u packet%s (%" PRIu64 " byte%s).\n", num_packets_read, (num_packets_read == 1) ? "" : "s", num_packets_written, (num_packets_written == 1) ? "" : "s", bytes_written, (bytes_written == 1) ? "" : "s"); diff --git a/tfshark.c b/tfshark.c index c8f543376d..4c245d9dc7 100644 --- a/tfshark.c +++ b/tfshark.c @@ -2036,7 +2036,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp return CF_OK; /* fail: */ - g_snprintf(err_msg, sizeof err_msg, + snprintf(err_msg, sizeof err_msg, cf_open_error_message(*err, err_info, FALSE, cf->cd_t), fname); cmdarg_err("%s", err_msg); return CF_ERROR; @@ -2094,7 +2094,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_UNSUPPORTED: /* Seen only when opening a capture file for reading. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" isn't a capture file in a format TFShark understands.\n" "(%s)", err_info); g_free(err_info); @@ -2103,7 +2103,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_CANT_WRITE_TO_PIPE: /* Seen only when opening a capture file for writing. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" is a pipe, and \"%s\" capture files can't be " "written to a pipe.", ftap_file_type_subtype_short_string(file_type)); errmsg = errmsg_errno; @@ -2116,11 +2116,11 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_UNSUPPORTED_ENCAP: if (for_writing) { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "TFShark can't save this capture as a \"%s\" file.", ftap_file_type_subtype_short_string(file_type)); } else { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" is a capture for a network type that TFShark doesn't support.\n" "(%s)", err_info); g_free(err_info); @@ -2130,7 +2130,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_ENCAP_PER_RECORD_UNSUPPORTED: if (for_writing) { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "TFShark can't save this capture as a \"%s\" file.", ftap_file_type_subtype_short_string(file_type)); errmsg = errmsg_errno; @@ -2140,7 +2140,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_BAD_FILE: /* Seen only when opening a capture file for reading. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" appears to be damaged or corrupt.\n" "(%s)", err_info); g_free(err_info); @@ -2169,7 +2169,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, case FTAP_ERR_DECOMPRESS: /* Seen only when opening a capture file for reading. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The compressed file \"%%s\" appears to be damaged or corrupt.\n" "(%s)", err_info); g_free(err_info); @@ -2177,7 +2177,7 @@ cf_open_error_message(int err, gchar *err_info _U_, gboolean for_writing, break; default: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" could not be %s: %s.", for_writing ? "created" : "opened", ftap_strerror(err)); diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl index b49c3f633b..58ca5dc798 100755 --- a/tools/checkAPIs.pl +++ b/tools/checkAPIs.pl @@ -1172,7 +1172,7 @@ while ($_ = pop @filelist) if ($fileContents =~ m{ %ll }xo) { - # use G_GINT64_MODIFIER instead of ll + # use PRI[dux...]N instead of ll print STDERR "Error: Found %ll in " .$filename."\n"; $errorCount++; } diff --git a/tshark.c b/tshark.c index af8dc1f047..499632c6f6 100644 --- a/tshark.c +++ b/tshark.c @@ -3169,7 +3169,7 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count, * (unless we roll over max_packet_count ?) */ if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) { - ws_debug("tshark: max_packet_count (%d) or max_byte_count (%" G_GINT64_MODIFIER "d/%" G_GINT64_MODIFIER "d) reached", + ws_debug("tshark: max_packet_count (%d) or max_byte_count (%" PRId64 "/%" PRId64 ") reached", max_packet_count, data_offset, max_byte_count); *err = 0; /* This is not an error */ break; @@ -3528,7 +3528,7 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh, * (unless we roll over max_packet_count ?) */ if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) { - ws_debug("tshark: max_packet_count (%d) or max_byte_count (%" G_GINT64_MODIFIER "d/%" G_GINT64_MODIFIER "d) reached", + ws_debug("tshark: max_packet_count (%d) or max_byte_count (%" PRId64 "/%" PRId64 ") reached", max_packet_count, data_offset, max_byte_count); *err = 0; /* This is not an error */ break; @@ -4104,7 +4104,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_DST: case COL_RES_DST: case COL_UNRES_DST: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; @@ -4124,7 +4124,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_DL_DST: case COL_RES_DL_DST: case COL_UNRES_DL_DST: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; @@ -4144,7 +4144,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_NET_DST: case COL_RES_NET_DST: case COL_UNRES_NET_DST: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_RIGHTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; @@ -4164,7 +4164,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_SRC: case COL_RES_SRC: case COL_UNRES_SRC: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; @@ -4184,7 +4184,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_DL_SRC: case COL_RES_DL_SRC: case COL_UNRES_DL_SRC: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; @@ -4204,7 +4204,7 @@ print_columns(capture_file *cf, const epan_dissect_t *edt) case COL_DEF_NET_SRC: case COL_RES_NET_SRC: case COL_UNRES_NET_SRC: - g_snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); + snprintf(str_format, sizeof(str_format), "%s%s%s", delimiter_char, UTF8_LEFTWARDS_ARROW, delimiter_char); put_string(line_bufp + buf_offset, str_format, 5); buf_offset += 5; break; diff --git a/ui/capture.c b/ui/capture.c index 5a5c6a2015..d627925847 100644 --- a/ui/capture.c +++ b/ui/capture.c @@ -307,7 +307,7 @@ cf_open_error_message(int err, gchar *err_info) break; case WTAP_ERR_UNSUPPORTED: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" contains record data that Wireshark doesn't support.\n" "(%s)", err_info != NULL ? err_info : "no information supplied"); g_free(err_info); @@ -319,7 +319,7 @@ cf_open_error_message(int err, gchar *err_info) break; case WTAP_ERR_BAD_FILE: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" appears to be damaged or corrupt.\n" "(%s)", err_info != NULL ? err_info : "no information supplied"); g_free(err_info); @@ -336,7 +336,7 @@ cf_open_error_message(int err, gchar *err_info) break; case WTAP_ERR_DECOMPRESS: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" cannot be decompressed; it may be damaged or corrupt.\n" "(%s)", err_info != NULL ? err_info : "no information supplied"); g_free(err_info); @@ -344,7 +344,7 @@ cf_open_error_message(int err, gchar *err_info) break; case WTAP_ERR_INTERNAL: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "An internal error occurred opening the file \"%%s\".\n" "(%s)", err_info != NULL ? err_info : "no information supplied"); g_free(err_info); @@ -352,7 +352,7 @@ cf_open_error_message(int err, gchar *err_info) break; case WTAP_ERR_DECOMPRESSION_NOT_SUPPORTED: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" cannot be decompressed; it is compressed in a way that We don't support.\n" "(%s)", err_info != NULL ? err_info : "no information supplied"); g_free(err_info); @@ -360,7 +360,7 @@ cf_open_error_message(int err, gchar *err_info) break; default: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" could not be opened: %s.", wtap_strerror(err)); errmsg = errmsg_errno; diff --git a/ui/cli/tap-endpoints.c b/ui/cli/tap-endpoints.c index 690cdb1742..948ca242a1 100644 --- a/ui/cli/tap-endpoints.c +++ b/ui/cli/tap-endpoints.c @@ -71,9 +71,9 @@ endpoints_draw(void *arg) if (display_port) { /* XXX - TODO: make port resolution configurable (through gbl_resolv_flags?) */ port_str = get_conversation_port(NULL, host->port, host->etype, TRUE); - printf("%-20s %5s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER - "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" - G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u \n", + printf("%-20s %5s %6" PRIu64 " %9" PRIu64 + " %6" PRIu64 " %9" PRIu64 " %6" + PRIu64 " %9" PRIu64 " \n", conversation_str, port_str, host->tx_frames+host->rx_frames, host->tx_bytes+host->rx_bytes, @@ -81,9 +81,9 @@ endpoints_draw(void *arg) host->rx_frames, host->rx_bytes); wmem_free(NULL, port_str); } else { - printf("%-20s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER - "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" - G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u \n", + printf("%-20s %6" PRIu64 " %9" PRIu64 + " %6" PRIu64 " %9" PRIu64 " %6" + PRIu64 " %9" PRIu64 " \n", /* XXX - TODO: make name resolution configurable (through gbl_resolv_flags?) */ conversation_str, host->tx_frames+host->rx_frames, host->tx_bytes+host->rx_bytes, diff --git a/ui/cli/tap-exportobject.c b/ui/cli/tap-exportobject.c index 6ce85cec62..d97f99e966 100644 --- a/ui/cli/tap-exportobject.c +++ b/ui/cli/tap-exportobject.c @@ -130,7 +130,7 @@ eo_draw(void *tapdata) char generic_name[EXPORT_OBJECT_MAXFILELEN+1]; const char *ext; ext = eo_ct2ext(entry->content_type); - g_snprintf(generic_name, sizeof(generic_name), + snprintf(generic_name, sizeof(generic_name), "object%u%s%s", entry->pkt_num, ext ? "." : "", ext ? ext : ""); safe_filename = eo_massage_str(generic_name, EXPORT_OBJECT_MAXFILELEN, count); diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c index 9203781800..865d91afde 100644 --- a/ui/cli/tap-follow.c +++ b/ui/cli/tap-follow.c @@ -116,7 +116,7 @@ static void follow_print_hex(const char *prefixp, guint32 offset, void *datap, i if ((ii % BYTES_PER_LINE) == 0) { /* new line */ - g_snprintf(line, LINE_LEN + 1, "%0*X", OFFSET_LEN, offset); + snprintf(line, LINE_LEN + 1, "%0*X", OFFSET_LEN, offset); memset(line + HEX_START - OFFSET_SPACE, ' ', HEX_LEN + OFFSET_SPACE + HEX_SPACE); diff --git a/ui/cli/tap-iostat.c b/ui/cli/tap-iostat.c index e45edcd3e0..b810ff0743 100644 --- a/ui/cli/tap-iostat.c +++ b/ui/cli/tap-iostat.c @@ -598,7 +598,7 @@ iostat_draw(void *arg) dur_nsecs = (int)(duration%G_GUINT64_CONSTANT(1000000)); dur_nsecs_orig = dur_nsecs; dur_mag = magnitude((guint64)dur_secs, 5); - g_snprintf(dur_mag_s, 3, "%u", dur_mag); + snprintf(dur_mag_s, 3, "%u", dur_mag); /* Calc the interval's magnitude */ invl_mag = magnitude(interval/G_GUINT64_CONSTANT(1000000), 5); @@ -678,7 +678,7 @@ iostat_draw(void *arg) fr_mag = MAX(6, fr_mag); col_w[j].fr = fr_mag; tabrow_w += col_w[j].fr + 3; - g_snprintf(fr_mag_s, 3, "%u", fr_mag); + snprintf(fr_mag_s, 3, "%u", fr_mag); if (type == CALC_TYPE_FRAMES) { fmt = g_strconcat(" %", fr_mag_s, "u |", NULL); @@ -689,8 +689,8 @@ iostat_draw(void *arg) val_mag = MAX(5, val_mag); col_w[j].val = val_mag; tabrow_w += (col_w[j].val + 3); - g_snprintf(val_mag_s, 3, "%u", val_mag); - fmt = g_strconcat(" %", fr_mag_s, "u |", " %", val_mag_s, G_GINT64_MODIFIER, "u |", NULL); + snprintf(val_mag_s, 3, "%u", val_mag); + fmt = g_strconcat(" %", fr_mag_s, "u |", " %", val_mag_s, PRIu64 " |", NULL); } if (fmt) fmts[j] = fmt; @@ -703,8 +703,8 @@ iostat_draw(void *arg) val_mag = magnitude(iot->max_vals[j], 15); val_mag = MAX(5, val_mag); col_w[j].val = val_mag; - g_snprintf(val_mag_s, 3, "%u", val_mag); - fmt = g_strconcat(" %", val_mag_s, G_GINT64_MODIFIER, "u |", NULL); + snprintf(val_mag_s, 3, "%u", val_mag); + fmt = g_strconcat(" %", val_mag_s, PRIu64 " |", NULL); break; default: @@ -713,7 +713,7 @@ iostat_draw(void *arg) case FT_FLOAT: case FT_DOUBLE: val_mag = magnitude(iot->max_vals[j], 15); - g_snprintf(val_mag_s, 3, "%u", val_mag); + snprintf(val_mag_s, 3, "%u", val_mag); fmt = g_strconcat(" %", val_mag_s, ".6f |", NULL); col_w[j].val = val_mag + 7; break; @@ -726,7 +726,7 @@ iostat_draw(void *arg) iot->max_vals[j] = (iot->max_vals[j] + G_GUINT64_CONSTANT(500000000)) / NANOSECS_PER_SEC; } val_mag = magnitude(iot->max_vals[j], 15); - g_snprintf(val_mag_s, 3, "%u", val_mag); + snprintf(val_mag_s, 3, "%u", val_mag); fmt = g_strconcat(" %", val_mag_s, "u.%06u |", NULL); col_w[j].val = val_mag + 7; break; @@ -735,7 +735,7 @@ iostat_draw(void *arg) val_mag = magnitude(iot->max_vals[j], 15); val_mag = MAX(namelen, val_mag); col_w[j].val = val_mag; - g_snprintf(val_mag_s, 3, "%u", val_mag); + snprintf(val_mag_s, 3, "%u", val_mag); switch (ftype) { case FT_UINT8: @@ -743,14 +743,14 @@ iostat_draw(void *arg) case FT_UINT24: case FT_UINT32: case FT_UINT64: - fmt = g_strconcat(" %", val_mag_s, G_GINT64_MODIFIER, "u |", NULL); + fmt = g_strconcat(" %", val_mag_s, PRIu64 " |", NULL); break; case FT_INT8: case FT_INT16: case FT_INT24: case FT_INT32: case FT_INT64: - fmt = g_strconcat(" %", val_mag_s, G_GINT64_MODIFIER, "d |", NULL); + fmt = g_strconcat(" %", val_mag_s, PRId64 " |", NULL); break; } } /* End of ftype switch */ @@ -810,7 +810,7 @@ iostat_draw(void *arg) spaces_s = &spaces[18 + dur_mag]; printf(full_fmt, (guint32)(interval/G_GUINT64_CONSTANT(1000000)), spaces_s); } else { - g_snprintf(invl_prec_s, 3, "%u", invl_prec); + snprintf(invl_prec_s, 3, "%u", invl_prec); invl_fmt = g_strconcat("%", dur_mag_s, "u.%0", invl_prec_s, "u", NULL); full_fmt = g_strconcat("| Duration: ", invl_fmt, " secs%s|\n", NULL); spaces_s = &spaces[19 + dur_mag + invl_prec]; @@ -1083,7 +1083,7 @@ iostat_draw(void *arg) int maxw; maxw = dur_mag >= 3 ? dur_mag+1 : 3; g_free(full_fmt); - g_snprintf(dur_mag_s, 3, "%u", maxw); + snprintf(dur_mag_s, 3, "%u", maxw); full_fmt = g_strconcat( dur_mag == 1 ? "| " : "| ", invl_fmt, " <> ", "%-", dur_mag_s, "s|", NULL); diff --git a/ui/cli/tap-iousers.c b/ui/cli/tap-iousers.c index c828a14ae0..af21fff5fb 100644 --- a/ui/cli/tap-iousers.c +++ b/ui/cli/tap-iousers.c @@ -111,9 +111,9 @@ iousers_draw(void *arg) dst_port = get_conversation_port(NULL, iui->dst_port, iui->etype, TRUE); src = wmem_strconcat(NULL, src_addr, ":", src_port, NULL); dst = wmem_strconcat(NULL, dst_addr, ":", dst_port, NULL); - printf("%-26s <-> %-26s %6" G_GINT64_MODIFIER "u %-9s" - " %6" G_GINT64_MODIFIER "u %-9s" - " %6" G_GINT64_MODIFIER "u %-9s ", + printf("%-26s <-> %-26s %6" PRIu64 " %-9s" + " %6" PRIu64 " %-9s" + " %6" PRIu64 " %-9s ", src, dst, iui->rx_frames, rx_bytes, iui->tx_frames, tx_bytes, @@ -125,9 +125,9 @@ iousers_draw(void *arg) wmem_free(NULL, src); wmem_free(NULL, dst); } else { - printf("%-20s <-> %-20s %6" G_GINT64_MODIFIER "u %-9s" - " %6" G_GINT64_MODIFIER "u %-9s" - " %6" G_GINT64_MODIFIER "u %-9s ", + printf("%-20s <-> %-20s %6" PRIu64 " %-9s" + " %6" PRIu64 " %-9s" + " %6" PRIu64 " %-9s ", src_addr, dst_addr, iui->rx_frames, rx_bytes, iui->tx_frames, tx_bytes, diff --git a/ui/cli/tap-protohierstat.c b/ui/cli/tap-protohierstat.c index 02bb57102e..d241ecb54e 100644 --- a/ui/cli/tap-protohierstat.c +++ b/ui/cli/tap-protohierstat.c @@ -129,13 +129,13 @@ phs_draw(phs_t *rs, int indentation) stroff = 0; for (i=0; i 15) { - stroff += g_snprintf(str+stroff, MAXPHSLINE-stroff, "..."); + stroff += snprintf(str+stroff, MAXPHSLINE-stroff, "..."); break; } - stroff += g_snprintf(str+stroff, MAXPHSLINE-stroff, " "); + stroff += snprintf(str+stroff, MAXPHSLINE-stroff, " "); } - g_snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name); - printf("%-40s frames:%u bytes:%" G_GINT64_MODIFIER "u\n", str, rs->frames, rs->bytes); + snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name); + printf("%-40s frames:%u bytes:%" PRIu64 "\n", str, rs->frames, rs->bytes); phs_draw(rs->child, indentation+1); } } diff --git a/ui/cli/tap-rpcprogs.c b/ui/cli/tap-rpcprogs.c index a0de2ad8cf..834bb83a6e 100644 --- a/ui/cli/tap-rpcprogs.c +++ b/ui/cli/tap-rpcprogs.c @@ -184,8 +184,8 @@ rpcprogs_draw(void *dummy _U_) td = ((guint64)(rp->tot.secs)) * NANOSECS_PER_SEC + rp->tot.nsecs; td = ((td / rp->num) + 500) / 1000; - g_snprintf(str, sizeof(str), "%s(%d)", rpc_prog_name(rp->program), rp->program); - printf("%-15s %2u %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n", + snprintf(str, sizeof(str), "%s(%d)", rpc_prog_name(rp->program), rp->program); + printf("%-15s %2u %6d %3d.%06d %3d.%06d %3" PRIu64 ".%06" PRIu64 "\n", str, rp->version, rp->num, diff --git a/ui/cli/tap-rtp.c b/ui/cli/tap-rtp.c index b449d9de73..b7937cd0d1 100644 --- a/ui/cli/tap-rtp.c +++ b/ui/cli/tap-rtp.c @@ -63,7 +63,7 @@ rtpstreams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo _U_) /* save the current locale */ savelocale = g_strdup(setlocale(LC_NUMERIC, NULL)); /* switch to "C" locale to avoid problems with localized decimal separators - in g_snprintf("%f") functions */ + in snprintf("%f") functions */ setlocale(LC_NUMERIC, "C"); list = the_tapinfo_struct.strinfo_list; diff --git a/ui/cli/tap-simple_stattable.c b/ui/cli/tap-simple_stattable.c index 014d0c908a..74fe904a98 100644 --- a/ui/cli/tap-simple_stattable.c +++ b/ui/cli/tap-simple_stattable.c @@ -61,7 +61,7 @@ simple_draw(void *arg) if (field_data->type == TABLE_ITEM_NONE) /* Nothing for us here */ break; - g_snprintf(fmt_string, sizeof(fmt_string), "%s |", field->field_format); + snprintf(fmt_string, sizeof(fmt_string), "%s |", field->field_format); switch(field->type) { case TABLE_ITEM_UINT: diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c index 31583b5491..8eb192c7d8 100644 --- a/ui/proto_hier_stats.c +++ b/ui/proto_hier_stats.c @@ -261,7 +261,7 @@ ph_stats_new(capture_file *cf) progbar_val = (gfloat) count / cf->count; if (progbar != NULL) { - g_snprintf(status_str, sizeof(status_str), + snprintf(status_str, sizeof(status_str), "%4u of %u frames", count, cf->count); update_progress_dlg(progbar, progbar_val, status_str); } diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index 1a8de81757..ad9f69584b 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -765,7 +765,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser memset(cur, ' ', 4); cur += 4; } - cur += g_snprintf(cur, 20, "%08X ", *global_pos); + cur += snprintf(cur, 20, "%08X ", *global_pos); /* 49 is space consumed by hex chars */ ascii_start = cur + 49 + 2; for (i = 0; i < 16 && current_pos + i < nchars; i++) { @@ -801,7 +801,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser case SHOW_CARRAY: current_pos = 0; - g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = { /* Packet %u */\n", + snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = { /* Packet %u */\n", is_from_server ? 1 : 0, is_from_server ? server_buffer_count_++ : client_buffer_count_++, packet_num); diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index f145f839a6..a1e5b404f8 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -741,7 +741,7 @@ int main(int argc, char *qt_argv[]) } #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "set_console_log_handler, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "set_console_log_handler, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif #ifdef HAVE_LIBPCAP @@ -761,7 +761,7 @@ int main(int argc, char *qt_argv[]) splash_update(RA_DISSECTORS, NULL, NULL); #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling epan init, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling epan init, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the @@ -775,7 +775,7 @@ int main(int argc, char *qt_argv[]) #ifdef DEBUG_STARTUP_TIME /* epan_init resets the preferences */ prefs.gui_console_open = console_open_always; - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "epan done, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "epan done, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif /* Register all audio codecs. */ @@ -794,7 +794,7 @@ int main(int argc, char *qt_argv[]) splash_update(RA_LISTENERS, NULL, NULL); #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Register all tap listeners, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Register all tap listeners, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif /* Register all tap listeners; we do this before we parse the arguments, as the "-z" argument can specify a registered tap. */ @@ -812,13 +812,13 @@ int main(int argc, char *qt_argv[]) } #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling extcap_register_preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling extcap_register_preferences, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif splash_update(RA_EXTCAP, NULL, NULL); extcap_register_preferences(); splash_update(RA_PREFERENCES, NULL, NULL); #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling module preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling module preferences, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif global_commandline_info.prefs_p = ws_app.readConfigurationFiles(false); @@ -840,7 +840,7 @@ int main(int argc, char *qt_argv[]) #ifdef HAVE_LIBPCAP #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling fill_in_local_interfaces, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling fill_in_local_interfaces, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif splash_update(RA_INTERFACES, NULL, NULL); @@ -917,7 +917,7 @@ int main(int argc, char *qt_argv[]) changed either from one of the preferences file or from the command line that their preferences have changed. */ #ifdef DEBUG_STARTUP_TIME - ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling prefs_apply_all, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time); + ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling prefs_apply_all, elapsed time %" PRIu64 " us \n", g_get_monotonic_time() - start_time); #endif prefs_apply_all(); prefs_to_capture_opts(); diff --git a/ui/qt/models/export_objects_model.cpp b/ui/qt/models/export_objects_model.cpp index 5a5ba64c37..ed42725b59 100644 --- a/ui/qt/models/export_objects_model.cpp +++ b/ui/qt/models/export_objects_model.cpp @@ -182,7 +182,7 @@ void ExportObjectModel::saveAllEntries(QString path) char generic_name[EXPORT_OBJECT_MAXFILELEN+1]; const char *ext; ext = eo_ct2ext(entry->content_type); - g_snprintf(generic_name, sizeof(generic_name), + snprintf(generic_name, sizeof(generic_name), "object%u%s%s", entry->pkt_num, ext ? "." : "", ext ? ext : ""); safe_filename = eo_massage_str(generic_name, diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp index ea4de028f0..e2e5003e84 100644 --- a/ui/qt/sctp_chunk_statistics_dialog.cpp +++ b/ui/qt/sctp_chunk_statistics_dialog.cpp @@ -67,7 +67,7 @@ void SCTPChunkStatisticsDialog::initializeChunkMap() for (int i = 0; i < 256; i++) { temp.id = i; temp.row = i; - g_snprintf(buf, sizeof buf, "%d", i); + snprintf(buf, sizeof buf, "%d", i); (void) g_strlcpy(temp.name, val_to_str_const(i, chunk_type_values, "NA"), sizeof temp.name); if (strcmp(temp.name, "NA") == 0) { temp.hide = 1; @@ -248,7 +248,7 @@ void SCTPChunkStatisticsDialog::on_pushButton_clicked() for (int i = 0; i < chunks.size(); i++) { tempChunk = chunks.value(i); - g_snprintf(str, sizeof str, "\"%d\",\"%s\",\"%s\"\n", tempChunk.id, tempChunk.name, tempChunk.hide==0?"Show":"Hide"); + snprintf(str, sizeof str, "\"%d\",\"%s\",\"%s\"\n", tempChunk.id, tempChunk.name, tempChunk.hide==0?"Show":"Hide"); fputs(str, fp); void *rec = g_malloc0(uat->record_size); uat_add_record(uat, rec, TRUE); diff --git a/ui/qt/show_packet_bytes_dialog.cpp b/ui/qt/show_packet_bytes_dialog.cpp index 250c575858..8285802677 100644 --- a/ui/qt/show_packet_bytes_dialog.cpp +++ b/ui/qt/show_packet_bytes_dialog.cpp @@ -684,7 +684,7 @@ void ShowPacketBytesDialog::updatePacketBytes(void) int i; // Dump offset - cur += g_snprintf(cur, 20, "%0*X ", offset_chars, pos); + cur += snprintf(cur, 20, "%0*X ", offset_chars, pos); // Dump bytes as hex for (i = 0; i < 16 && pos + i < len; i++) { diff --git a/ui/summary.c b/ui/summary.c index fe0174ba9c..fedaefea86 100644 --- a/ui/summary.c +++ b/ui/summary.c @@ -99,7 +99,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) { int i; for (i = 0; i < (int) length; i++) { - g_snprintf(str+(i*2), 3, "%02x", hash[i]); + snprintf(str+(i*2), 3, "%02x", hash[i]); } } diff --git a/ui/traffic_table_ui.c b/ui/traffic_table_ui.c index 6a003b07fb..10a76d87af 100644 --- a/ui/traffic_table_ui.c +++ b/ui/traffic_table_ui.c @@ -194,9 +194,9 @@ write_endpoint_geoip_map(FILE *fp, gboolean json_only, hostlist_talker_t *const json_dumper_value_anyf(&dumper, "%u", result->accuracy); } json_dumper_set_member_name(&dumper, "packets"); - json_dumper_value_anyf(&dumper, "%" G_GUINT64_FORMAT, host->rx_frames + host->tx_frames); + json_dumper_value_anyf(&dumper, "%" PRIu64, host->rx_frames + host->tx_frames); json_dumper_set_member_name(&dumper, "bytes"); - json_dumper_value_anyf(&dumper, "%" G_GUINT64_FORMAT, host->rx_bytes + host->tx_bytes); + json_dumper_value_anyf(&dumper, "%" PRIu64, host->rx_bytes + host->tx_bytes); } json_dumper_end_object(&dumper); // end properties diff --git a/wiretap/ascend_parser.lemon b/wiretap/ascend_parser.lemon index c6504b3800..08c77fea1a 100644 --- a/wiretap/ascend_parser.lemon +++ b/wiretap/ascend_parser.lemon @@ -490,7 +490,7 @@ run_ascend_parser(guint8 *pd, ascend_state_t *parser_state, int *err, gchar **er do { token_id = ascend_lex(scanner); - ascend_debug("Got token %d at %" G_GINT64_MODIFIER "d", token_id, file_tell(parser_state->fh)); + ascend_debug("Got token %d at %" PRId64, token_id, file_tell(parser_state->fh)); AscendParser(parser, token_id, parser_state->token, parser_state); } while (token_id && !parser_state->err && !parser_state->ascend_parse_error && parser_state->caplen < ASCEND_MAX_PKT_LEN); diff --git a/wiretap/blf.c b/wiretap/blf.c index 497fdcd6da..c7c054bc6c 100644 --- a/wiretap/blf.c +++ b/wiretap/blf.c @@ -1708,7 +1708,7 @@ static gboolean blf_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar blf_tmp.blf_data = (blf_t *)wth->priv; if (!blf_read_block(&blf_tmp, blf_tmp.blf_data->current_real_seek_pos, err, err_info)) { - ws_debug("data_offset is %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("data_offset is %" PRId64, *data_offset); return FALSE; } *data_offset = blf_tmp.blf_data->start_of_last_obj; diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index a3135c9a4c..bd4af92ac2 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -277,7 +277,7 @@ catapult_dct2000_open(wtap *wth, int *err, gchar **err_info) return WTAP_OPEN_MINE; } -/* Ugly, but much faster than using g_snprintf! */ +/* Ugly, but much faster than using snprintf! */ static void write_timestamp_string(char *timestamp_string, int secs, int tenthousandths) { int idx = 0; @@ -317,7 +317,7 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou timestamp_string[idx++] = ((secs % 10)) + '0'; } else { - g_snprintf(timestamp_string, MAX_TIMESTAMP_LEN, "%d.%04d", secs, tenthousandths); + snprintf(timestamp_string, MAX_TIMESTAMP_LEN, "%d.%04d", secs, tenthousandths); return; } @@ -505,7 +505,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, /* If get here, must have failed */ *err = errno; *err_info = g_strdup_printf("catapult dct2000: seek_read failed to read/parse " - "line at position %" G_GINT64_MODIFIER "d", + "line at position %" PRId64, seek_off); return FALSE; } diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index 8570cb2305..aa8fd7a6cd 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -174,7 +174,7 @@ daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, rec->block = wtap_block_create(WTAP_BLOCK_PACKET); rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s", + if (sscanf(readLine, "%*s %18" PRIu64 ".%9d %9u %" READDATA_MAX_FIELD_SIZE "s", &seconds, &useconds, &rec->rec_header.packet_header.len, readData) != 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("daintree_sna: invalid read record"); diff --git a/wiretap/erf.c b/wiretap/erf.c index 21dfbb0ae1..a9903b45e2 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -2169,11 +2169,11 @@ static void erf_set_interface_descr(wtap_block_t block, guint option_id, guint64 } if (host_id > 0) { - g_snprintf(hostid_buf, sizeof(hostid_buf), " Host %012" G_GINT64_MODIFIER "x,", host_id); + snprintf(hostid_buf, sizeof(hostid_buf), " Host %012" PRIx64 ",", host_id); } if (source_id > 0) { - g_snprintf(sourceid_buf, sizeof(sourceid_buf), " Source %u,", source_id); + snprintf(sourceid_buf, sizeof(sourceid_buf), " Source %u,", source_id); } if (descr) { @@ -2336,7 +2336,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli /* XXX: this is a pointer! */ int_data = g_array_index(wth->interface_data, wtap_block_t, if_info->if_index); - g_snprintf(portstr_buf, sizeof(portstr_buf), "Port %c", 'A'+i); + snprintf(portstr_buf, sizeof(portstr_buf), "Port %c", 'A'+i); oldstr = if_info->name; if_info->name = g_strconcat(oldstr ? oldstr : portstr_buf, " [unmatched implicit]", NULL); diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index 15d8b1ad26..32e4ffec2e 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -291,7 +291,7 @@ ipfix_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - ws_debug("offset is initially %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("offset is initially %" PRId64, *data_offset); if (!ipfix_read_message(wth->fh, rec, buf, err, err_info)) { ws_debug("couldn't read message header with code: %d\n, and error '%s'", @@ -315,7 +315,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, return FALSE; /* Seek error */ } - ws_debug("reading at offset %" G_GINT64_MODIFIER "u", seek_off); + ws_debug("reading at offset %" PRIu64, seek_off); if (!ipfix_read_message(wth->random_fh, rec, buf, err, err_info)) { ws_debug("couldn't read message header"); diff --git a/wiretap/iseries.c b/wiretap/iseries.c index be1469a773..eb43142802 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -747,7 +747,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec, * the error message, to avoid an overflow.) */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("iseries: File has %" G_GUINT64_FORMAT "-byte packet, bigger than maximum of %u", + *err_info = g_strdup_printf("iseries: File has %" PRIu64 "-byte packet, bigger than maximum of %u", (guint64)pkt_len + 14, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; diff --git a/wiretap/k12.c b/wiretap/k12.c index a667a98096..e5e145cd5a 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -90,7 +90,7 @@ void k12_hex_ascii_dump(guint level, gint64 offset, const char* label, const uns if (debug_level < level) return; - fprintf(dbg_out,"%s(%.8" G_GINT64_MODIFIER "x,%.4x):\n",label,offset,len); + fprintf(dbg_out,"%s(%.8" PRIx64 ",%.4x):\n",label,offset,len); for (i=0 ; i left) { /* diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 109ee1f389..0bf009161c 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -527,24 +527,24 @@ k12text_dump(wtap_dumper *wdh, const wtap_rec *rec, tmp = gmtime(&rec->ts.secs); if (tmp == NULL) - g_snprintf(p, 90, "+---------+---------------+----------+\r\nXX:XX:XX,"); + snprintf(p, 90, "+---------+---------------+----------+\r\nXX:XX:XX,"); else strftime(p, 90, "+---------+---------------+----------+\r\n%H:%M:%S,", tmp); wl = strlen(p); p += wl; left -= wl; - wl = g_snprintf(p, (gulong)left, "%.3d,%.3d %s\r\n|0 |", ms, ns, str_enc); + wl = snprintf(p, (gulong)left, "%.3d,%.3d %s\r\n|0 |", ms, ns, str_enc); p += wl; left -= wl; for(i = 0; i < rec->rec_header.packet_header.caplen && left > 2; i++) { - wl = g_snprintf(p, (gulong)left, "%.2x|", pd[i]); + wl = snprintf(p, (gulong)left, "%.2x|", pd[i]); p += wl; left -= wl; } - wl = g_snprintf(p, (gulong)left, "\r\n\r\n"); + wl = snprintf(p, (gulong)left, "\r\n\r\n"); left -= wl; ret = wtap_dump_file_write(wdh, buf, K12BUF_SIZE - left, err); diff --git a/wiretap/log3gpp.c b/wiretap/log3gpp.c index 96afbb6887..6b3d4a5321 100644 --- a/wiretap/log3gpp.c +++ b/wiretap/log3gpp.c @@ -281,7 +281,7 @@ gboolean log3gpp_read(wtap* wth, wtap_rec* rec, Buffer* buf, char timestamp_string[MAX_TIMESTAMP_LEN+1]; /*not used gint64 *pkey = NULL;*/ - g_snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100); + snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100); /* All packets go to 3GPP protocol stub dissector */ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP; @@ -407,7 +407,7 @@ log3gpp_seek_read(wtap *wth, gint64 seek_off, int n; int stub_offset = 0; char timestamp_string[32]; - g_snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100); + snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100); /* Make sure all packets go to log3gpp dissector */ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP; @@ -460,7 +460,7 @@ log3gpp_seek_read(wtap *wth, gint64 seek_off, /* If get here, must have failed */ *err = errno; *err_info = g_strdup_printf("prot 3gpp: seek_read failed to read/parse " - "line at position %" G_GINT64_MODIFIER "d", + "line at position %" PRId64, seek_off); return FALSE; } diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index de872cdb8b..084413b826 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -382,7 +382,7 @@ parse_netscreen_packet(FILE_T fh, wtap_rec *rec, Buffer* buf, * address in the header. If they are, assume ethernet * LinkLayer or else PPP */ - g_snprintf(dststr, 13, "%02x%02x%02x%02x%02x%02x", + snprintf(dststr, 13, "%02x%02x%02x%02x%02x%02x", pd[0], pd[1], pd[2], pd[3], pd[4], pd[5]); if (strncmp(dststr, cap_dst, 12) == 0) rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET; diff --git a/wiretap/observer.c b/wiretap/observer.c index 933df9223d..2817fedd4f 100644 --- a/wiretap/observer.c +++ b/wiretap/observer.c @@ -730,9 +730,9 @@ static gboolean observer_dump_open(wtap_dumper *wdh, int *err, current_time = localtime(&system_time); memset(&comment, 0x00, sizeof(comment)); if (current_time != NULL) - g_snprintf(comment, 64, "This capture was saved from Wireshark on %s", asctime(current_time)); + snprintf(comment, 64, "This capture was saved from Wireshark on %s", asctime(current_time)); else - g_snprintf(comment, 64, "This capture was saved from Wireshark"); + snprintf(comment, 64, "This capture was saved from Wireshark"); comment_length = strlen(comment); comment_header.type = INFORMATION_TYPE_COMMENT; diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 9a0aa99806..5009423715 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -756,7 +756,7 @@ pcapng_process_nflx_custom_option(wtapng_block_t *wblock, memcpy(&dumpinfo, value, sizeof(struct nflx_dumpinfo)); section_info->bblog_offset_tv_sec = GUINT64_FROM_LE(dumpinfo.tlh_offset_tv_sec); section_info->bblog_offset_tv_usec = GUINT64_FROM_LE(dumpinfo.tlh_offset_tv_usec); - ws_debug("BBLog dumpinfo time offset: %" G_GUINT64_FORMAT, section_info->bblog_offset_tv_sec); + ws_debug("BBLog dumpinfo time offset: %" PRIu64, section_info->bblog_offset_tv_sec); } else { ws_debug("BBLog dumpinfo parameter has strange length: %u", length); } @@ -765,7 +765,7 @@ pcapng_process_nflx_custom_option(wtapng_block_t *wblock, if (length == sizeof(gint64)) { memcpy(&dumptime, value, sizeof(gint64)); dumptime = GINT64_FROM_LE(dumptime); - ws_debug("BBLog dumpinfo time offset: %" G_GUINT64_FORMAT, dumptime); + ws_debug("BBLog dumpinfo time offset: %" PRIu64, dumptime); } else { ws_debug("BBLog dumptime parameter has strange length: %u", length); } @@ -3575,7 +3575,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, /* read next block */ while (1) { *data_offset = file_tell(wth->fh); - ws_debug("data_offset is %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("data_offset is %" PRId64, *data_offset); /* * Get the section_info_t for the current section. @@ -3588,7 +3588,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, */ if (!pcapng_read_block(wth, wth->fh, pcapng, current_section, &new_section, &wblock, err, err_info)) { - ws_debug("data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("data_offset is finally %" PRId64, *data_offset); ws_debug("couldn't read packet block"); wtap_block_unref(wblock.block); return FALSE; @@ -3707,7 +3707,7 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, } /*ws_debug("Read length: %u Packet length: %u", bytes_read, rec->rec_header.packet_header.caplen);*/ - ws_debug("data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); + ws_debug("data_offset is finally %" PRId64, *data_offset); return TRUE; } diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index 24f35a2862..a22992af78 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -77,7 +77,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("stanag4607: File has %" G_GUINT32_FORMAT "d-byte packet, " + *err_info = g_strdup_printf("stanag4607: File has %" PRIu32 "d-byte packet, " "bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } @@ -87,7 +87,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, * infinitely if the size is zero. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("stanag4607: File has %" G_GUINT32_FORMAT "d-byte packet, " + *err_info = g_strdup_printf("stanag4607: File has %" PRIu32 "d-byte packet, " "smaller than minimum of %u", packet_size, PKT_HDR_SIZE+SEG_HDR_SIZE); return FALSE; } diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 5d40b9c1ce..1547b5dfaf 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -353,7 +353,7 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr, if (wtap_block_get_uint64_option_value(if_descr, OPT_IDB_SPEED, &tmp64) == WTAP_OPTTYPE_SUCCESS) { g_string_append_printf(info, - "%*cSpeed = %" G_GINT64_MODIFIER "u%s", indent, ' ', + "%*cSpeed = %" PRIu64 "%s", indent, ' ', tmp64, line_end); } @@ -377,7 +377,7 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr, line_end); g_string_append_printf(info, - "%*cTime ticks per second = %" G_GINT64_MODIFIER "u%s", indent, ' ', + "%*cTime ticks per second = %" PRIu64 "%s", indent, ' ', if_descr_mand->time_units_per_second, line_end); @@ -1384,7 +1384,7 @@ wtap_strerror(int err) if (err < 0) { wtap_errlist_index = -1 - err; if (wtap_errlist_index >= WTAP_ERRLIST_SIZE) { - g_snprintf(errbuf, 128, "Error %d", err); + snprintf(errbuf, 128, "Error %d", err); return errbuf; } if (wtap_errlist[wtap_errlist_index] == NULL) @@ -1759,7 +1759,7 @@ wtap_full_file_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int * * Avoid allocating space for an immensely-large file. */ *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("%s: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u", + *err_info = g_strdup_printf("%s: File has %" PRId64 "-byte packet, bigger than maximum of %u", wtap_encap_name(wth->file_encap), file_size, G_MAXINT); return FALSE; } diff --git a/wsutil/wmem/wmem_interval_tree.c b/wsutil/wmem/wmem_interval_tree.c index 805e70afe7..b93f94401c 100644 --- a/wsutil/wmem/wmem_interval_tree.c +++ b/wsutil/wmem/wmem_interval_tree.c @@ -12,7 +12,9 @@ #include "config.h" +#include #include +#include #include #include