* [PATCH] Remove some calls to malloc_failure
@ 2019-12-10 20:35 Tom Tromey
2019-12-11 1:25 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2019-12-10 20:35 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I noticed a couple of spots that call malloc_failure, but that don't
need to.
* In xml-support.c, "concat" uses xmalloc, so cannot return NULL.
* In utils.c, "buildargv" also uses xmalloc, so can only return NULL
if the argument is empty.
Tested by the buildbot.
gdb/ChangeLog
2019-12-10 Tom Tromey <tromey@adacore.com>
* xml-support.c (xml_fetch_content_from_file): Don't call
malloc_failure.
* utils.h (class gdb_argv): Remove malloc_failure comment.
* utils.c (gdb_argv::reset): Don't call malloc_failure.
Change-Id: I59483620deb6609ccf2f024d94a29113bb62d1a9
---
gdb/ChangeLog | 7 +++++++
gdb/utils.c | 3 ---
gdb/utils.h | 5 +----
gdb/xml-support.c | 2 --
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/gdb/utils.c b/gdb/utils.c
index f7fae35729b..0b8ec02abe6 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3033,9 +3033,6 @@ gdb_argv::reset (const char *s)
{
char **argv = buildargv (s);
- if (s != NULL && argv == NULL)
- malloc_failure (0);
-
freeargv (m_argv);
m_argv = argv;
}
diff --git a/gdb/utils.h b/gdb/utils.h
index c8337f23017..71860191403 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -146,10 +146,7 @@ public:
}
/* A constructor that calls buildargv on STR. STR may be NULL, in
- which case this object is initialized with a NULL array. If
- buildargv fails due to out-of-memory, call malloc_failure.
- Therefore, the value is guaranteed to be non-NULL, unless the
- parameter itself is NULL. */
+ which case this object is initialized with a NULL array. */
explicit gdb_argv (const char *str)
: m_argv (NULL)
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 915be76066d..f5a14275457 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -977,8 +977,6 @@ xml_fetch_content_from_file (const char *filename, void *baton)
{
char *fullname = concat (dirname, "/", filename, (char *) NULL);
- if (fullname == NULL)
- malloc_failure (0);
file = gdb_fopen_cloexec (fullname, FOPEN_RT);
xfree (fullname);
}
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Remove some calls to malloc_failure
2019-12-10 20:35 [PATCH] Remove some calls to malloc_failure Tom Tromey
@ 2019-12-11 1:25 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2019-12-11 1:25 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2019-12-10 3:35 p.m., Tom Tromey wrote:
> I noticed a couple of spots that call malloc_failure, but that don't
> need to.
>
> * In xml-support.c, "concat" uses xmalloc, so cannot return NULL.
>
> * In utils.c, "buildargv" also uses xmalloc, so can only return NULL
> if the argument is empty.
>
> Tested by the buildbot.
Thanks, that LGTM.
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-11 1:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 20:35 [PATCH] Remove some calls to malloc_failure Tom Tromey
2019-12-11 1:25 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).