Remove some calls to malloc_failure
authorTom Tromey <tromey@adacore.com>
Tue, 10 Dec 2019 18:19:23 +0000 (11:19 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 12 Dec 2019 19:36:57 +0000 (12:36 -0700)
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-12  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
gdb/utils.c
gdb/utils.h
gdb/xml-support.c

index 766cff499e3666c604d3ed3ab334400f670e29a9..2ffc3334feab9bf52c60629a2f45b9843fec9a03 100644 (file)
@@ -1,3 +1,10 @@
+2019-12-12  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.
+
 2019-12-12  Tom Tromey  <tromey@adacore.com>
 
        * Makefile.in (ALL_TARGET_OBS): Add riscv-ravenscar-thread.o.
index f7fae35729b7cfb4d4573b68616a174b1fba66c5..0b8ec02abe6668c2ed59604335311248ea240592 100644 (file)
@@ -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;
 }
index c8337f2301790b7bb4e481530d9f6e55747b53d4..71860191403508bbf706f4c2a6a0ab4e3269e1f7 100644 (file)
@@ -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)
index 915be76066d9fce8003a6b3b4a60ea2354432515..f5a142754578e18572874406258cb2e2c0d0fcc0 100644 (file)
@@ -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);
     }
This page took 0.032474 seconds and 4 git commands to generate.