forked from osmocom/wireshark
parent
f0eeb0bdf1
commit
c2ae798ae2
|
@ -361,15 +361,14 @@ usb_addr_to_str_buf(const guint8 *addrp, gchar *buf, int buf_len)
|
|||
*/
|
||||
static void
|
||||
time_secs_to_str_buf(gint32 time, guint32 frac, gboolean is_nsecs,
|
||||
gchar *buf, int buf_len)
|
||||
emem_strbuf_t *buf)
|
||||
{
|
||||
static gchar *p;
|
||||
int hours, mins, secs;
|
||||
const gchar *msign = "";
|
||||
gboolean do_comma = FALSE;
|
||||
|
||||
if(time == G_MININT32) { /* That Which Shall Not Be Negated */
|
||||
g_snprintf(buf, buf_len, "Unable to cope with time value %d", time);
|
||||
ep_strbuf_append_printf(buf, "Unable to cope with time value %d", time);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -385,61 +384,59 @@ time_secs_to_str_buf(gint32 time, guint32 frac, gboolean is_nsecs,
|
|||
hours = time % 24;
|
||||
time /= 24;
|
||||
|
||||
/* This would probably be cleaner if we used GStrings instead. */
|
||||
p = buf;
|
||||
if (time != 0) {
|
||||
p += g_snprintf(p, buf_len, "%s%u day%s", msign, time, PLURALIZE(time));
|
||||
ep_strbuf_append_printf(buf, "%s%u day%s", msign, time, PLURALIZE(time));
|
||||
do_comma = TRUE;
|
||||
msign="";
|
||||
}
|
||||
if (hours != 0) {
|
||||
p += g_snprintf(p, buf_len-(p-buf), "%s%s%u hour%s", COMMA(do_comma), msign, hours, PLURALIZE(hours));
|
||||
ep_strbuf_append_printf(buf, "%s%s%u hour%s", COMMA(do_comma), msign, hours, PLURALIZE(hours));
|
||||
do_comma = TRUE;
|
||||
msign="";
|
||||
}
|
||||
if (mins != 0) {
|
||||
p += g_snprintf(p, buf_len-(p-buf), "%s%s%u minute%s", COMMA(do_comma), msign, mins, PLURALIZE(mins));
|
||||
ep_strbuf_append_printf(buf, "%s%s%u minute%s", COMMA(do_comma), msign, mins, PLURALIZE(mins));
|
||||
do_comma = TRUE;
|
||||
msign="";
|
||||
}
|
||||
if (secs != 0 || frac != 0) {
|
||||
if (frac != 0) {
|
||||
if (is_nsecs)
|
||||
p += g_snprintf(p, buf_len-(p-buf), "%s%s%u.%09u seconds", COMMA(do_comma), msign, secs, frac);
|
||||
ep_strbuf_append_printf(buf, "%s%s%u.%09u seconds", COMMA(do_comma), msign, secs, frac);
|
||||
else
|
||||
p += g_snprintf(p, buf_len-(p-buf), "%s%s%u.%03u seconds", COMMA(do_comma), msign, secs, frac);
|
||||
ep_strbuf_append_printf(buf, "%s%s%u.%03u seconds", COMMA(do_comma), msign, secs, frac);
|
||||
} else
|
||||
p += g_snprintf(p, buf_len-(p-buf), "%s%s%u second%s", COMMA(do_comma), msign, secs, PLURALIZE(secs));
|
||||
ep_strbuf_append_printf(buf, "%s%s%u second%s", COMMA(do_comma), msign, secs, PLURALIZE(secs));
|
||||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
time_secs_to_str(gint32 time)
|
||||
{
|
||||
gchar *buf;
|
||||
emem_strbuf_t *buf;
|
||||
|
||||
buf=ep_alloc(TIME_SECS_LEN+1);
|
||||
buf=ep_strbuf_sized_new(TIME_SECS_LEN+1, TIME_SECS_LEN+1);
|
||||
|
||||
if (time == 0) {
|
||||
g_snprintf(buf, TIME_SECS_LEN+1, "0 time");
|
||||
return buf;
|
||||
ep_strbuf_append(buf, "0 time");
|
||||
return buf->str;
|
||||
}
|
||||
|
||||
time_secs_to_str_buf(time, 0, FALSE, buf, TIME_SECS_LEN+1);
|
||||
return buf;
|
||||
time_secs_to_str_buf(time, 0, FALSE, buf);
|
||||
return buf->str;
|
||||
}
|
||||
|
||||
gchar *
|
||||
time_msecs_to_str(gint32 time)
|
||||
{
|
||||
gchar *buf;
|
||||
emem_strbuf_t *buf;
|
||||
int msecs;
|
||||
|
||||
buf=ep_alloc(TIME_SECS_LEN+1+3+1);
|
||||
buf=ep_strbuf_sized_new(TIME_SECS_LEN+1+3+1, TIME_SECS_LEN+1+3+1);
|
||||
|
||||
if (time == 0) {
|
||||
g_snprintf(buf, TIME_SECS_LEN+1+3+1, "0 time");
|
||||
return buf;
|
||||
ep_strbuf_append(buf, "0 time");
|
||||
return buf->str;
|
||||
}
|
||||
|
||||
if(time<0){
|
||||
|
@ -453,8 +450,8 @@ time_msecs_to_str(gint32 time)
|
|||
time /= 1000;
|
||||
}
|
||||
|
||||
time_secs_to_str_buf(time, msecs, FALSE, buf, TIME_SECS_LEN+1+3+1);
|
||||
return buf;
|
||||
time_secs_to_str_buf(time, msecs, FALSE, buf);
|
||||
return buf->str;
|
||||
}
|
||||
|
||||
static const char *mon_names[12] = {
|
||||
|
@ -628,14 +625,13 @@ display_epoch_time(gchar *buf, int buflen, time_t sec, gint32 frac,
|
|||
gchar *
|
||||
rel_time_to_str(nstime_t *rel_time)
|
||||
{
|
||||
gchar *buf;
|
||||
emem_strbuf_t *buf;
|
||||
char *p;
|
||||
const char *sign;
|
||||
gint32 time;
|
||||
gint32 nsec;
|
||||
|
||||
buf=ep_alloc(1+TIME_SECS_LEN+1+6+1);
|
||||
p = buf;
|
||||
buf=ep_strbuf_sized_new(1+TIME_SECS_LEN+1+6+1, 1+TIME_SECS_LEN+1+6+1);
|
||||
|
||||
/* If the nanoseconds part of the time stamp is negative,
|
||||
print its absolute value and, if the seconds part isn't
|
||||
|
@ -645,8 +641,8 @@ rel_time_to_str(nstime_t *rel_time)
|
|||
time = (gint) rel_time->secs;
|
||||
nsec = rel_time->nsecs;
|
||||
if (time == 0 && nsec == 0) {
|
||||
g_snprintf(buf, 1+TIME_SECS_LEN+1+6+1, "0.000000000 seconds");
|
||||
return buf;
|
||||
ep_strbuf_append(buf, "0.000000000 seconds");
|
||||
return buf->str;
|
||||
}
|
||||
if (nsec < 0) {
|
||||
nsec = -nsec;
|
||||
|
@ -660,8 +656,8 @@ rel_time_to_str(nstime_t *rel_time)
|
|||
time = (gint) -rel_time->secs;
|
||||
}
|
||||
|
||||
time_secs_to_str_buf(time, nsec, TRUE, p, 1+TIME_SECS_LEN+1+6+1);
|
||||
return buf;
|
||||
time_secs_to_str_buf(time, nsec, TRUE, buf);
|
||||
return buf->str;
|
||||
}
|
||||
|
||||
#define REL_TIME_SECS_LEN (1+10+1+9+1)
|
||||
|
@ -828,7 +824,7 @@ decode_numeric_bitfield(guint32 val, guint32 mask, int width,
|
|||
shift++;
|
||||
|
||||
p = decode_bitfield_value(buf, val, mask, width);
|
||||
g_snprintf(p, 1025-(p-buf), fmt, (val & mask) >> shift);
|
||||
g_snprintf(p, (gulong) (1025-(p-buf)), fmt, (val & mask) >> shift);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ tvbparse_wanted_t* tvbparse_string(int id,
|
|||
w->condition = cond_string;
|
||||
w->id = id;
|
||||
w->control.str = str;
|
||||
w->len = strlen(str);
|
||||
w->len = (int) strlen(str);
|
||||
w->data = data;
|
||||
w->before = before_cb;
|
||||
w->after = after_cb;
|
||||
|
@ -423,7 +423,7 @@ tvbparse_wanted_t* tvbparse_casestring(int id,
|
|||
w->condition = cond_casestring;
|
||||
w->id = id;
|
||||
w->control.str = str;
|
||||
w->len = strlen(str);
|
||||
w->len = (int) strlen(str);
|
||||
w->data = data;
|
||||
w->before = before_cb;
|
||||
w->after = after_cb;
|
||||
|
|
12
epan/uat.c
12
epan/uat.c
|
@ -92,7 +92,7 @@ uat_t* uat_new(const char* name,
|
|||
uat->update_cb = update_cb;
|
||||
uat->free_cb = free_cb;
|
||||
uat->fields = flds_array;
|
||||
uat->user_data = g_array_new(FALSE,FALSE,uat->record_size);
|
||||
uat->user_data = g_array_new(FALSE,FALSE,(guint)uat->record_size);
|
||||
uat->changed = FALSE;
|
||||
uat->loaded = FALSE;
|
||||
uat->rep = NULL;
|
||||
|
@ -126,7 +126,7 @@ void* uat_add_record(uat_t* uat, const void* data) {
|
|||
rec = uat->user_data->data + (uat->record_size * (uat->user_data->len-1));
|
||||
|
||||
if (uat->copy_cb) {
|
||||
uat->copy_cb(rec, data, uat->record_size);
|
||||
uat->copy_cb(rec, data, (unsigned int) uat->record_size);
|
||||
}
|
||||
|
||||
UAT_UPDATE(uat);
|
||||
|
@ -135,7 +135,7 @@ void* uat_add_record(uat_t* uat, const void* data) {
|
|||
}
|
||||
|
||||
void uat_swap(uat_t* uat, guint a, guint b) {
|
||||
guint s = uat->record_size;
|
||||
size_t s = uat->record_size;
|
||||
void* tmp = ep_alloc(s);
|
||||
|
||||
g_assert( a < uat->user_data->len && b < uat->user_data->len );
|
||||
|
@ -326,14 +326,14 @@ void uat_clear(uat_t* uat) {
|
|||
}
|
||||
|
||||
void* uat_dup(uat_t* uat, guint* len_p) {
|
||||
guint size = (uat->record_size * uat->user_data->len);
|
||||
guint size = (guint) (uat->record_size * uat->user_data->len);
|
||||
*len_p = size;
|
||||
return size ? g_memdup(uat->user_data->data,size) : NULL ;
|
||||
}
|
||||
|
||||
void* uat_se_dup(uat_t* uat, guint* len_p) {
|
||||
guint size = (uat->record_size * uat->user_data->len);
|
||||
*len_p = size;
|
||||
guint size = (guint) (uat->record_size * uat->user_data->len);
|
||||
*len_p = (guint) size;
|
||||
return size ? se_memdup(uat->user_data->data,size) : NULL ;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ decode_enumerated_bitfield(guint32 val, guint32 mask, int width,
|
|||
char *p;
|
||||
|
||||
p = decode_bitfield_value(buf, val, mask, width);
|
||||
g_snprintf(p, 1024-(p-buf), fmt, val_to_str(val & mask, tab, "Unknown"));
|
||||
g_snprintf(p, (gulong) (1024-(p-buf)), fmt, val_to_str(val & mask, tab, "Unknown"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ decode_enumerated_bitfield_shifted(guint32 val, guint32 mask, int width,
|
|||
shift++;
|
||||
|
||||
p = decode_bitfield_value(buf, val, mask, width);
|
||||
g_snprintf(p, 1024-(p-buf), fmt, val_to_str((val & mask) >> shift, tab, "Unknown"));
|
||||
g_snprintf(p, (gulong) (1024-(p-buf)), fmt, val_to_str((val & mask) >> shift, tab, "Unknown"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue