-/*
+/*
*------------------------------------------------------------------
* Copyright (c) 2005-2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
-#include <sys/fcntl.h>
#include <sys/mman.h>
#include <arpa/inet.h>
#include <stdio.h>
g_little_endian = FALSE;
askstr = getprop("dont_ask_ticks_per_ns_initially");
-
+
if (askstr && (*askstr == 't' || *askstr == 'T')) {
tmp = atol(getprop_default("ticks_per_ns", 0));
if (tmp > 0) {
/*
* Squirrel away original (sorted) vector, so we can
* toggle between "chase" mode, snapshots, and the original
- * display method on short notice
+ * display method on short notice
*/
g_original_pids = g_malloc0(sizeof(pid_sort_t)*g_npids);
- memcpy (g_original_pids, g_pids, sizeof(pid_sort_t)*g_npids);
+ memcpy (g_original_pids, g_pids, sizeof(pid_sort_t)*g_npids);
}
/****************************************************************************
ulp = (ulong *)mapfile(filename, &size);
if (ulp == NULL) {
- sprintf(tmpbuf, "Couldn't open %s\n", filename);
+ snprintf(tmpbuf, sizeof(tmpbuf), "Couldn't open %s\n", filename);
infobox("Read Event Log Failure", tmpbuf);
return;
}
g_nevents = ntohl(*ulp);
if (size != (g_nevents*sizeof(raw_event_t) + sizeof(g_nevents))) {
- sprintf(tmpbuf, "%s was damaged, or isn't an event log.\n", filename);
+ snprintf(tmpbuf, sizeof(tmpbuf),
+ "%s was damaged, or isn't an event log.\n", filename);
infobox("Bad Input File", tmpbuf);
g_nevents = 0;
unmapfile((char *)ulp, size);
}
unmapfile((char *)ulp, size);
-
+
make_sorted_pid_vector();
g_free(s_pidhash);
s_pidhash = 0;
* add_clib_event
****************************************************************************/
-void add_clib_event(double delta, unsigned short track,
+void add_clib_event(double delta, unsigned short track,
unsigned short event, unsigned int index)
{
event_t *ep;
make_sorted_pid_vector();
g_free(s_pidhash);
s_pidhash = 0;
-
+
/* Give the view-1 world a chance to reset a few things... */
view1_read_events_callback();
}
char *rv;
int maphfile;
size_t mapfsize;
-
+
maphfile = open (file, O_RDONLY);
if (maphfile < 0)
boolean unmapfile (char *addr, ulong size)
{
if (munmap (addr, size) < 0) {
- g_warning("Unmap error, addr 0x%lx size 0x%x\n",
+ g_warning("Unmap error, addr 0x%lx size 0x%x\n",
(unsigned long) addr, (unsigned int)size);
return(FALSE);
}
if (ep->time < t)
top = index + 1;
- else
+ else
bottom = index - 1;
}
}
void events_about (char *tmpbuf)
{
- sprintf(tmpbuf+strlen(tmpbuf), "%d total events, %.3f ticks per us\n",
- (int)g_nevents, ticks_per_ns);
+ snprintf(tmpbuf+strlen(tmpbuf), 1024 - strlen(tmpbuf),
+ "%d total events, %.3f ticks per us\n",
+ (int)g_nevents, ticks_per_ns);
}