On 9/6/07, Jim Meyering <[EMAIL PROTECTED]> wrote:
> "Frodo Baggins" <[EMAIL PROTECTED]> wrote:
> > Is this safe/desirable?
>
> Thanks for working on the code.
>
> However, please don't mix two types of changes like this.
> A global-substitution change like s/((m|re)alloc|free)/ped_$1/, belongs
> in a change set all by itself. BTW, I'm luke-warm on that change,
> but won't object outright. I don't see much to gain by using the
> ped_ wrappers. IMHO, if it's worth using the ped_-prefixed allocation
> functions everywhere, then it's also worth writing a "make distcheck"
> rule (add it to Makefile.maint) to enforce the policy that all uses of
> malloc/calloc/realloc be through the ped_-prefixed functions.
>
> Uh oh... I just looked at the definitions of ped_realloc and ped_malloc
> and see that they call ped_exception_throw upon error. Ick. Worse
> still, ped_realloc returns 0/1, so your s/realloc/ped_realloc/ change
> would actually cause some serious damage. IMHO, ped_realloc should be
> eliminated altogether (there are only a handful of uses) or changed to
> have its signature match that of realloc.
I am looking into this.
>
> I think it would be worthwhile (long term) to convert the other way,
> e.g., ped_free -> free, ped_malloc -> malloc, etc.
>
> --------------------------
> For the other part, why do you want to remove uses of alloca?
> Is the struct too large for someone's stack?
> Is there some portability problem? Removing alloca is often
> an improvement, but it's best to be able to justify introducing
> a new way to fail.
>
How about this? Added this in a local branch.
>From d2326864f15b579cbc3324d29afe1f733706e10e Mon Sep 17 00:00:00 2001
From: Frodo Baggins <[EMAIL PROTECTED]>
Date: Sun, 9 Sep 2007 03:19:04 +0530
Subject: [PATCH] Remove use of alloca in libparted/arch/linux.c
alloca is system-specific and usually not recommended. Hence
substituting it with static allocation.
---
libparted/arch/linux.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 648bd2b..0c97796 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2214,7 +2214,7 @@ static int
_dm_is_part (struct dm_info *this, char *name)
{
struct dm_task* task = NULL;
- struct dm_info* info = alloca(sizeof *info);
+ struct dm_info info;
struct dm_deps* deps = NULL;
int rc = 0;
unsigned int i;
@@ -2231,9 +2231,9 @@ _dm_is_part (struct dm_info *this, char
}
rc = 0;
- memset(info, '\0', sizeof *info);
- dm_task_get_info(task, info);
- if (!info->exists)
+ memset(&info, '\0', sizeof (struct dm_info));
+ dm_task_get_info(task, &info);
+ if (!info.exists)
goto err;
deps = dm_task_get_deps(task);
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel