linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e2fsck: show size requested when memory allocation fails
@ 2013-01-07 21:45 Eric Sandeen
  2013-01-08 15:41 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2013-01-07 21:45 UTC (permalink / raw)
  To: ext4 development

"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);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] e2fsck: show size requested when memory allocation fails
  2013-01-07 21:45 [PATCH] e2fsck: show size requested when memory allocation fails Eric Sandeen
@ 2013-01-08 15:41 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-01-08 15:41 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development

On Mon, Jan 07, 2013 at 03:45:54PM -0600, Eric Sandeen wrote:
> "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>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-08 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 21:45 [PATCH] e2fsck: show size requested when memory allocation fails Eric Sandeen
2013-01-08 15:41 ` Theodore Ts'o

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).