[syslinux] [PATCH 1/4 v2] com32/lib/: Avoid unneeded allocation.
Matt Fleming
matt at console-pimps.org
Mon Sep 30 06:21:59 PDT 2013
On Tue, 17 Sep, at 04:42:24PM, Raphael S.Carvalho wrote:
> eparam would only be used if EBIOS is available.
> If it is not, then there is no reason to allocate eparam.
>
> Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com>
> ---
> com32/lib/syslinux/disk.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
> index 093751a..d96acbf 100644
> --- a/com32/lib/syslinux/disk.c
> +++ b/com32/lib/syslinux/disk.c
> @@ -73,7 +73,7 @@ int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg)
> int disk_get_params(int disk, struct disk_info *const diskinfo)
> {
> static com32sys_t inreg, outreg;
> - struct disk_ebios_eparam *eparam;
> + struct disk_ebios_eparam *eparam = NULL;
> int rv = 0;
>
> memset(diskinfo, 0, sizeof *diskinfo);
> @@ -94,12 +94,12 @@ int disk_get_params(int disk, struct disk_info *const diskinfo)
> diskinfo->ebios = 1;
> }
>
> - eparam = lmalloc(sizeof *eparam);
> - if (!eparam)
> - return -1;
> -
> /* Get extended disk parameters if ebios == 1 */
> if (diskinfo->ebios) {
> + eparam = lmalloc(sizeof *eparam);
> + if (!eparam)
> + return -1;
> +
> memset(&inreg, 0, sizeof inreg);
> inreg.eax.b[1] = 0x48;
> inreg.edx.b[0] = disk;
It would be better to move the lfree(), and in fact the declaration of
'eparam' under...
if (diskbios->ebios) {
struct disk_ebios_eparam *eparam;
eparam = lmalloc();
...
lfree(eparam);
}
since it's not used anywhere else. Make sense?
--
Matt Fleming, Intel Open Source Technology Center
More information about the Syslinux
mailing list