summaryrefslogtreecommitdiffstats
path: root/src/tools/g2/pointsel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/g2/pointsel.c')
-rw-r--r--src/tools/g2/pointsel.c95
1 files changed, 48 insertions, 47 deletions
diff --git a/src/tools/g2/pointsel.c b/src/tools/g2/pointsel.c
index 018dc2139e6..1d0a217297e 100644
--- a/src/tools/g2/pointsel.c
+++ b/src/tools/g2/pointsel.c
@@ -1,4 +1,4 @@
-/*
+/*
*------------------------------------------------------------------
* Copyright (c) 2005-2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -229,37 +229,37 @@ void point_selector_init(void)
gtk_widget_show(s_nonebutton);
gtk_signal_connect (GTK_OBJECT(s_allbutton), "clicked",
- GTK_SIGNAL_FUNC(button_click_callback),
+ GTK_SIGNAL_FUNC(button_click_callback),
(gpointer) ALL_BUTTON);
gtk_signal_connect (GTK_OBJECT(s_nonebutton), "clicked",
- GTK_SIGNAL_FUNC(button_click_callback),
+ GTK_SIGNAL_FUNC(button_click_callback),
(gpointer) NONE_BUTTON);
- gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_allbutton, FALSE,
+ gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_allbutton, FALSE,
FALSE, 0);
- gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_nonebutton, FALSE,
+ gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_nonebutton, FALSE,
FALSE, 0);
-
+
gtk_widget_show(s_pointselbuttons);
- gtk_widget_ref(s_pointselbuttons);
+ gtk_widget_ref(s_pointselbuttons);
- gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE,
+ gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE,
FALSE, 0);
- gtk_box_pack_end (GTK_BOX(g_mainhbox), s_pointselbox,
+ gtk_box_pack_end (GTK_BOX(g_mainhbox), s_pointselbox,
FALSE, FALSE, 0);
- s_ps_vsadj = gtk_adjustment_new(0.0 /* initial value */,
+ s_ps_vsadj = gtk_adjustment_new(0.0 /* initial value */,
0.0 /* minimum value */,
2000.0 /* maximum value */,
- 0.1 /* step increment */,
- 10.0/* page increment */,
+ 0.1 /* step increment */,
+ 10.0/* page increment */,
10.0/* page size */);
-
+
s_ps_vscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT(s_ps_vsadj));
gtk_signal_connect (GTK_OBJECT (s_ps_vsadj), "value-changed",
- GTK_SIGNAL_FUNC (scroll_callback),
+ GTK_SIGNAL_FUNC (scroll_callback),
(gpointer)s_ps_vscroll);
gtk_box_pack_end(GTK_BOX(g_mainhbox), s_ps_vscroll, FALSE, FALSE, 0);
}
@@ -289,12 +289,12 @@ static void reset_point_selector(void)
gtk_widget_hide(s_pointselbox);
gtk_widget_hide(s_pointselbuttons);
gtk_widget_hide(s_ps_vscroll);
- gtk_container_remove(GTK_CONTAINER(s_pointselbox),
+ gtk_container_remove(GTK_CONTAINER(s_pointselbox),
s_pointselbuttons);
-
+
for (i = 0; i < g_neventdefs; i++) {
if (s_event_buttons[i]) {
- gtk_container_remove(GTK_CONTAINER(s_pointselbox),
+ gtk_container_remove(GTK_CONTAINER(s_pointselbox),
s_event_buttons[i]);
s_event_buttons[i] = 0;
}
@@ -314,7 +314,7 @@ static void create_point_selector(void)
for (i = 0; i < g_neventdefs; i++) {
ep = &g_eventdefs[i];
- sprintf(tmpbuf, "[%lu] %s", ep->event,
+ snprintf(tmpbuf, sizeof(tmpbuf), "[%lu] %s", ep->event,
ep->name ? ep->name : "(none)");
/* Hack to reduce width of point selectors */
if (strlen(tmpbuf) > 50) {
@@ -324,7 +324,7 @@ static void create_point_selector(void)
wp = gtk_check_button_new_with_label (tmpbuf);
s_event_buttons[i] = wp;
gtk_signal_connect (GTK_OBJECT(wp), "toggled",
- GTK_SIGNAL_FUNC(point_select_callback),
+ GTK_SIGNAL_FUNC(point_select_callback),
(gpointer) (unsigned long long) i);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(wp), TRUE);
@@ -335,7 +335,7 @@ static void create_point_selector(void)
s_min_shown_pointsel = 1;
up_button();
- gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE,
+ gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE,
FALSE, 0);
gtk_widget_show(s_pointselbuttons);
gtk_widget_show(s_pointselbox);
@@ -376,7 +376,7 @@ static void add_event(ulong event, char *name, char *format)
g_error("Too many event definitions, increase NEVENTS!");
/*NOTREACHED*/
}
-
+
/* Simple dup check, probably not needed very often */
for (i = 0; i < g_neventdefs; i++) {
if (g_eventdefs[i].event == event) {
@@ -398,7 +398,7 @@ static void add_event(ulong event, char *name, char *format)
* add_event_from_cpel_file
****************************************************************************/
-void add_event_from_cpel_file(ulong event, char *event_format,
+void add_event_from_cpel_file(ulong event, char *event_format,
char *datum_format)
{
event_def_t *ep;
@@ -414,7 +414,7 @@ void add_event_from_cpel_file(ulong event, char *event_format,
/*
* Duplicate the strings for backward compatibility. Otherwise,
* the g_free above will barf because the name/format strings are
- * actually in mmap'ed memory
+ * actually in mmap'ed memory
*/
ep->name = sxerox(event_format);
ep->format = sxerox(datum_format);
@@ -425,7 +425,7 @@ void add_event_from_cpel_file(ulong event, char *event_format,
* add_event_from_clib_file
****************************************************************************/
-void add_event_from_clib_file(unsigned int event, char *name,
+void add_event_from_clib_file(unsigned int event, char *name,
unsigned int vec_index)
{
event_def_t *ep;
@@ -478,7 +478,7 @@ static void read_header_file (void)
/* skip ws after #define */
while (*cp && isspace ((int)*cp))
cp++;
-
+
if (*cp == 0)
continue;
@@ -492,7 +492,7 @@ static void read_header_file (void)
/* skip ws after symbolic name */
while (*cp && isspace ((int)*cp))
cp++;
-
+
if (*cp == 0)
continue;
@@ -504,16 +504,16 @@ static void read_header_file (void)
while (*cp && *cp != '(')
cp++;
-
+
if (*cp == 0)
continue;
- cp++;
+ cp++;
while (*cp && isspace ((int)*cp))
cp++;
-
- }
+
+ }
/* eat event code. */
while (*cp && isdigit ((int)*cp))
@@ -537,7 +537,7 @@ static void read_header_file (void)
/* skip ws after event code */
while (*cp && isspace ((int)*cp))
cp++;
-
+
if (*cp != '/')
continue;
@@ -565,11 +565,11 @@ static void read_header_file (void)
continue;
*cp++ = 0;
-
+
/* skip ws after name: */
while (*cp && isspace ((int)*cp))
cp++;
-
+
if (*cp == 0 || *cp == '/')
{
format = " ";
@@ -577,7 +577,7 @@ static void read_header_file (void)
}
format = cp;
-
+
/* accumulate format string */
while (*cp && !isspace ((int)*cp))
cp++;
@@ -630,12 +630,12 @@ static boolean read_header_files (void)
/* skip ws after EV_COMPxxx_START */
while (*cp && isspace ((int)*cp))
cp++;
-
+
if (*cp == 0)
continue;
-
+
basenum = atol (cp);
-
+
/* skip #define */
while (*cp && (*cp != '/'))
cp++;
@@ -669,7 +669,7 @@ static boolean read_header_files (void)
while (*cp && !isspace ((int)*cp))
cp++;
-
+
*cp = 0;
s_hfp = fopen (name, "rt");
@@ -747,7 +747,7 @@ boolean read_event_definitions (char *filename)
s_elog_hfp = fopen (filename, "rt");
if (s_elog_hfp == NULL) {
- sprintf (tmpbuf, "Couldn't open %s\n", filename);
+ snprintf (tmpbuf, sizeof(tmpbuf), "Couldn't open %s\n", filename);
infobox ("Open Failed", tmpbuf);
return(FALSE);
}
@@ -765,7 +765,7 @@ boolean read_event_definitions (char *filename)
s_hfp = fopen (filename, "rt");
if (s_hfp == NULL) {
- sprintf (tmpbuf, "Couldn't open %s\n", filename);
+ snprintf (tmpbuf, sizeof(tmpbuf), "Couldn't open %s\n", filename);
infobox ("Read Event Definition Failure", tmpbuf);
return(FALSE);
}
@@ -774,7 +774,8 @@ boolean read_event_definitions (char *filename)
/* Happens if the user feeds us the wrong file, for example */
if (g_neventdefs == 0) {
- sprintf (tmpbuf, "No event definitions found in %s\n", filename);
+ snprintf (tmpbuf, sizeof(tmpbuf),
+ "No event definitions found in %s\n", filename);
infobox ("No Event Definitions?", tmpbuf);
return(FALSE);
}
@@ -805,7 +806,7 @@ event_def_t *find_event_definition (ulong code)
index = (bottom + top) / 2;
edp = (g_eventdefs + index);
-
+
if (edp->event == code)
return(edp);
@@ -815,14 +816,14 @@ event_def_t *find_event_definition (ulong code)
edp->selected = TRUE;
edp->event = code;
edp->format = "0x%x";
- sprintf (dummy_string, "E%lu", code);
+ snprintf (dummy_string, sizeof(dummy_string), "E%lu", code);
edp->name = &dummy_string[0];
return(edp);
}
if (edp->event < code)
top = index + 1;
- else
+ else
bottom = index - 1;
}
}
@@ -835,10 +836,10 @@ event_def_t *find_event_definition (ulong code)
void pointsel_next_snapshot(void)
{
int i;
-
+
for (i = 0; i < g_neventdefs; i++) {
gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON(s_event_buttons[i]),
+ GTK_TOGGLE_BUTTON(s_event_buttons[i]),
g_eventdefs[i].selected);
}
}
@@ -849,6 +850,6 @@ void pointsel_next_snapshot(void)
void pointsel_about (char *tmpbuf)
{
- sprintf (tmpbuf+strlen(tmpbuf), "%d event definitions\n",
+ snprintf (tmpbuf+strlen(tmpbuf), 128, "%d event definitions\n",
g_neventdefs);
}