mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 00:32:30 +08:00
sim: hw: rework code to avoid gcc warnings
Newer gcc thinks we might return a pointer to a stack buffer, but we don't -- we strdup it before returning. Rework the code to just malloc the buffer from the start and avoid the stack+strdup.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2021-01-09 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* hw-base.c (full_name_of_hw): Delete full_name. Replace
|
||||||
|
hw_strdup call with hw_malloc.
|
||||||
|
|
||||||
2021-01-09 Mike Frysinger <vapier@gentoo.org>
|
2021-01-09 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
* cgen-par.c: Include stdlib.h.
|
* cgen-par.c: Include stdlib.h.
|
||||||
|
@ -281,11 +281,10 @@ full_name_of_hw (struct hw *leaf,
|
|||||||
unsigned sizeof_buf)
|
unsigned sizeof_buf)
|
||||||
{
|
{
|
||||||
/* get a buffer */
|
/* get a buffer */
|
||||||
char full_name[1024];
|
if (buf == NULL)
|
||||||
if (buf == (char*)0)
|
|
||||||
{
|
{
|
||||||
buf = full_name;
|
sizeof_buf = 1024;
|
||||||
sizeof_buf = sizeof (full_name);
|
buf = hw_malloc (leaf, sizeof_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use head recursion to construct the path */
|
/* use head recursion to construct the path */
|
||||||
@ -318,9 +317,6 @@ full_name_of_hw (struct hw *leaf,
|
|||||||
strcat (buf, unit);
|
strcat (buf, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return it usefully */
|
|
||||||
if (buf == full_name)
|
|
||||||
buf = hw_strdup (leaf, full_name);
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user