Ticket #2057: 2057-lib-vfs-mc-vfs-extfs.c-UN-need-goto.patch

File 2057-lib-vfs-mc-vfs-extfs.c-UN-need-goto.patch, 5.2 KB (added by vit_r, 14 years ago)
  • lib/vfs/mc-vfs/extfs.c

    From bc9409a8799ee44f9d7f74fe1b5658d2750af64c Mon Sep 17 00:00:00 2001
    From: Vit Rosin <vit_r@list.ru>
    Date: Wed, 24 Feb 2010 19:15:44 +0000
    Subject: [PATCH]  lib/vfs/mc-vfs/extfs.c UN needed goto
    
    ---
     lib/vfs/mc-vfs/extfs.c |   98 +++++++++++++++++++++++------------------------
     1 files changed, 48 insertions(+), 50 deletions(-)
    
    diff --git a/lib/vfs/mc-vfs/extfs.c b/lib/vfs/mc-vfs/extfs.c
    index a8f086c..6d4076e 100644
    a b extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, 
    966966    struct archive *archive; 
    967967    char *q, *mpath; 
    968968    struct entry *entry; 
    969     int result = -1; 
    970969 
    971970    mpath = g_strdup (path); 
    972971 
    973972    q = extfs_get_path_mangle (me, mpath, &archive, FALSE); 
     973    g_free (mpath); 
    974974    if (q == NULL) 
    975         goto cleanup; 
     975        return -1; 
     976 
    976977    entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); 
    977978    if (entry == NULL) 
    978         goto cleanup; 
     979        return -1; 
     980 
    979981    if (resolve) { 
    980982        entry = extfs_resolve_symlinks (entry); 
    981983        if (entry == NULL) 
    982             goto cleanup; 
     984            return -1; 
    983985    } 
    984986    extfs_stat_move (buf, entry->inode); 
    985     result = 0; 
    986 cleanup: 
    987     g_free (mpath); 
    988     return result; 
     987    return 0; 
    989988} 
    990989 
    991990static int 
    extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) 
    10161015    char *q, *mpath; 
    10171016    size_t len; 
    10181017    struct entry *entry; 
    1019     int result = -1; 
    10201018 
    10211019    mpath = g_strdup (path); 
    10221020 
    10231021    q = extfs_get_path_mangle (me, mpath, &archive, FALSE); 
    1024     if (q  == NULL) 
    1025         goto cleanup; 
     1022    g_free (mpath); 
     1023    if (q == NULL) 
     1024        return -1; 
     1025 
    10261026    entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); 
    10271027    if (entry == NULL) 
    1028         goto cleanup; 
     1028        return -1; 
     1029 
    10291030    if (!S_ISLNK (entry->inode->mode)) { 
    10301031        me->verrno = EINVAL; 
    1031         goto cleanup; 
     1032        return -1; 
    10321033    } 
    10331034    len = strlen (entry->inode->linkname); 
    10341035    if (size < len) 
    10351036       len = size; 
    10361037    /* readlink() does not append a NUL character to buf */ 
    1037     result = len; 
    1038     memcpy (buf, entry->inode->linkname, result); 
    1039 cleanup: 
    1040     g_free (mpath); 
    1041     return result; 
     1038    memcpy (buf, entry->inode->linkname, len); 
     1039 
     1040    return len; 
    10421041} 
    10431042 
    10441043static int 
    extfs_unlink (struct vfs_class *me, const char *file) 
    10751074    struct archive *archive; 
    10761075    char *q, *mpath; 
    10771076    struct entry *entry; 
    1078     int result = -1; 
    10791077 
    10801078    mpath = g_strdup (file); 
    10811079 
    10821080    q = extfs_get_path_mangle (me, mpath, &archive, FALSE); 
     1081    g_free (mpath); 
    10831082    if (q == NULL) 
    1084         goto cleanup; 
     1083        return -1; 
     1084 
    10851085    entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); 
    10861086    if (entry == NULL) 
    1087         goto cleanup; 
     1087        return -1; 
     1088 
    10881089    entry = extfs_resolve_symlinks (entry); 
    10891090    if (entry == NULL) 
    1090         goto cleanup; 
     1091        return -1; 
     1092 
    10911093    if (S_ISDIR (entry->inode->mode)) { 
    10921094        me->verrno = EISDIR; 
    1093         goto cleanup; 
     1095        return -1; 
    10941096    } 
    10951097    if (extfs_cmd (" rm ", archive, entry, "")) { 
    10961098        my_errno = EIO; 
    1097         goto cleanup; 
     1099        return -1; 
    10981100    } 
    10991101    extfs_remove_entry (entry); 
    1100     result = 0; 
    1101 cleanup: 
    1102     g_free (mpath); 
    1103     return result; 
     1102    return 0; 
    11041103} 
    11051104 
    11061105static int 
    extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) 
    11091108    struct archive *archive; 
    11101109    char *q, *mpath; 
    11111110    struct entry *entry; 
    1112     int result = -1; 
    11131111 
    11141112    (void) mode; 
    11151113 
    11161114    mpath = g_strdup (path); 
    11171115 
    11181116    q = extfs_get_path_mangle (me, mpath, &archive, FALSE); 
     1117    g_free (mpath); 
    11191118    if (q == NULL) 
    1120         goto cleanup; 
     1119        return -1; 
     1120 
    11211121    entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); 
    11221122    if (entry != NULL) { 
    11231123        me->verrno = EEXIST; 
    1124         goto cleanup; 
     1124        return -1; 
    11251125    } 
    11261126    entry = extfs_find_entry (archive->root_entry, q, TRUE, FALSE); 
    11271127    if (entry == NULL) 
    1128         goto cleanup; 
     1128        return -1; 
     1129 
    11291130    entry = extfs_resolve_symlinks (entry); 
    11301131    if (entry == NULL) 
    1131         goto cleanup; 
     1132        return -1; 
     1133 
    11321134    if (!S_ISDIR (entry->inode->mode)) { 
    11331135        me->verrno = ENOTDIR; 
    1134         goto cleanup; 
     1136        return -1; 
    11351137    } 
    11361138 
    11371139    if (extfs_cmd (" mkdir ", archive, entry, "")) { 
    11381140        my_errno = EIO; 
    11391141        extfs_remove_entry (entry); 
    1140         goto cleanup; 
     1142        return -1; 
    11411143    } 
    1142     result = 0; 
    1143 cleanup: 
    1144     g_free (mpath); 
    1145     return result; 
     1144    return 0; 
    11461145} 
    11471146 
    11481147static int 
    extfs_rmdir (struct vfs_class *me, const char *path) 
    11511150    struct archive *archive; 
    11521151    char *q, *mpath; 
    11531152    struct entry *entry; 
    1154     int result = -1; 
    11551153 
    11561154    mpath = g_strdup (path); 
    11571155 
    11581156    q = extfs_get_path_mangle (me, mpath, &archive, FALSE); 
     1157    g_free (mpath); 
    11591158    if (q == NULL) 
    1160         goto cleanup; 
     1159        return -1; 
     1160 
    11611161    entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); 
    11621162    if (entry == NULL) 
    1163         goto cleanup; 
     1163        return -1; 
     1164 
    11641165    entry = extfs_resolve_symlinks (entry); 
    11651166    if (entry == NULL) 
    1166         goto cleanup; 
     1167        return -1; 
     1168 
    11671169    if (!S_ISDIR (entry->inode->mode)) { 
    11681170        me->verrno = ENOTDIR; 
    1169         goto cleanup; 
     1171        return -1; 
    11701172    } 
    1171  
    11721173    if (extfs_cmd (" rmdir ", archive, entry, "")) { 
    11731174        my_errno = EIO; 
    1174         goto cleanup; 
     1175        return -1; 
    11751176    } 
    11761177    extfs_remove_entry (entry); 
    1177     result = 0; 
    1178 cleanup: 
    1179     g_free (mpath); 
    1180     return result; 
     1178    return 0; 
    11811179} 
    11821180 
    11831181static int