diff --git a/epan/column-utils.c b/epan/column-utils.c index 8851fce7f1..2505e6dff7 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -191,7 +191,7 @@ col_clear(column_info *cinfo, gint el) /* Use this if "str" points to something that will stay around (and thus needn't be copied). */ void -col_set_str(column_info *cinfo, gint el, gchar* str) +col_set_str(column_info *cinfo, gint el, const gchar* str) { int i; int fence; @@ -338,11 +338,11 @@ col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator, void col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...) { - va_list ap; - int i; - char orig_buf[COL_BUF_MAX_LEN]; - char *orig; - size_t max_len; + va_list ap; + int i; + char orig_buf[COL_BUF_MAX_LEN]; + const char *orig; + size_t max_len; g_assert(cinfo->col_first[el] >= 0); if (el == COL_INFO) @@ -354,12 +354,12 @@ col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...) for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { if (cinfo->fmt_matx[i][el]) { if (cinfo->col_data[i] != cinfo->col_buf[i]) { - /* This was set with "col_set_str()"; which is effectively const */ + /* This was set with "col_set_str()"; which is effectively const */ orig = cinfo->col_data[i]; } else { + strncpy(orig_buf, cinfo->col_buf[i], max_len); + orig_buf[max_len - 1] = '\0'; orig = orig_buf; - strncpy(orig, cinfo->col_buf[i], max_len); - orig[max_len - 1] = '\0'; } vsnprintf(cinfo->col_buf[i], max_len, format, ap); cinfo->col_buf[i][max_len - 1] = '\0'; diff --git a/epan/column_info.h b/epan/column_info.h index 85eff842e0..69c631afc7 100644 --- a/epan/column_info.h +++ b/epan/column_info.h @@ -31,18 +31,18 @@ #define COL_MAX_INFO_LEN 4096 typedef struct _column_info { - gint num_cols; /* Number of columns */ - gint *col_fmt; /* Format of column */ - gboolean **fmt_matx; /* Specifies which formats apply to a column */ - gint *col_first; /* First column number with a given format */ - gint *col_last; /* Last column number with a given format */ - gchar **col_title; /* Column titles */ - gchar **col_data; /* Column data */ - gchar **col_buf; /* Buffer into which to copy data for column */ - int *col_fence; /* Stuff in column buffer before this index is immutable */ - gchar **col_expr; /* Filter expression */ - gchar **col_expr_val; /* Value for filter expression */ - gboolean writable; /* Are we stil writing to the columns? */ + gint num_cols; /* Number of columns */ + gint *col_fmt; /* Format of column */ + gboolean **fmt_matx; /* Specifies which formats apply to a column */ + gint *col_first; /* First column number with a given format */ + gint *col_last; /* Last column number with a given format */ + gchar **col_title; /* Column titles */ + const gchar **col_data; /* Column data */ + gchar **col_buf; /* Buffer into which to copy data for column */ + int *col_fence; /* Stuff in column buffer before this index is immutable */ + gchar **col_expr; /* Filter expression */ + gchar **col_expr_val; /* Value for filter expression */ + gboolean writable; /* Are we stil writing to the columns? */ } column_info; /* diff --git a/gtk/packet_win.c b/gtk/packet_win.c index 5d5dae16a5..427b4fe9d1 100644 --- a/gtk/packet_win.c +++ b/gtk/packet_win.c @@ -95,7 +95,7 @@ void new_window_cb(GtkWidget *w _U_) { #define NewWinTitleLen 1000 char Title[NewWinTitleLen] = ""; - char *TextPtr; + const char *TextPtr; gint tv_size = 95, bv_size = 75; GtkWidget *main_w, *main_vbox, *pane, *tree_view, *tv_scrollw, diff --git a/print.c b/print.c index d1ffd14cb2..a95e3c859b 100644 --- a/print.c +++ b/print.c @@ -76,7 +76,7 @@ static gboolean print_hex_data_buffer(print_stream_t *stream, const guchar *cp, guint length, char_enc encoding); static void ps_clean_string(unsigned char *out, const unsigned char *in, int outbuf_size); -static void print_escaped_xml(FILE *fh, char *unescaped_string); +static void print_escaped_xml(FILE *fh, const char *unescaped_string); static void print_pdml_geninfo(proto_tree *tree, FILE *fh); @@ -561,9 +561,9 @@ get_field_data(GSList *src_list, field_info *fi) /* Print a string, escaping out certain characters that need to * escaped out for XML. */ static void -print_escaped_xml(FILE *fh, char *unescaped_string) +print_escaped_xml(FILE *fh, const char *unescaped_string) { - unsigned char *p; + const unsigned char *p; for (p = unescaped_string; *p != '\0'; p++) { switch (*p) {