aboutsummaryrefslogtreecommitdiffstats
path: root/ui/cli
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-12-17 20:05:19 +0000
committerJoão Valverde <j@v6e.pt>2021-12-19 20:06:13 +0000
commitfe5248717faa1c99a4d0c761fa8da63afffc5d3f (patch)
tree80dfeee421091a44c88f80b7a65edc0590e4b4e5 /ui/cli
parentc5a19582e4e18605e8528cd999221444f7ece318 (diff)
Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
Diffstat (limited to 'ui/cli')
-rw-r--r--ui/cli/tap-endpoints.c12
-rw-r--r--ui/cli/tap-exportobject.c2
-rw-r--r--ui/cli/tap-follow.c2
-rw-r--r--ui/cli/tap-iostat.c26
-rw-r--r--ui/cli/tap-iousers.c12
-rw-r--r--ui/cli/tap-protohierstat.c8
-rw-r--r--ui/cli/tap-rpcprogs.c4
-rw-r--r--ui/cli/tap-rtp.c2
-rw-r--r--ui/cli/tap-simple_stattable.c2
9 files changed, 35 insertions, 35 deletions
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<indentation; i++) {
if (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: