* ui-file.h (ui_file_xstrdup): Mention that the length argument
may be NULL. * ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is NULL. * aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length parameter to ui_file_xstrdup. * arm-tdep.c (_initialize_arm_tdep): Ditto. * infrun.c (print_target_wait_results): Ditto. * language.c (add_language): Ditto. * linespec.c (cplusplus_error): Ditto. * remote.c (escape_buffer): Ditto. * typeprint.c (type_to_string): Ditto. * utils.c (error_stream): Ditto. * varobj.c (value_get_print_value): Ditto. * xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with `length' local. Pass it to ui_file_xstrdup, and avoid an strlen call. * gdbarch.sh (verify_gdbarch): Ditto. * gdbarch.c: Regenerate. * cli/cli-setshow.c (do_setshow_command): Pass NULL as length parameter to ui_file_xstrdup. * python/python-frame.c (frapy_str): Ditto. * python/python-type.c (typy_str): Use the length local instead of calling strlen. * python/python-value.c (valpy_str): Pass NULL as length parameter to ui_file_xstrdup.
This commit is contained in:
parent
4da0d87511
commit
759ef83693
19 changed files with 59 additions and 41 deletions
|
@ -1,3 +1,32 @@
|
|||
2009-08-14 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
* ui-file.h (ui_file_xstrdup): Mention that the length argument
|
||||
may be NULL.
|
||||
* ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is
|
||||
NULL.
|
||||
* aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length
|
||||
parameter to ui_file_xstrdup.
|
||||
* arm-tdep.c (_initialize_arm_tdep): Ditto.
|
||||
* infrun.c (print_target_wait_results): Ditto.
|
||||
* language.c (add_language): Ditto.
|
||||
* linespec.c (cplusplus_error): Ditto.
|
||||
* remote.c (escape_buffer): Ditto.
|
||||
* typeprint.c (type_to_string): Ditto.
|
||||
* utils.c (error_stream): Ditto.
|
||||
* varobj.c (value_get_print_value): Ditto.
|
||||
* xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with
|
||||
`length' local. Pass it to ui_file_xstrdup, and avoid an strlen
|
||||
call.
|
||||
* gdbarch.sh (verify_gdbarch): Ditto.
|
||||
* gdbarch.c: Regenerate.
|
||||
* cli/cli-setshow.c (do_setshow_command): Pass NULL as length
|
||||
parameter to ui_file_xstrdup.
|
||||
* python/python-frame.c (frapy_str): Ditto.
|
||||
* python/python-type.c (typy_str): Use the length local instead of
|
||||
calling strlen.
|
||||
* python/python-value.c (valpy_str): Pass NULL as length parameter
|
||||
to ui_file_xstrdup.
|
||||
|
||||
2009-08-13 Doug Evans <dje@google.com>
|
||||
|
||||
* utils.c (gnu_debuglink_crc32): Store crc32_table as unsigned int
|
||||
|
|
|
@ -1734,7 +1734,6 @@ aix_thread_extra_thread_info (struct thread_info *thread)
|
|||
pthdb_suspendstate_t suspendstate;
|
||||
pthdb_detachstate_t detachstate;
|
||||
int cancelpend;
|
||||
long length;
|
||||
static char *ret = NULL;
|
||||
|
||||
if (!PD_TID (thread->ptid))
|
||||
|
@ -1775,7 +1774,7 @@ aix_thread_extra_thread_info (struct thread_info *thread)
|
|||
|
||||
xfree (ret); /* Free old buffer. */
|
||||
|
||||
ret = ui_file_xstrdup (buf, &length);
|
||||
ret = ui_file_xstrdup (buf, NULL);
|
||||
ui_file_delete (buf);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -6081,7 +6081,7 @@ _initialize_arm_tdep (void)
|
|||
_("The valid values are:\n"),
|
||||
regdesc,
|
||||
_("The default is \"std\"."));
|
||||
helptext = ui_file_xstrdup (stb, &length);
|
||||
helptext = ui_file_xstrdup (stb, NULL);
|
||||
ui_file_delete (stb);
|
||||
|
||||
add_setshow_enum_cmd("disassembler", no_class,
|
||||
|
|
|
@ -383,8 +383,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
|
|||
ui_out_field_stream (uiout, "value", stb);
|
||||
else
|
||||
{
|
||||
long length;
|
||||
char *value = ui_file_xstrdup (stb->stream, &length);
|
||||
char *value = ui_file_xstrdup (stb->stream, NULL);
|
||||
make_cleanup (xfree, value);
|
||||
if (c->show_value_func != NULL)
|
||||
c->show_value_func (gdb_stdout, from_tty, c, value);
|
||||
|
|
|
@ -507,7 +507,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
|
|||
{
|
||||
struct ui_file *log;
|
||||
struct cleanup *cleanups;
|
||||
long dummy;
|
||||
long length;
|
||||
char *buf;
|
||||
log = mem_fileopen ();
|
||||
cleanups = make_cleanup_ui_file_delete (log);
|
||||
|
@ -639,9 +639,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
|
|||
/* Skip verify of record_special_symbol, has predicate */
|
||||
/* Skip verify of has_global_solist, invalid_p == 0 */
|
||||
/* Skip verify of has_global_breakpoints, invalid_p == 0 */
|
||||
buf = ui_file_xstrdup (log, &dummy);
|
||||
buf = ui_file_xstrdup (log, &length);
|
||||
make_cleanup (xfree, buf);
|
||||
if (strlen (buf) > 0)
|
||||
if (length > 0)
|
||||
internal_error (__FILE__, __LINE__,
|
||||
_("verify_gdbarch: the following are invalid ...%s"),
|
||||
buf);
|
||||
|
|
|
@ -1417,7 +1417,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
|
|||
{
|
||||
struct ui_file *log;
|
||||
struct cleanup *cleanups;
|
||||
long dummy;
|
||||
long length;
|
||||
char *buf;
|
||||
log = mem_fileopen ();
|
||||
cleanups = make_cleanup_ui_file_delete (log);
|
||||
|
@ -1463,9 +1463,9 @@ do
|
|||
fi
|
||||
done
|
||||
cat <<EOF
|
||||
buf = ui_file_xstrdup (log, &dummy);
|
||||
buf = ui_file_xstrdup (log, &length);
|
||||
make_cleanup (xfree, buf);
|
||||
if (strlen (buf) > 0)
|
||||
if (length > 0)
|
||||
internal_error (__FILE__, __LINE__,
|
||||
_("verify_gdbarch: the following are invalid ...%s"),
|
||||
buf);
|
||||
|
|
|
@ -1943,7 +1943,6 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
|
|||
char *status_string = target_waitstatus_to_string (ws);
|
||||
struct ui_file *tmp_stream = mem_fileopen ();
|
||||
char *text;
|
||||
long len;
|
||||
|
||||
/* The text is split over several lines because it was getting too long.
|
||||
Call fprintf_unfiltered (gdb_stdlog) once so that the text is still
|
||||
|
@ -1963,7 +1962,7 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
|
|||
"infrun: %s\n",
|
||||
status_string);
|
||||
|
||||
text = ui_file_xstrdup (tmp_stream, &len);
|
||||
text = ui_file_xstrdup (tmp_stream, NULL);
|
||||
|
||||
/* This uses %s in part to handle %'s in the text, but also to avoid
|
||||
a gcc error: the format attribute requires a string literal. */
|
||||
|
|
|
@ -888,7 +888,6 @@ add_language (const struct language_defn *lang)
|
|||
|
||||
int i;
|
||||
struct ui_file *tmp_stream;
|
||||
long len;
|
||||
|
||||
if (lang->la_magic != LANG_MAGIC)
|
||||
{
|
||||
|
@ -945,7 +944,7 @@ local or auto Automatic setting based on source file\n"));
|
|||
}
|
||||
|
||||
xfree (language_set_doc);
|
||||
language_set_doc = ui_file_xstrdup (tmp_stream, &len);
|
||||
language_set_doc = ui_file_xstrdup (tmp_stream, NULL);
|
||||
ui_file_delete (tmp_stream);
|
||||
|
||||
add_setshow_enum_cmd ("language", class_support,
|
||||
|
|
|
@ -150,7 +150,6 @@ static NORETURN void
|
|||
cplusplus_error (const char *name, const char *fmt, ...)
|
||||
{
|
||||
struct ui_file *tmp_stream;
|
||||
long len;
|
||||
char *message;
|
||||
tmp_stream = mem_fileopen ();
|
||||
make_cleanup_ui_file_delete (tmp_stream);
|
||||
|
@ -169,9 +168,9 @@ cplusplus_error (const char *name, const char *fmt, ...)
|
|||
"(Note leading single quote.)"),
|
||||
name, name);
|
||||
|
||||
message = ui_file_xstrdup (tmp_stream, &len);
|
||||
make_cleanup (xfree, message);
|
||||
throw_error (NOT_FOUND_ERROR, "%s", message);
|
||||
message = ui_file_xstrdup (tmp_stream, NULL);
|
||||
make_cleanup (xfree, message);
|
||||
throw_error (NOT_FOUND_ERROR, "%s", message);
|
||||
}
|
||||
|
||||
/* Return the number of methods described for TYPE, including the
|
||||
|
|
|
@ -80,13 +80,12 @@ static PyObject *
|
|||
frapy_str (PyObject *self)
|
||||
{
|
||||
char *s;
|
||||
long len;
|
||||
PyObject *result;
|
||||
struct ui_file *strfile;
|
||||
|
||||
strfile = mem_fileopen ();
|
||||
fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
|
||||
s = ui_file_xstrdup (strfile, &len);
|
||||
s = ui_file_xstrdup (strfile, NULL);
|
||||
result = PyString_FromString (s);
|
||||
xfree (s);
|
||||
|
||||
|
|
|
@ -494,13 +494,13 @@ typy_str (PyObject *self)
|
|||
{
|
||||
volatile struct gdb_exception except;
|
||||
char *thetype = NULL;
|
||||
long length = 0;
|
||||
PyObject *result;
|
||||
|
||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
struct cleanup *old_chain;
|
||||
struct ui_file *stb;
|
||||
long length;
|
||||
|
||||
stb = mem_fileopen ();
|
||||
old_chain = make_cleanup_ui_file_delete (stb);
|
||||
|
@ -516,7 +516,7 @@ typy_str (PyObject *self)
|
|||
GDB_PY_HANDLE_EXCEPTION (except);
|
||||
}
|
||||
|
||||
result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL);
|
||||
result = PyUnicode_Decode (thetype, length, host_charset (), NULL);
|
||||
xfree (thetype);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -348,7 +348,6 @@ static PyObject *
|
|||
valpy_str (PyObject *self)
|
||||
{
|
||||
char *s = NULL;
|
||||
long dummy;
|
||||
struct ui_file *stb;
|
||||
struct cleanup *old_chain;
|
||||
PyObject *result;
|
||||
|
@ -365,7 +364,7 @@ valpy_str (PyObject *self)
|
|||
{
|
||||
common_val_print (((value_object *) self)->value, stb, 0,
|
||||
&opts, python_language);
|
||||
s = ui_file_xstrdup (stb, &dummy);
|
||||
s = ui_file_xstrdup (stb, NULL);
|
||||
}
|
||||
GDB_PY_HANDLE_EXCEPTION (except);
|
||||
|
||||
|
|
|
@ -5947,13 +5947,12 @@ escape_buffer (const char *buf, int n)
|
|||
struct cleanup *old_chain;
|
||||
struct ui_file *stb;
|
||||
char *str;
|
||||
long length;
|
||||
|
||||
stb = mem_fileopen ();
|
||||
old_chain = make_cleanup_ui_file_delete (stb);
|
||||
|
||||
fputstrn_unfiltered (buf, n, 0, stb);
|
||||
str = ui_file_xstrdup (stb, &length);
|
||||
str = ui_file_xstrdup (stb, NULL);
|
||||
do_cleanups (old_chain);
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ char *
|
|||
type_to_string (struct type *type)
|
||||
{
|
||||
char *s = NULL;
|
||||
long dummy;
|
||||
struct ui_file *stb;
|
||||
struct cleanup *old_chain;
|
||||
volatile struct gdb_exception except;
|
||||
|
@ -97,7 +96,7 @@ type_to_string (struct type *type)
|
|||
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
type_print (type, "", stb, -1);
|
||||
s = ui_file_xstrdup (stb, &dummy);
|
||||
s = ui_file_xstrdup (stb, NULL);
|
||||
}
|
||||
if (except.reason < 0)
|
||||
s = NULL;
|
||||
|
|
|
@ -285,8 +285,7 @@ do_ui_file_xstrdup (void *context, const char *buffer, long length)
|
|||
}
|
||||
|
||||
char *
|
||||
ui_file_xstrdup (struct ui_file *file,
|
||||
long *length)
|
||||
ui_file_xstrdup (struct ui_file *file, long *length)
|
||||
{
|
||||
struct accumulated_ui_file acc;
|
||||
acc.buffer = NULL;
|
||||
|
@ -294,7 +293,8 @@ ui_file_xstrdup (struct ui_file *file,
|
|||
ui_file_put (file, do_ui_file_xstrdup, &acc);
|
||||
if (acc.buffer == NULL)
|
||||
acc.buffer = xstrdup ("");
|
||||
*length = acc.length;
|
||||
if (length != NULL)
|
||||
*length = acc.length;
|
||||
return acc.buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ extern void ui_file_put (struct ui_file *src, ui_file_put_method_ftype *write, v
|
|||
|
||||
/* Returns a freshly allocated buffer containing the entire contents
|
||||
of FILE (as determined by ui_file_put()) with a NUL character
|
||||
appended. LENGTH is set to the size of the buffer minus that
|
||||
appended NUL. */
|
||||
appended. LENGTH, if not NULL, is set to the size of the buffer
|
||||
minus that appended NUL. */
|
||||
extern char *ui_file_xstrdup (struct ui_file *file, long *length);
|
||||
|
||||
|
||||
|
|
|
@ -838,8 +838,7 @@ fatal (const char *string, ...)
|
|||
NORETURN void
|
||||
error_stream (struct ui_file *stream)
|
||||
{
|
||||
long len;
|
||||
char *message = ui_file_xstrdup (stream, &len);
|
||||
char *message = ui_file_xstrdup (stream, NULL);
|
||||
make_cleanup (xfree, message);
|
||||
error (("%s"), message);
|
||||
}
|
||||
|
|
|
@ -2175,7 +2175,6 @@ static char *
|
|||
value_get_print_value (struct value *value, enum varobj_display_formats format,
|
||||
struct varobj *var)
|
||||
{
|
||||
long dummy;
|
||||
struct ui_file *stb;
|
||||
struct cleanup *old_chain;
|
||||
gdb_byte *thevalue = NULL;
|
||||
|
@ -2247,7 +2246,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
|
|||
}
|
||||
else
|
||||
common_val_print (value, stb, 0, &opts, current_language);
|
||||
thevalue = ui_file_xstrdup (stb, &dummy);
|
||||
thevalue = ui_file_xstrdup (stb, NULL);
|
||||
|
||||
do_cleanups (old_chain);
|
||||
return thevalue;
|
||||
|
|
|
@ -2498,7 +2498,7 @@ xtensa_verify_config (struct gdbarch *gdbarch)
|
|||
struct ui_file *log;
|
||||
struct cleanup *cleanups;
|
||||
struct gdbarch_tdep *tdep;
|
||||
long dummy;
|
||||
long length;
|
||||
char *buf;
|
||||
|
||||
tdep = gdbarch_tdep (gdbarch);
|
||||
|
@ -2531,9 +2531,9 @@ xtensa_verify_config (struct gdbarch *gdbarch)
|
|||
if (tdep->a0_base == -1)
|
||||
fprintf_unfiltered (log, _("\n\ta0_base: No Ax registers"));
|
||||
|
||||
buf = ui_file_xstrdup (log, &dummy);
|
||||
buf = ui_file_xstrdup (log, &length);
|
||||
make_cleanup (xfree, buf);
|
||||
if (strlen (buf) > 0)
|
||||
if (length > 0)
|
||||
internal_error (__FILE__, __LINE__,
|
||||
_("the following are invalid: %s"), buf);
|
||||
do_cleanups (cleanups);
|
||||
|
|
Loading…
Add table
Reference in a new issue