diff options
author | João Valverde <j@v6e.pt> | 2021-12-17 20:05:19 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2021-12-19 20:06:13 +0000 |
commit | fe5248717faa1c99a4d0c761fa8da63afffc5d3f (patch) | |
tree | 80dfeee421091a44c88f80b7a65edc0590e4b4e5 /wiretap | |
parent | c5a19582e4e18605e8528cd999221444f7ece318 (diff) |
Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ascend_parser.lemon | 2 | ||||
-rw-r--r-- | wiretap/blf.c | 2 | ||||
-rw-r--r-- | wiretap/catapult_dct2000.c | 6 | ||||
-rw-r--r-- | wiretap/daintree-sna.c | 2 | ||||
-rw-r--r-- | wiretap/erf.c | 6 | ||||
-rw-r--r-- | wiretap/ipfix.c | 4 | ||||
-rw-r--r-- | wiretap/iseries.c | 2 | ||||
-rw-r--r-- | wiretap/k12.c | 6 | ||||
-rw-r--r-- | wiretap/k12text.l | 8 | ||||
-rw-r--r-- | wiretap/log3gpp.c | 6 | ||||
-rw-r--r-- | wiretap/netscreen.c | 2 | ||||
-rw-r--r-- | wiretap/observer.c | 4 | ||||
-rw-r--r-- | wiretap/pcapng.c | 10 | ||||
-rw-r--r-- | wiretap/stanag4607.c | 4 | ||||
-rw-r--r-- | wiretap/wtap.c | 8 |
15 files changed, 36 insertions, 36 deletions
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<len ; i += 16) { for (j=0; j<16; j++) { @@ -431,7 +431,7 @@ static gint get_record(k12_t *file_data, FILE_T fh, gint64 file_offset, */ guint junky_offset = 8192 - (gint) ( (file_offset - K12_FILE_HDR_LEN) % 8192 ); - K12_DBG(6,("get_record: ENTER: junky_offset=%" G_GINT64_MODIFIER "d, file_offset=%" G_GINT64_MODIFIER "d",junky_offset,file_offset)); + K12_DBG(6,("get_record: ENTER: junky_offset=%" PRId64 ", file_offset=%" PRId64,junky_offset,file_offset)); /* no buffer is given, lets create it */ if (buffer == NULL) { @@ -513,7 +513,7 @@ static gint get_record(k12_t *file_data, FILE_T fh, gint64 file_offset, /* Read the rest of the record. */ do { - K12_DBG(6,("get_record: looping left=%d junky_offset=%" G_GINT64_MODIFIER "d",left,junky_offset)); + K12_DBG(6,("get_record: looping left=%d junky_offset=%" PRId64,left,junky_offset)); if (junky_offset > 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; } |