Unexport die_out_of_memory

Print more specific error diagnostics than a generic "Out of memory"
when an error happens outside xmalloc.c.

* defs.h (die_out_of_memory): Remove prototype.
* strace.c (strace_popen, init): Call perror_msg_and_die instead
of die_out_of_memory.
* unwind.c (unwind_tcb_init): Likewise.
* xmalloc.c (die_out_of_memory): Add static qualifier.
This commit is contained in:
Дмитрий Левин 2017-06-26 22:41:28 +00:00
parent 11621507fb
commit 2698d1d060
4 changed files with 4 additions and 5 deletions

1
defs.h
View File

@ -393,7 +393,6 @@ void error_msg_and_help(const char *fmt, ...)
ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
void perror_msg_and_die(const char *fmt, ...)
ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
void die_out_of_memory(void) ATTRIBUTE_NORETURN;
void *xmalloc(size_t size) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1));
void *xcalloc(size_t nmemb, size_t size)

View File

@ -566,7 +566,7 @@ strace_popen(const char *command)
swap_uid();
fp = fdopen(fds[1], "w");
if (!fp)
die_out_of_memory();
perror_msg_and_die("fdopen");
return fp;
}
@ -1750,7 +1750,7 @@ init(int argc, char *argv[])
#endif
case 'E':
if (putenv(optarg) < 0)
die_out_of_memory();
perror_msg_and_die("putenv");
break;
case 'I':
opt_intr = string_to_uint_upto(optarg, NUM_INTR_OPTS - 1);

View File

@ -113,7 +113,7 @@ unwind_tcb_init(struct tcb *tcp)
tcp->libunwind_ui = _UPT_create(tcp->pid);
if (!tcp->libunwind_ui)
die_out_of_memory();
perror_msg_and_die("_UPT_create");
tcp->queue = xmalloc(sizeof(*tcp->queue));
tcp->queue->head = NULL;

View File

@ -27,7 +27,7 @@
#include "defs.h"
void die_out_of_memory(void)
static void die_out_of_memory(void)
{
static bool recursed;