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.
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)
swap_uid();
fp = fdopen(fds[1], "w");
if (!fp)
- die_out_of_memory();
+ perror_msg_and_die("fdopen");
return fp;
}
#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);
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;
#include "defs.h"
-void die_out_of_memory(void)
+static void die_out_of_memory(void)
{
static bool recursed;