From d932bfcdea79780763831afad9ccacbefe909b67 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 9 Jun 2011 16:51:00 +0200 Subject: [PATCH] Replaced some large local variables by other means in libisofs/builder.c --- libisofs/aaip_0_2.c | 4 ++-- libisofs/builder.c | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libisofs/aaip_0_2.c b/libisofs/aaip_0_2.c index 7c57696..a0ed83e 100644 --- a/libisofs/aaip_0_2.c +++ b/libisofs/aaip_0_2.c @@ -4,10 +4,10 @@ Arbitrary Attribute Interchange Protocol , AAIP versions 0.2 , 1.0 , 2.0. Implementation of encoding and decoding xattr and ACL. - See test/aaip_0_2.h + See libisofs/aaip_0_2.h http://libburnia-project.org/wiki/AAIP - Copyright (c) 2009 Thomas Schmitt, libburnia project, GPLv2+ + Copyright (c) 2009 - 2011 Thomas Schmitt, libburnia project, GPLv2+ */ diff --git a/libisofs/builder.c b/libisofs/builder.c index ef509ce..66da392 100644 --- a/libisofs/builder.c +++ b/libisofs/builder.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2009 Thomas Schmitt + * Copyright (c) 2009 - 2011 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -20,6 +20,7 @@ #include "fsource.h" #include "image.h" #include "aaip_0_2.h" +#include "util.h" #include #include @@ -104,9 +105,11 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, char *name; unsigned char *aa_string = NULL; char *a_text = NULL, *d_text = NULL; + char *dest = NULL; + IsoSymlink *link; if (builder == NULL || src == NULL || node == NULL) { - return ISO_NULL_POINTER; + {ret = ISO_NULL_POINTER; goto ex;} } /* get info about source */ @@ -116,7 +119,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, ret = iso_file_source_lstat(src, &info); } if (ret < 0) { - return ret; + goto ex; } name = iso_file_source_get_name(src); @@ -157,9 +160,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, case S_IFLNK: { /* source is a symbolic link */ - char dest[LIBISOFS_NODE_PATH_MAX]; - IsoSymlink *link; - + LIBISO_ALLOC_MEM(dest, char, LIBISOFS_NODE_PATH_MAX); ret = iso_file_source_readlink(src, dest, LIBISOFS_NODE_PATH_MAX); if (ret < 0) { break; @@ -198,7 +199,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, if (ret < 0) { free(name); - return ret; + goto ex; } /* fill fields */ @@ -233,14 +234,17 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, if (ret == 1 && aa_string != NULL) { ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string); if (ret < 0) - return ret; + goto ex; } else if(aa_string != NULL) { free(aa_string); } *node = new; - return ISO_SUCCESS; + ret = ISO_SUCCESS; +ex:; + LIBISO_FREE_MEM(dest); + return ret; } static