diff options
Diffstat (limited to 'src/analysis/contents/file.c')
-rw-r--r-- | src/analysis/contents/file.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/analysis/contents/file.c b/src/analysis/contents/file.c index 3519be3..31acb6f 100644 --- a/src/analysis/contents/file.c +++ b/src/analysis/contents/file.c @@ -354,14 +354,18 @@ GBinContent *g_file_content_new_from_xml(xmlXPathContextPtr context, const char /* Chargement */ - absolute = build_absolute_filename(base, filename); + if (filename != NULL) + { + absolute = build_absolute_filename(base, filename); - if (filename != NULL) free(filename); + free(filename); + + if (absolute != NULL) + { + result = g_file_content_new(absolute); + free(absolute); + } - if (absolute != NULL) - { - result = g_file_content_new(absolute); - free(absolute); } return result; @@ -428,11 +432,10 @@ static bool g_file_content_save(const GFileContent *content, xmlDocPtr xdoc, xml char *access; /* Chemin d'accès à un élément */ char *relative; /* Chemin d'accès relatif */ - result = true; - /* Type */ - result &= add_string_attribute_to_node(xdoc, context, path, "type", "file"); + result = add_string_attribute_to_node(xdoc, context, path, "type", "file"); + if (!result) goto gfcs_exit; /* Nom du fichier associé */ @@ -441,11 +444,13 @@ static bool g_file_content_save(const GFileContent *content, xmlDocPtr xdoc, xml relative = build_relative_filename(base, content->filename); - result &= add_content_to_node(xdoc, context, access, relative); + result = add_content_to_node(xdoc, context, access, relative); free(relative); free(access); + gfcs_exit: + return result; } @@ -530,19 +535,26 @@ static void g_file_content_compute_end_pos(const GFileContent *content, vmpa2t * static bool g_file_content_seek(const GFileContent *content, vmpa2t *addr, phys_t length) { + bool result; /* Bilan à retourner */ phys_t offset; /* Emplacement de départ */ + result = false; + offset = get_phy_addr(addr); if (length > get_mrange_length(&content->range)) - return false; + goto gfcs_done; if (offset > (get_mrange_length(&content->range) - length)) - return false; + goto gfcs_done; advance_vmpa(addr, length); - return true; + result = true; + + gfcs_done: + + return result; } @@ -563,6 +575,7 @@ static bool g_file_content_seek(const GFileContent *content, vmpa2t *addr, phys_ static const bin_t *g_file_content_get_raw_access(const GFileContent *content, vmpa2t *addr, phys_t length) { + const bin_t *result; /* Données utiles à renvoyer */ phys_t offset; /* Emplacement de départ */ bool allowed; /* Capacité d'avancer ? */ @@ -570,7 +583,9 @@ static const bin_t *g_file_content_get_raw_access(const GFileContent *content, v allowed = g_file_content_seek(content, addr, length); - return (allowed ? &content->data[offset] : NULL); + result = (allowed ? &content->data[offset] : NULL); + + return result; } |