Patchwork e2fsck: show size requested when memory allocation fails

login
register
mail settings
Submitter Eric Sandeen
Date Jan. 7, 2013, 9:45 p.m.
Message ID <50EB4212.9080601@redhat.com>
Download mbox | patch
Permalink /patch/210242/
State Accepted
Headers show

Comments

Eric Sandeen - Jan. 7, 2013, 9:45 p.m.
"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>
---


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o - Jan. 8, 2013, 3:41 p.m.
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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

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