aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2017-02-22 01:12:16 +0100
committerMichael Mann <mmann78@netscape.net>2017-02-24 02:14:44 +0000
commiteef155561037790e58b9e39cfd9d0cd5b7690349 (patch)
tree3f906da09a08c8f93a749338f6688ffb1741b435 /sharkd_session.c
parent99929f727477cd5ddf74d991fa3fa52cba9c6b7d (diff)
Fix sharkd compilation on some <glibc-2.16 or <gcc-4.8
- use printf() instead of fwrite(). - don't shadow stat() Bug: 13424 Change-Id: Idc8931bcc5b1387f0ce3a3bfa146ffeb5b4edc82 Reviewed-on: https://code.wireshark.org/review/20234 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: John Thacker <johnthacker@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'sharkd_session.c')
-rw-r--r--sharkd_session.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index d58c15e07f..8113a2dfa2 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -162,7 +162,7 @@ json_print_base64(const guint8 *data, int len)
int base64_state1 = 0;
int base64_state2 = 0;
gsize wrote;
- gchar buf[(1 / 3 + 1) * 4 + 4];
+ gchar buf[(1 / 3 + 1) * 4 + 4 + 1];
putchar('"');
@@ -170,12 +170,18 @@ json_print_base64(const guint8 *data, int len)
{
wrote = g_base64_encode_step(&data[i], 1, FALSE, buf, &base64_state1, &base64_state2);
if (wrote > 0)
- fwrite(buf, 1, wrote, stdout);
+ {
+ buf[wrote] = '\0';
+ printf("%s", buf);
+ }
}
wrote = g_base64_encode_close(FALSE, buf, &base64_state1, &base64_state2);
if (wrote > 0)
- fwrite(buf, 1, wrote, stdout);
+ {
+ buf[wrote] = '\0';
+ printf("%s", buf);
+ }
putchar('"');
}
@@ -1326,7 +1332,7 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
{
unsigned int frames;
guint64 bytes;
- } stat, stat_total;
+ } st, st_total;
nstime_t *start_ts = NULL;
@@ -1351,11 +1357,11 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
return;
}
- stat_total.frames = 0;
- stat_total.bytes = 0;
+ st_total.frames = 0;
+ st_total.bytes = 0;
- stat.frames = 0;
- stat.bytes = 0;
+ st.frames = 0;
+ st.bytes = 0;
idx = 0;
@@ -1378,9 +1384,9 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
if (idx != new_idx)
{
- if (stat.frames != 0)
+ if (st.frames != 0)
{
- printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
+ printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, st.frames, st.bytes);
sepa = ",";
}
@@ -1388,24 +1394,24 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
if (idx > max_idx)
max_idx = idx;
- stat.frames = 0;
- stat.bytes = 0;
+ st.frames = 0;
+ st.bytes = 0;
}
- stat.frames += 1;
- stat.bytes += fdata->pkt_len;
+ st.frames += 1;
+ st.bytes += fdata->pkt_len;
- stat_total.frames += 1;
- stat_total.bytes += fdata->pkt_len;
+ st_total.frames += 1;
+ st_total.bytes += fdata->pkt_len;
}
- if (stat.frames != 0)
+ if (st.frames != 0)
{
- printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
+ printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, st.frames, st.bytes);
/* sepa = ","; */
}
- printf("],\"last\":%" G_GINT64_FORMAT ",\"frames\":%u,\"bytes\":%" G_GUINT64_FORMAT "}\n", max_idx, stat_total.frames, stat_total.bytes);
+ printf("],\"last\":%" G_GINT64_FORMAT ",\"frames\":%u,\"bytes\":%" G_GUINT64_FORMAT "}\n", max_idx, st_total.frames, st_total.bytes);
}
/**