diff options
-rw-r--r-- | src/plugins/hs_apps/vcl/sock_test_client.c | 4 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/sock_test_server.c | 3 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_client.c | 8 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_server.c | 2 | ||||
-rw-r--r-- | src/tools/g2/events.c | 30 | ||||
-rw-r--r-- | src/tools/g2/g2version.c | 4 | ||||
-rw-r--r-- | src/tools/g2/main.c | 22 | ||||
-rw-r--r-- | src/tools/g2/menu1.c | 124 | ||||
-rw-r--r-- | src/tools/g2/pointsel.c | 95 | ||||
-rw-r--r-- | src/tools/g2/props.c | 12 | ||||
-rw-r--r-- | src/tools/g2/view1.c | 40 | ||||
-rw-r--r-- | src/vnet/dhcp/dhcp6_ia_na_client_cp.c | 25 | ||||
-rw-r--r-- | src/vnet/dhcp/dhcp6_pd_client_cp.c | 25 | ||||
-rw-r--r-- | src/vnet/session/application_worker.c | 7 |
14 files changed, 206 insertions, 195 deletions
diff --git a/src/plugins/hs_apps/vcl/sock_test_client.c b/src/plugins/hs_apps/vcl/sock_test_client.c index ed43e7faaf1..6f5fb074503 100644 --- a/src/plugins/hs_apps/vcl/sock_test_client.c +++ b/src/plugins/hs_apps/vcl/sock_test_client.c @@ -327,7 +327,7 @@ echo_test_client () { static char buf[64]; - sprintf (buf, "CLIENT (fd %d) RESULTS", tsock->fd); + snprintf (buf, sizeof (buf), "CLIENT (fd %d) RESULTS", tsock->fd); vcl_test_stats_dump (buf, &tsock->stats, 1 /* show_rx */ , 1 /* show tx */ , ctrl->cfg.verbose); @@ -498,7 +498,7 @@ stream_test_client (vcl_test_t test) { static char buf[64]; - sprintf (buf, "CLIENT (fd %d) RESULTS", tsock->fd); + snprintf (buf, sizeof (buf), "CLIENT (fd %d) RESULTS", tsock->fd); vcl_test_stats_dump (buf, &tsock->stats, test == VCL_TEST_TYPE_BI /* show_rx */ , 1 /* show tx */ , ctrl->cfg.verbose); diff --git a/src/plugins/hs_apps/vcl/sock_test_server.c b/src/plugins/hs_apps/vcl/sock_test_server.c index 110ff3e183b..bd777ccb917 100644 --- a/src/plugins/hs_apps/vcl/sock_test_server.c +++ b/src/plugins/hs_apps/vcl/sock_test_server.c @@ -238,7 +238,8 @@ stream_test_server_start_stop (sock_server_conn_t * conn, { static char buf[64]; - sprintf (buf, "SERVER (fd %d) RESULTS", tc->fd); + snprintf (buf, sizeof (buf), "SERVER (fd %d) RESULTS", + tc->fd); vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */ , test == VCL_TEST_TYPE_BI /* show tx */ , diff --git a/src/plugins/hs_apps/vcl/vcl_test_client.c b/src/plugins/hs_apps/vcl/vcl_test_client.c index 55bc7889098..30b48d8d145 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_client.c +++ b/src/plugins/hs_apps/vcl/vcl_test_client.c @@ -394,7 +394,7 @@ vtc_accumulate_stats (vcl_test_client_worker_t * wrk, if (ctrl->cfg.verbose > 1) { - sprintf (buf, "CLIENT (fd %d) RESULTS", ts->fd); + snprintf (buf, sizeof (buf), "CLIENT (fd %d) RESULTS", ts->fd); vcl_test_stats_dump (buf, &ts->stats, show_rx, 1 /* show tx */ , ctrl->cfg.verbose); } @@ -553,10 +553,10 @@ vtc_print_stats (vcl_test_session_t * ctrl) } if (is_echo) - sprintf (buf, "Echo"); + snprintf (buf, sizeof (buf), "Echo"); else - sprintf (buf, "%s-directional Stream", - ctrl->cfg.test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + snprintf (buf, sizeof (buf), "%s-directional Stream", + ctrl->cfg.test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); } static void diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c index be225fa8c9e..364c32fc9f8 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_server.c +++ b/src/plugins/hs_apps/vcl/vcl_test_server.c @@ -180,7 +180,7 @@ vts_server_start_stop (vcl_test_server_worker_t * wrk, conn->stats.stop.tv_sec -= VCL_TEST_DELAY_DISCONNECT; if (conn->cfg.verbose) { - sprintf (buf, "SERVER (fd %d) RESULTS", tc->fd); + snprintf (buf, sizeof (buf), "SERVER (fd %d) RESULTS", tc->fd); vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */ , is_bi /* show tx */ , conn->cfg.verbose); } diff --git a/src/tools/g2/events.c b/src/tools/g2/events.c index f17a69db8f7..09054b71324 100644 --- a/src/tools/g2/events.c +++ b/src/tools/g2/events.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 2005-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -70,7 +70,7 @@ void event_init(void) 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) { @@ -189,10 +189,10 @@ static void make_sorted_pid_vector(void) /* * 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); } /**************************************************************************** @@ -214,7 +214,7 @@ void read_events(char *filename) 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; } @@ -222,7 +222,8 @@ void read_events(char *filename) 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); @@ -279,7 +280,7 @@ void read_events(char *filename) } unmapfile((char *)ulp, size); - + make_sorted_pid_vector(); g_free(s_pidhash); s_pidhash = 0; @@ -333,7 +334,7 @@ void add_cpel_event(ulonglong delta, ulong track, ulong event, ulong datum) * 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; @@ -355,7 +356,7 @@ void cpel_event_finalize(void) 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(); } @@ -370,7 +371,7 @@ char *mapfile (char *file, ulong *sizep) char *rv; int maphfile; size_t mapfsize; - + maphfile = open (file, O_RDONLY); if (maphfile < 0) @@ -417,7 +418,7 @@ char *mapfile (char *file, ulong *sizep) 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); } @@ -459,7 +460,7 @@ int find_event_index (ulonglong t) if (ep->time < t) top = index + 1; - else + else bottom = index - 1; } } @@ -470,6 +471,7 @@ int find_event_index (ulonglong t) 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); } diff --git a/src/tools/g2/g2version.c b/src/tools/g2/g2version.c index 05961ecf81a..cd0226ce006 100644 --- a/src/tools/g2/g2version.c +++ b/src/tools/g2/g2version.c @@ -14,5 +14,5 @@ * limitations under the License. */ -const char *version_string = "G2 (x86_64 GNU/Linux) major version 3.1"; -const char *minor_v_string = "Last Changed Sun Feb 3 10:38:26 EST 2019"; +const char *version_string = "G2 (x86_64 GNU/Linux) major version 3.2"; +const char *minor_v_string = "Last Changed Sat Apr 4 09:26:32 EDT 2020"; diff --git a/src/tools/g2/main.c b/src/tools/g2/main.c index 1ec7983acf5..5af679d44db 100644 --- a/src/tools/g2/main.c +++ b/src/tools/g2/main.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 2005-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,7 +34,7 @@ GtkWidget *g_mainwindow; /* The main window */ * [main window] * [main vbox] * [main (e.g. file) menubar] - * [view hbox] + * [view hbox] * [view bottom menu] */ @@ -62,7 +62,7 @@ int main (int argc, char **argv) char *title = "none"; int curarg=1; char *homedir; - + clib_mem_init (0, ((uword)3<<30)); gtk_init(&argc, &argv); @@ -71,11 +71,11 @@ int main (int argc, char **argv) tmpbuf[0] = 0; if (homedir) { - sprintf(tmpbuf, "%s/.g2", homedir); + snprintf(tmpbuf, sizeof(tmpbuf), "%s/.g2", homedir); } else { pw = getpwuid(geteuid()); if (pw) { - sprintf(tmpbuf, "%s/.g2", pw->pw_dir); + snprintf(tmpbuf, sizeof(tmpbuf), "%s/.g2", pw->pw_dir); } } if (tmpbuf[0]) @@ -94,7 +94,7 @@ int main (int argc, char **argv) g_mainvbox = gtk_vbox_new(FALSE, 0); g_mainhbox = gtk_hbox_new(FALSE, 0); - /* + /* * init routines */ @@ -103,11 +103,11 @@ int main (int argc, char **argv) view1_init(); event_init(); - /* + /* * Now that we're ready to rock 'n roll, see if we've been asked to * press a few buttons... */ - + while (curarg < argc) { if (!strncmp(argv[curarg], "--cpel-input", 4)) { curarg++; @@ -163,12 +163,12 @@ int main (int argc, char **argv) g_error ("Missing filename after --event-log\n"); } - fprintf(stderr, + fprintf(stderr, "g2 [--pointdefs <filename>] [--event-log <filename>]\n"); fprintf(stderr, " [--ticks-per-us <value>]\n"); - fprintf(stderr, + fprintf(stderr, " [--cpel-input <filename>] [--clib-input <filename]>\n"); - fprintf(stderr, + fprintf(stderr, "%s\n%s\n", version_string, minor_v_string); exit(0); } diff --git a/src/tools/g2/menu1.c b/src/tools/g2/menu1.c index fce81fa66b2..ab06a6b9abd 100644 --- a/src/tools/g2/menu1.c +++ b/src/tools/g2/menu1.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 2006-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -118,7 +118,7 @@ static void get_dialog_value (GtkWidget *dialog, gpointer user_data) { md_t *md = (md_t *)user_data; char * cb_arg; - + cb_arg = (char *) gtk_entry_get_text(GTK_ENTRY(md->entry)); if ((*md->callback)(cb_arg)) { @@ -133,7 +133,7 @@ static void get_dialog_value (GtkWidget *dialog, gpointer user_data) * modal_dialog ****************************************************************************/ -void modal_dialog (char *label_text, char *retry_text, char *default_value, +void modal_dialog (char *label_text, char *retry_text, char *default_value, boolean (*cb)(char *)) { GtkWidget *dialog, *label, *ok_button, *entry; @@ -158,10 +158,10 @@ void modal_dialog (char *label_text, char *retry_text, char *default_value, else md->callback = debug_dialog_callback; - gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", + gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); - gtk_signal_connect (GTK_OBJECT (entry), "activate", + gtk_signal_connect (GTK_OBJECT (entry), "activate", GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), @@ -193,26 +193,26 @@ static void get_eventdef_name (GtkFileSelection *sel, gpointer user_data) static void read_eventdef_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read Event Definitions From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "../h/elog.h"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_eventdef_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -261,21 +261,21 @@ static void read_events_callback(GtkToggleButton *item, gpointer data) char tmpbuf [32]; s_eventsel = gtk_file_selection_new("Read Events From..."); - + gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_events_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_eventsel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_eventsel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_eventsel)); @@ -283,7 +283,7 @@ static void read_events_callback(GtkToggleButton *item, gpointer data) if (ticks_per_ns_set) gtk_widget_show (s_eventsel); else { - sprintf(tmpbuf, "%.3f", ticks_per_ns); + snprintf(tmpbuf, sizeof(tmpbuf), "%.3f", ticks_per_ns); modal_dialog ("Please enter clock ticks per nanosecond", "Invalid: Please enter clock ticks per nanosecond", tmpbuf, get_ticks_per_ns); @@ -312,10 +312,10 @@ void infobox_size_request (GtkWidget *widget, GtkRequisition *req, int widest_line_in_chars; int w; int nlines; - + /* * You'd think that the string extent function would work here. - * You'd be wrong. + * You'd be wrong. */ nlines = w = widest_line_in_chars = 0; for (cp = text; *cp; cp++) { @@ -349,8 +349,8 @@ void infobox(char *label_text, char *text) entry = gtk_text_new(NULL, NULL); - gtk_signal_connect (GTK_OBJECT (entry), "size-request", - GTK_SIGNAL_FUNC(infobox_size_request), + gtk_signal_connect (GTK_OBJECT (entry), "size-request", + GTK_SIGNAL_FUNC(infobox_size_request), (gpointer) text); gtk_text_insert(GTK_TEXT(entry), g_font, &fg_black, &bg_white, @@ -360,8 +360,8 @@ void infobox(char *label_text, char *text) ok_button = gtk_button_new_with_label("OK"); - gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), + gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer) GTK_OBJECT(dialog)); box = gtk_vbox_new(FALSE, 5); @@ -393,12 +393,14 @@ static void help_general_callback(GtkToggleButton *item, gpointer data) static void help_about_callback(GtkToggleButton *item, gpointer data) { char tmpbuf [1024]; - sprintf (tmpbuf, "G2 -- Graphical Event Viewer\n\n"); + snprintf (tmpbuf, sizeof(tmpbuf), "G2 -- Graphical Event Viewer\n\n"); view1_about(tmpbuf); pointsel_about(tmpbuf); events_about(tmpbuf); - sprintf (tmpbuf+strlen(tmpbuf), "\n%s\n", version_string); - sprintf (tmpbuf+strlen(tmpbuf), "%s\n", minor_v_string); + snprintf (tmpbuf+strlen(tmpbuf), sizeof(tmpbuf) - strlen(tmpbuf), + "\n%s\n", version_string); + snprintf (tmpbuf+strlen(tmpbuf), sizeof(tmpbuf) - strlen(tmpbuf), + "%s\n", minor_v_string); infobox("About", tmpbuf); } @@ -433,26 +435,26 @@ static void get_clib_name (GtkFileSelection *sel, gpointer user_data) static void read_cpel_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read CPEL data from..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "cpel.out"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_cpel_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -465,26 +467,26 @@ static void read_cpel_callback(GtkToggleButton *item, gpointer data) static void read_clib_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read clib data From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "clib.out"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_clib_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -500,42 +502,42 @@ void menu1_init(void) s_filemenu = gtk_menu_new(); - s_readcpel = gtk_menu_item_new_with_label + s_readcpel = gtk_menu_item_new_with_label ("Read CPEL file"); gtk_menu_append(GTK_MENU(s_filemenu), s_readcpel); - gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", + gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", GTK_SIGNAL_FUNC(read_cpel_callback), 0); - s_readclib = gtk_menu_item_new_with_label + s_readclib = gtk_menu_item_new_with_label ("Read CLIB file"); gtk_menu_append(GTK_MENU(s_filemenu), s_readclib); - gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", + gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", GTK_SIGNAL_FUNC(read_clib_callback), 0); - + s_readdefs = gtk_menu_item_new_with_label ("Read Event Definitions"); gtk_menu_append(GTK_MENU(s_filemenu), s_readdefs); - gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", + gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", GTK_SIGNAL_FUNC(read_eventdef_callback), 0); - + s_readevents = gtk_menu_item_new_with_label ("Read Event Log"); gtk_menu_append(GTK_MENU(s_filemenu), s_readevents); - gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", + gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", GTK_SIGNAL_FUNC(read_events_callback), 0); - - s_readeventsclock = gtk_menu_item_new_with_label + + s_readeventsclock = gtk_menu_item_new_with_label ("Read Event Log with Different Clock Rate"); gtk_menu_append(GTK_MENU(s_filemenu), s_readeventsclock); - gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", + gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", GTK_SIGNAL_FUNC(read_eventsclock_callback), 0); s_print = gtk_menu_item_new_with_label ("Print"); gtk_menu_append(GTK_MENU(s_filemenu), s_print); - gtk_signal_connect(GTK_OBJECT(s_print), "activate", + gtk_signal_connect(GTK_OBJECT(s_print), "activate", GTK_SIGNAL_FUNC(view1_print_callback), 0); - + s_quit = gtk_menu_item_new_with_label ("Exit"); gtk_menu_append(GTK_MENU(s_filemenu), s_quit); - gtk_signal_connect(GTK_OBJECT(s_quit), "activate", + gtk_signal_connect(GTK_OBJECT(s_quit), "activate", GTK_SIGNAL_FUNC(gtk_main_quit), 0); s_mainfilemenu = gtk_menu_item_new_with_label("File"); @@ -545,12 +547,12 @@ void menu1_init(void) s_help_general = gtk_menu_item_new_with_label ("General"); gtk_menu_append(GTK_MENU(s_helpmenu), s_help_general); - gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", + gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", GTK_SIGNAL_FUNC(help_general_callback), 0); s_help_about = gtk_menu_item_new_with_label ("About"); gtk_menu_append(GTK_MENU(s_helpmenu), s_help_about); - gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", + gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", GTK_SIGNAL_FUNC(help_about_callback), 0); s_mainhelpmenu = gtk_menu_item_new_with_label("Help"); 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); } diff --git a/src/tools/g2/props.c b/src/tools/g2/props.c index a23dc0504d2..41df97ab7dd 100644 --- a/src/tools/g2/props.c +++ b/src/tools/g2/props.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 1997-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ static prop_t *buckets [NBUCKETS]; static int hash_shifts[4] = {24, 16, 8, 0}; /* - * getprop + * getprop */ char *getprop (char *name) @@ -106,7 +106,7 @@ void addprop (char *name, char *value) } /* - * sxerox + * sxerox */ static char *sxerox (char *s) @@ -117,7 +117,7 @@ static char *sxerox (char *s) } /* - * readprops + * readprops */ #define START 0 @@ -183,7 +183,7 @@ int readprops (char *filename) c, linenum); exit (1); break; - + case CPP_COMMENT: while (1) { c = getc (ifp); @@ -217,7 +217,7 @@ int readprops (char *filename) } } break; - + case READNAME: i = 0; namebuf[i++] = c; diff --git a/src/tools/g2/view1.c b/src/tools/g2/view1.c index a0cff900dbf..38c41522a45 100644 --- a/src/tools/g2/view1.c +++ b/src/tools/g2/view1.c @@ -436,9 +436,6 @@ void format_popbox_string (char *tmpbuf, int len, event_t *ep, event_def_t *edp) { char *fp; -#ifdef NOTDEF - sprintf(tmpbuf,"%d:", ep->code); -#endif if (ep->flags & EVENT_FLAG_CLIB) { elog_event_t *eep; u8 *s; @@ -898,7 +895,7 @@ static int toggle_event_select(GdkEventButton *event, v1_geometry_t *vp) } } - sprintf(tmpbuf, "%ld", ep->code); + snprintf(tmpbuf, sizeof(tmpbuf), "%ld", ep->code); /* Figure out the dimensions of the regular box */ rp = tbox(tmpbuf, x, y, TBOX_GETRECT_EVENT); @@ -1405,13 +1402,13 @@ button_press_event (GtkWidget *widget, GdkEventButton *event) */ nsec = ((double)xdelta)*time_per_pixel; if (nsec >1e9) { - sprintf(tmpbuf, "%8.3f sec ", nsec/1e9); + snprintf(tmpbuf, sizeof(tmpbuf), "%8.3f sec ", nsec/1e9); } else if (nsec > 1e6) { - sprintf(tmpbuf, "%8.3f msec", nsec/1e6); + snprintf(tmpbuf, sizeof(tmpbuf), "%8.3f msec", nsec/1e6); } else if (nsec > 1e3) { - sprintf(tmpbuf, "%8.3f usec", nsec/1e3); + snprintf(tmpbuf, sizeof(tmpbuf), "%8.3f usec", nsec/1e3); } else { - sprintf(tmpbuf, "%8.0f nsec", nsec); + snprintf(tmpbuf, sizeof(tmpbuf), "%8.0f nsec", nsec); } s_v1->last_time_interval = nsec; tbox(tmpbuf, (int)(press3_event.x), s_v1->pop_offset, @@ -1580,7 +1577,7 @@ boolean event_search_internal (void) x = s_v1->pid_ax_width + (int)(((double)(ep->time - s_v1->minvistime)) / time_per_pixel); - sprintf(tmpbuf, "SEARCH RESULT"); + snprintf(tmpbuf, sizeof(tmpbuf), "SEARCH RESULT"); tbox(tmpbuf, x, y - s_v1->pop_offset, TBOX_DRAW_BOXED); line(x, y-s_v1->pop_offset, x, y, LINE_DRAW_BLACK); } else { @@ -1594,7 +1591,8 @@ boolean event_search_internal (void) return(TRUE); } } - sprintf (tmpbuf, "Search for event %ld failed...\n", s_srchcode); + snprintf (tmpbuf, sizeof(tmpbuf), + "Search for event %ld failed...\n", s_srchcode); message_line(tmpbuf); s_srchfail_up = TRUE; return(TRUE); @@ -1814,8 +1812,9 @@ boolean anomaly_search_internal (void) return(TRUE); } } - sprintf (tmpbuf, "Search for an anomalous event %ld failed...\n", - s_anomalycode); + snprintf (tmpbuf, sizeof(tmpbuf), + "Search for an anomalous event %ld failed...\n", + s_anomalycode); message_line(tmpbuf); s_srchfail_up = TRUE; return(TRUE); @@ -3397,13 +3396,8 @@ static void display_event_data(v1_geometry_t *vp) if (ep->flags & (EVENT_FLAG_SELECT | EVENT_FLAG_SEARCHRSLT)) { if (ep->flags & EVENT_FLAG_SELECT) { format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); -#ifdef NOTDEF - sprintf(tmpbuf, edp->name); - sprintf(tmpbuf+strlen(tmpbuf), ": "); - sprintf(tmpbuf+strlen(tmpbuf), edp->format, ep->datum); -#endif } else { - sprintf(tmpbuf, "SEARCH RESULT"); + snprintf(tmpbuf, sizeof(tmpbuf), "SEARCH RESULT"); } print_rect = tbox(tmpbuf, x, y - vp->pop_offset, TBOX_DRAW_BOXED+s_print_offset); @@ -3419,7 +3413,7 @@ static void display_event_data(v1_geometry_t *vp) line(x, y - delta, x, y + delta, LINE_DRAW_BLACK); last_x_used[pid_index] = x + 1; } else { - sprintf(tmpbuf, "%ld", ep->code); + snprintf(tmpbuf, sizeof(tmpbuf), "%ld", ep->code); print_rect = tbox(tmpbuf, x, y, TBOX_DRAW_EVENT+s_print_offset); if (last_x_used != NULL) last_x_used[pid_index] = x + print_rect->width; @@ -3506,7 +3500,7 @@ static void display_time_axis(v1_geometry_t *vp) time += (double)(vp->minvistime); time /= unit_divisor; - sprintf (tmpbuf, "%.2f%s", time, units); + snprintf (tmpbuf, sizeof(tmpbuf), "%.2f%s", time, units); tbox(tmpbuf, x+xoffset, y+15, TBOX_DRAW_PLAIN+s_print_offset); @@ -3571,13 +3565,13 @@ void view1_about (char *tmpbuf) int nsnaps; snapshot_t *snaps; - sprintf(tmpbuf+strlen(tmpbuf), "Minvistime %lld\nMaxvistime %lld\n", + snprintf(tmpbuf+strlen(tmpbuf), 128, "Minvistime %lld\nMaxvistime %lld\n", s_v1->minvistime, s_v1->maxvistime); - sprintf(tmpbuf+strlen(tmpbuf), "Strip Height %d\n", + snprintf(tmpbuf+strlen(tmpbuf), 128, "Strip Height %d\n", s_v1->strip_height); for (nsnaps = 0, snaps = s_snapshots; snaps; snaps = snaps->next) { nsnaps++; } - sprintf(tmpbuf+strlen(tmpbuf), "%d snapshots in the ring\n", nsnaps); + snprintf(tmpbuf+strlen(tmpbuf), 128, "%d snapshots in the ring\n", nsnaps); } diff --git a/src/vnet/dhcp/dhcp6_ia_na_client_cp.c b/src/vnet/dhcp/dhcp6_ia_na_client_cp.c index c5e4d0ce1da..78baf18cb40 100644 --- a/src/vnet/dhcp/dhcp6_ia_na_client_cp.c +++ b/src/vnet/dhcp/dhcp6_ia_na_client_cp.c @@ -582,8 +582,8 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, clib_error_t *error = 0; client_state_t *cs; f64 current_time = vlib_time_now (vm); - char buf1[256]; - char buf2[256]; + u8 *buf1 = 0; + u8 *buf2 = 0; const char *rebinding; u32 i; @@ -592,26 +592,28 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, cs = &rm->client_state_by_sw_if_index[i]; if (cs->enabled) { + vec_reset_length (buf1); + vec_reset_length (buf2); if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time) { - sprintf (buf1, "%u remaining", - (u32) round (cs->T1_due_time - current_time)); + buf1 = format (buf1, "%u remaining", + (u32) round (cs->T1_due_time - current_time)); } else - sprintf (buf1, "timeout"); + buf1 = format (buf1, "timeout"); if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time) - sprintf (buf2, "%u remaining", - (u32) round (cs->T2_due_time - current_time)); + buf2 = format (buf2, "%u remaining", + (u32) round (cs->T2_due_time - current_time)); else - sprintf (buf2, "timeout"); + buf2 = format (buf2, "timeout"); if (cs->rebinding) rebinding = ", REBINDING"; else rebinding = ""; if (cs->T1) vlib_cli_output (vm, - "sw_if_index: %u, T1: %u (%s), " - "T2: %u (%s), server index: %d%s", i, + "sw_if_index: %u, T1: %u (%v), " + "T2: %u (%v), server index: %d%s", i, cs->T1, buf1, cs->T2, buf2, cs->server_index, rebinding); else @@ -619,6 +621,9 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, } } + vec_free (buf1); + vec_free (buf2); + return error; } diff --git a/src/vnet/dhcp/dhcp6_pd_client_cp.c b/src/vnet/dhcp/dhcp6_pd_client_cp.c index 0b1b707981a..984b74ad6ec 100644 --- a/src/vnet/dhcp/dhcp6_pd_client_cp.c +++ b/src/vnet/dhcp/dhcp6_pd_client_cp.c @@ -1118,8 +1118,8 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, client_state_t *cs; f64 current_time = vlib_time_now (vm); const u8 *prefix_group; - char buf1[256]; - char buf2[256]; + u8 *buf1 = 0; + u8 *buf2 = 0; const char *rebinding; u32 i; @@ -1128,18 +1128,20 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, cs = &rm->client_state_by_sw_if_index[i]; if (cs->enabled) { + vec_reset_length (buf1); + vec_reset_length (buf2); if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time) { - sprintf (buf1, "%u remaining", - (u32) round (cs->T1_due_time - current_time)); + buf1 = format (buf1, "%u remaining", + (u32) round (cs->T1_due_time - current_time)); } else - sprintf (buf1, "timeout"); + buf1 = format (buf1, "timeout"); if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time) - sprintf (buf2, "%u remaining", - (u32) round (cs->T2_due_time - current_time)); + buf2 = format (buf2, "%u remaining", + (u32) round (cs->T2_due_time - current_time)); else - sprintf (buf2, "timeout"); + buf2 = format (buf2, "timeout"); if (cs->rebinding) rebinding = ", REBINDING"; else @@ -1148,8 +1150,8 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, pm->prefix_group_name_by_index[cs->prefix_group_index]; if (cs->T1) vlib_cli_output (vm, - "sw_if_index: %u, prefix group: %s, T1: %u (%s), " - "T2: %u (%s), server index: %d%s", i, + "sw_if_index: %u, prefix group: %s, T1: %u (%v), " + "T2: %u (%v), server index: %d%s", i, prefix_group, cs->T1, buf1, cs->T2, buf2, cs->server_index, rebinding); else @@ -1158,6 +1160,9 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, } } + vec_free (buf1); + vec_free (buf2); + return error; } diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c index f4321edb09f..49c76b8d354 100644 --- a/src/vnet/session/application_worker.c +++ b/src/vnet/session/application_worker.c @@ -676,10 +676,11 @@ format_app_worker_listener (u8 * s, va_list * args) if (verbose) { - char buf[32]; - sprintf (buf, "%u(%u)", app_wrk->wrk_map_index, app_wrk->wrk_index); - s = format (s, "%-40s%-25s%=10s%-15u%-15u%-10u", str, app_name, + u8 *buf; + buf = format (0, "%u(%u)", app_wrk->wrk_map_index, app_wrk->wrk_index); + s = format (s, "%-40s%-25s%=10v%-15u%-15u%-10u", str, app_name, buf, app_wrk->api_client_index, handle, sm_index); + vec_free (buf); } else s = format (s, "%-40s%-25s%=10u", str, app_name, app_wrk->wrk_map_index); |