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, |
966 | 966 | struct archive *archive; |
967 | 967 | char *q, *mpath; |
968 | 968 | struct entry *entry; |
969 | | int result = -1; |
970 | 969 | |
971 | 970 | mpath = g_strdup (path); |
972 | 971 | |
973 | 972 | q = extfs_get_path_mangle (me, mpath, &archive, FALSE); |
| 973 | g_free (mpath); |
974 | 974 | if (q == NULL) |
975 | | goto cleanup; |
| 975 | return -1; |
| 976 | |
976 | 977 | entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); |
977 | 978 | if (entry == NULL) |
978 | | goto cleanup; |
| 979 | return -1; |
| 980 | |
979 | 981 | if (resolve) { |
980 | 982 | entry = extfs_resolve_symlinks (entry); |
981 | 983 | if (entry == NULL) |
982 | | goto cleanup; |
| 984 | return -1; |
983 | 985 | } |
984 | 986 | extfs_stat_move (buf, entry->inode); |
985 | | result = 0; |
986 | | cleanup: |
987 | | g_free (mpath); |
988 | | return result; |
| 987 | return 0; |
989 | 988 | } |
990 | 989 | |
991 | 990 | static int |
… |
… |
extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) |
1016 | 1015 | char *q, *mpath; |
1017 | 1016 | size_t len; |
1018 | 1017 | struct entry *entry; |
1019 | | int result = -1; |
1020 | 1018 | |
1021 | 1019 | mpath = g_strdup (path); |
1022 | 1020 | |
1023 | 1021 | 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 | |
1026 | 1026 | entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); |
1027 | 1027 | if (entry == NULL) |
1028 | | goto cleanup; |
| 1028 | return -1; |
| 1029 | |
1029 | 1030 | if (!S_ISLNK (entry->inode->mode)) { |
1030 | 1031 | me->verrno = EINVAL; |
1031 | | goto cleanup; |
| 1032 | return -1; |
1032 | 1033 | } |
1033 | 1034 | len = strlen (entry->inode->linkname); |
1034 | 1035 | if (size < len) |
1035 | 1036 | len = size; |
1036 | 1037 | /* 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; |
1042 | 1041 | } |
1043 | 1042 | |
1044 | 1043 | static int |
… |
… |
extfs_unlink (struct vfs_class *me, const char *file) |
1075 | 1074 | struct archive *archive; |
1076 | 1075 | char *q, *mpath; |
1077 | 1076 | struct entry *entry; |
1078 | | int result = -1; |
1079 | 1077 | |
1080 | 1078 | mpath = g_strdup (file); |
1081 | 1079 | |
1082 | 1080 | q = extfs_get_path_mangle (me, mpath, &archive, FALSE); |
| 1081 | g_free (mpath); |
1083 | 1082 | if (q == NULL) |
1084 | | goto cleanup; |
| 1083 | return -1; |
| 1084 | |
1085 | 1085 | entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); |
1086 | 1086 | if (entry == NULL) |
1087 | | goto cleanup; |
| 1087 | return -1; |
| 1088 | |
1088 | 1089 | entry = extfs_resolve_symlinks (entry); |
1089 | 1090 | if (entry == NULL) |
1090 | | goto cleanup; |
| 1091 | return -1; |
| 1092 | |
1091 | 1093 | if (S_ISDIR (entry->inode->mode)) { |
1092 | 1094 | me->verrno = EISDIR; |
1093 | | goto cleanup; |
| 1095 | return -1; |
1094 | 1096 | } |
1095 | 1097 | if (extfs_cmd (" rm ", archive, entry, "")) { |
1096 | 1098 | my_errno = EIO; |
1097 | | goto cleanup; |
| 1099 | return -1; |
1098 | 1100 | } |
1099 | 1101 | extfs_remove_entry (entry); |
1100 | | result = 0; |
1101 | | cleanup: |
1102 | | g_free (mpath); |
1103 | | return result; |
| 1102 | return 0; |
1104 | 1103 | } |
1105 | 1104 | |
1106 | 1105 | static int |
… |
… |
extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) |
1109 | 1108 | struct archive *archive; |
1110 | 1109 | char *q, *mpath; |
1111 | 1110 | struct entry *entry; |
1112 | | int result = -1; |
1113 | 1111 | |
1114 | 1112 | (void) mode; |
1115 | 1113 | |
1116 | 1114 | mpath = g_strdup (path); |
1117 | 1115 | |
1118 | 1116 | q = extfs_get_path_mangle (me, mpath, &archive, FALSE); |
| 1117 | g_free (mpath); |
1119 | 1118 | if (q == NULL) |
1120 | | goto cleanup; |
| 1119 | return -1; |
| 1120 | |
1121 | 1121 | entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); |
1122 | 1122 | if (entry != NULL) { |
1123 | 1123 | me->verrno = EEXIST; |
1124 | | goto cleanup; |
| 1124 | return -1; |
1125 | 1125 | } |
1126 | 1126 | entry = extfs_find_entry (archive->root_entry, q, TRUE, FALSE); |
1127 | 1127 | if (entry == NULL) |
1128 | | goto cleanup; |
| 1128 | return -1; |
| 1129 | |
1129 | 1130 | entry = extfs_resolve_symlinks (entry); |
1130 | 1131 | if (entry == NULL) |
1131 | | goto cleanup; |
| 1132 | return -1; |
| 1133 | |
1132 | 1134 | if (!S_ISDIR (entry->inode->mode)) { |
1133 | 1135 | me->verrno = ENOTDIR; |
1134 | | goto cleanup; |
| 1136 | return -1; |
1135 | 1137 | } |
1136 | 1138 | |
1137 | 1139 | if (extfs_cmd (" mkdir ", archive, entry, "")) { |
1138 | 1140 | my_errno = EIO; |
1139 | 1141 | extfs_remove_entry (entry); |
1140 | | goto cleanup; |
| 1142 | return -1; |
1141 | 1143 | } |
1142 | | result = 0; |
1143 | | cleanup: |
1144 | | g_free (mpath); |
1145 | | return result; |
| 1144 | return 0; |
1146 | 1145 | } |
1147 | 1146 | |
1148 | 1147 | static int |
… |
… |
extfs_rmdir (struct vfs_class *me, const char *path) |
1151 | 1150 | struct archive *archive; |
1152 | 1151 | char *q, *mpath; |
1153 | 1152 | struct entry *entry; |
1154 | | int result = -1; |
1155 | 1153 | |
1156 | 1154 | mpath = g_strdup (path); |
1157 | 1155 | |
1158 | 1156 | q = extfs_get_path_mangle (me, mpath, &archive, FALSE); |
| 1157 | g_free (mpath); |
1159 | 1158 | if (q == NULL) |
1160 | | goto cleanup; |
| 1159 | return -1; |
| 1160 | |
1161 | 1161 | entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE); |
1162 | 1162 | if (entry == NULL) |
1163 | | goto cleanup; |
| 1163 | return -1; |
| 1164 | |
1164 | 1165 | entry = extfs_resolve_symlinks (entry); |
1165 | 1166 | if (entry == NULL) |
1166 | | goto cleanup; |
| 1167 | return -1; |
| 1168 | |
1167 | 1169 | if (!S_ISDIR (entry->inode->mode)) { |
1168 | 1170 | me->verrno = ENOTDIR; |
1169 | | goto cleanup; |
| 1171 | return -1; |
1170 | 1172 | } |
1171 | | |
1172 | 1173 | if (extfs_cmd (" rmdir ", archive, entry, "")) { |
1173 | 1174 | my_errno = EIO; |
1174 | | goto cleanup; |
| 1175 | return -1; |
1175 | 1176 | } |
1176 | 1177 | extfs_remove_entry (entry); |
1177 | | result = 0; |
1178 | | cleanup: |
1179 | | g_free (mpath); |
1180 | | return result; |
| 1178 | return 0; |
1181 | 1179 | } |
1182 | 1180 | |
1183 | 1181 | static int |