linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH] e2fsck: show size requested when memory allocation fails
Date: Mon, 07 Jan 2013 15:45:54 -0600	[thread overview]
Message-ID: <50EB4212.9080601@redhat.com> (raw)

"e2fsck: Can't allocate dx_block info array"
is only so helpful - it'd be nice to know how much it tried to allocate.

In particular, since I think malloc(0) can return NULL,
it'd be nice to know if maybe we passed in an uninitialized (or
0-initialized) size.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/e2fsck/util.c b/e2fsck/util.c
index a808eec..6242954 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -121,7 +121,8 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
 #endif
 	ret = malloc(size);
 	if (!ret) {
-		sprintf(buf, "Can't allocate %s\n", description);
+		sprintf(buf, "Can't allocate %u bytes for %s\n",
+			size, description);
 		fatal_error(ctx, buf);
 	}
 	memset(ret, 0, size);


             reply	other threads:[~2013-01-07 21:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 21:45 Eric Sandeen [this message]
2013-01-08 15:41 ` [PATCH] e2fsck: show size requested when memory allocation fails Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50EB4212.9080601@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).