[parted-devel] Re: Patch against SVN (1.8.0rc2): number two
David Cantrell
dcantrell at redhat.com
Tue Oct 31 20:19:52 CET 2006
Debarshi 'Rishi' Ray wrote:
> Here is a patch (diff -urNp) against the whole 1.8.0rc2 trunk
> directory. It includes the previous patch against parted/parted.c
> which I had sent. So if that is not applied, you only need to apply
> this one.
>
> It mainly deals with the following new points:
>
> 1. libparted/arch/linux.c -->> a. readFD does not need to allocate
> 16384 bytes (= 16KB) initially to read /proc/devices. It is merely an
> ASCII file, which lists the major device numbers of all the devices.
> It is highly imporabable (if not impossible) for it to be larger than
> 2KB. The extra memory requirement might lead to a 'memory allocation
> error/failure' in memory-starved systems. Hence I have shortenend it
> to 1024 bytes (=1KB).
That function came from nash(8) in RH, which also reads
/proc/partitions. That file can definitely get huge on big systems,
hence the 16KB buffer. Here it's unnecessary, but doesn't really
matter. I'll apply the diff.
> b. It is better to set filesize to zero during initialization. Would
> be faster that way.
>
> c. We can combine the error and EOF encountered by 'read' conditions.
>
> d. Before finishing off the excess memory needs to be realeased, and
> it would be good idea to set the byte following the last character to
> NULL.
>
> e. Calloc becomes uneccessary now. Moreover, realloc does not
> initialize the locations to zero, so it does not make any difference
> as compared to malloc.
>
> 2. libparted/arch/linux.c -->> a. _is_dm_major can be trimmed a bit.
>
> 3. libparted/device.c -->> a. canonicalize_file_name does a calloc,
> which should use sizeof(char) instead of 1.
Applied.
Thanks for all the fixes! I'm going to push out an rc3 here shortly
because we have some other bug fixes included now. I'd also like
mention: Be careful with your ioctl() calls. If you are making changes
involving ioctl() calls, be sure to pass arguments if the particular
ioctl is expecting them.
--
David Cantrell
Red Hat / Westford, MA
More information about the parted-devel
mailing list