-
From 843abe6f277cd144f285c222c63ec4cdbd762df3 Mon Sep 17 00:00:00 2001
From: Vit Rosin <vit_r@list.ru>
Date: Wed, 30 Dec 2009 19:53:45 +0000
Subject: [PATCH] getting out assignments(X = foo) from some if-calls
---
edit/choosesyntax.c | 4 +-
edit/edit.c | 12 +++++---
edit/editcmd.c | 15 +++++++---
edit/editlock.c | 4 +-
edit/syntax.c | 16 +++++++----
src/background.c | 6 +++-
src/charsets.c | 6 +++-
src/complete.c | 11 +++++---
src/file.c | 6 ++--
src/filenot.c | 3 +-
src/hotlist.c | 24 +++++++++++-----
src/logging.c | 3 +-
src/main.c | 3 +-
src/mountlist.c | 6 +++-
src/pipethrough.c | 3 +-
src/subshell.c | 7 +++--
src/treestore.c | 8 +++---
src/user.c | 3 +-
src/util.c | 11 +++++---
src/utilunix.c | 12 +++++---
src/viewer/datasource.c | 3 +-
src/viewer/mcviewer.c | 3 +-
src/widget.c | 3 +-
vfs/cpio.c | 22 ++++++++++-----
vfs/direntry.c | 21 ++++++++++-----
vfs/extfs.c | 55 +++++++++++++++++++++++++-------------
vfs/fish.c | 24 +++++++++++-----
vfs/ftpfs.c | 66 ++++++++++++++++++++++++++--------------------
vfs/mcfs.c | 63 +++++++++++++++++++++++++++-----------------
vfs/mcserv.c | 35 +++++++++++++++---------
vfs/sfs.c | 7 +++-
vfs/tar.c | 6 +++-
vfs/undelfs.c | 9 ++++--
vfs/utilvfs.c | 13 ++++++---
vfs/vfs.c | 6 +++-
35 files changed, 314 insertions(+), 185 deletions(-)
diff --git a/edit/choosesyntax.c b/edit/choosesyntax.c
index 20df935..f06da24 100644
a
|
b
|
edit_syntax_dialog (void) { |
77 | 77 | edit_load_syntax (NULL, &names, NULL); |
78 | 78 | while (names[count++] != NULL); |
79 | 79 | qsort(names, count - 1, sizeof(char*), pstrcmp); |
80 | | |
81 | | if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) { |
| 80 | syntax = exec_edit_syntax_dialog ((const char**) names); |
| 81 | if (syntax < 0) { |
82 | 82 | for (i = 0; names[i]; i++) { |
83 | 83 | g_free (names[i]); |
84 | 84 | } |
-
diff --git a/edit/edit.c b/edit/edit.c
index 7a06d53..0ed4c9b 100644
a
|
b
|
edit_load_file_fast (WEdit *edit, const char *filename) |
294 | 294 | edit->curs2 = edit->last_byte; |
295 | 295 | buf2 = edit->curs2 >> S_EDIT_BUF_SIZE; |
296 | 296 | edit->utf8 = 0; |
297 | | if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) { |
| 297 | file = mc_open (filename, O_RDONLY | O_BINARY); |
| 298 | if (file == -1) { |
298 | 299 | GString *errmsg = g_string_new(NULL); |
299 | 300 | g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename); |
300 | 301 | edit_error_dialog (_("Error"), get_sys_error (errmsg->str)); |
… |
… |
int |
487 | 488 | edit_insert_file (WEdit *edit, const char *filename) |
488 | 489 | { |
489 | 490 | char *p; |
490 | | if ((p = edit_get_filter (filename))) { |
| 491 | p = edit_get_filter (filename); |
| 492 | if (p) { |
491 | 493 | FILE *f; |
492 | 494 | long current = edit->curs1; |
493 | 495 | f = (FILE *) popen (p, "r"); |
… |
… |
edit_insert_file (WEdit *edit, const char *filename) |
516 | 518 | long current = edit->curs1; |
517 | 519 | int vertical_insertion = 0; |
518 | 520 | char *buf; |
519 | | if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) |
| 521 | file = mc_open (filename, O_RDONLY | O_BINARY); |
| 522 | if (file == -1) |
520 | 523 | return 0; |
521 | 524 | buf = g_malloc0 (TEMP_BUF_LEN); |
522 | 525 | blocklen = mc_read (file, buf, sizeof(VERTICAL_MAGIC)); |
… |
… |
pop_action (WEdit * edit) |
1105 | 1108 | return STACK_BOTTOM; |
1106 | 1109 | } |
1107 | 1110 | sp = (sp - 1) & edit->stack_size_mask; |
1108 | | if ((c = edit->undo_stack[sp]) >= 0) { |
| 1111 | c = edit->undo_stack[sp]; |
| 1112 | if (c >= 0) { |
1109 | 1113 | /* edit->undo_stack[sp] = '@'; */ |
1110 | 1114 | edit->stack_pointer = (edit->stack_pointer - 1) & edit->stack_size_mask; |
1111 | 1115 | return c; |
-
diff --git a/edit/editcmd.c b/edit/editcmd.c
index b8c2cc6..2e6766a 100644
a
|
b
|
edit_save_file (WEdit *edit, const char *filename) |
267 | 267 | goto error_save; |
268 | 268 | |
269 | 269 | /* pipe save */ |
270 | | if ((p = edit_get_write_filter (savename, real_filename))) { |
| 270 | p = edit_get_write_filter (savename, real_filename); |
| 271 | if (p) { |
271 | 272 | FILE *file; |
272 | 273 | |
273 | 274 | mc_close (fd); |
… |
… |
edit_save_as_cmd (WEdit *edit) |
565 | 566 | if (strcmp (edit->filename, exp)) { |
566 | 567 | int file; |
567 | 568 | different_filename = 1; |
568 | | if ((file = mc_open (exp, O_RDONLY | O_BINARY)) != -1) { |
| 569 | file = mc_open (exp, O_RDONLY | O_BINARY); |
| 570 | if (file != -1) { |
569 | 571 | /* the file exists */ |
570 | 572 | mc_close (file); |
571 | 573 | /* Overwrite the current file or cancel the operation */ |
… |
… |
static FILE *edit_open_macro_file (const char *r) |
648 | 650 | FILE *fd; |
649 | 651 | int file; |
650 | 652 | filename = concat_dir_and_file (home_dir, EDIT_MACRO_FILE); |
651 | | if ((file = open (filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1){ |
| 653 | file = open (filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 654 | if (file == -1) { |
652 | 655 | g_free(filename); |
653 | 656 | return 0; |
654 | 657 | } |
… |
… |
edit_delete_macro (WEdit * edit, int k) |
688 | 691 | (void) edit; |
689 | 692 | |
690 | 693 | if (saved_macros_loaded) |
691 | | if ((j = macro_exists (k)) < 0) |
| 694 | j = macro_exists (k); |
| 695 | if (j < 0) |
692 | 696 | return 0; |
693 | 697 | tmp = concat_dir_and_file (home_dir, EDIT_TEMP_FILE); |
694 | 698 | g = fopen (tmp , "w"); |
… |
… |
int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) |
794 | 798 | if (macro_exists (k) < 0) |
795 | 799 | return 0; |
796 | 800 | |
797 | | if ((f = edit_open_macro_file ("r"))) { |
| 801 | f = edit_open_macro_file ("r"); |
| 802 | if (f) { |
798 | 803 | struct macro dummy; |
799 | 804 | do { |
800 | 805 | int u; |
-
diff --git a/edit/editlock.c b/edit/editlock.c
index 9199031..102c011 100644
a
|
b
|
lock_get_info (const char *lockfname) |
150 | 150 | { |
151 | 151 | int cnt; |
152 | 152 | static char buf[BUF_SIZE]; |
153 | | |
154 | | if ((cnt = readlink (lockfname, buf, BUF_SIZE - 1)) == -1 || !*buf) |
| 153 | cnt = readlink (lockfname, buf, BUF_SIZE - 1); |
| 154 | if (cnt == -1 || !(*buf)) |
155 | 155 | return NULL; |
156 | 156 | buf[cnt] = '\0'; |
157 | 157 | return buf; |
-
diff --git a/edit/syntax.c b/edit/syntax.c
index 7479483..a0fe9d6 100644
a
|
b
|
subst_defines (GTree *defines, char **argv, char **argv_end) |
146 | 146 | int argc; |
147 | 147 | |
148 | 148 | while (*argv && argv < argv_end) { |
149 | | if ((t = g_tree_lookup (defines, *argv))) { |
| 149 | t = g_tree_lookup (defines, *argv); |
| 150 | if (t) { |
150 | 151 | int count = 0; |
151 | 152 | |
152 | 153 | /* Count argv array members */ |
… |
… |
static struct syntax_rule apply_rules_going_right (WEdit * edit, long i, struct |
308 | 309 | int is_end; |
309 | 310 | long end = 0; |
310 | 311 | struct syntax_rule _rule = rule; |
311 | | |
312 | | if (!(c = edit_get_byte (edit, i))) |
| 312 | c = edit_get_byte (edit, i); |
| 313 | if (!c) |
313 | 314 | return rule; |
314 | 315 | is_end = (rule.end == (unsigned char) i); |
315 | 316 | |
… |
… |
static int read_one_line (char **line, FILE * f) |
533 | 534 | r++; |
534 | 535 | /* handle all of \r\n, \r, \n correctly. */ |
535 | 536 | if (c == '\r') { |
536 | | if ( (c = fgetc (f)) == '\n') |
| 537 | c = fgetc (f); |
| 538 | if (c == '\n') |
537 | 539 | r++; |
538 | 540 | else |
539 | 541 | ungetc (c, f); |
… |
… |
edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) |
927 | 929 | |
928 | 930 | if (argc < 3) |
929 | 931 | break_a; |
930 | | if ((argv = g_tree_lookup (edit->defines, key))) { |
| 932 | argv = g_tree_lookup (edit->defines, key); |
| 933 | if (argv) { |
931 | 934 | mc_defines_destroy (NULL, argv, NULL); |
932 | 935 | } else { |
933 | 936 | key = g_strdup (key); |
… |
… |
edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, |
1066 | 1069 | if (!found && !strcmp (args[0], "include")) { |
1067 | 1070 | if (g) |
1068 | 1071 | continue; |
1069 | | if (!args[1] || !(g = open_include_file (args[1]))) { |
| 1072 | g = open_include_file (args[1]); |
| 1073 | if (!args[1] || !g) { |
1070 | 1074 | result = line; |
1071 | 1075 | break; |
1072 | 1076 | } |
-
diff --git a/src/background.c b/src/background.c
index c34a95b..19dc79e 100644
a
|
b
|
do_background (struct FileOpContext *ctx, char *info) |
148 | 148 | if (pipe (back_comm) == -1) |
149 | 149 | return -1; |
150 | 150 | |
151 | | if ((pid = fork ()) == -1) { |
| 151 | pid = fork (); |
| 152 | if (pid == -1) { |
152 | 153 | int saved_errno = errno; |
153 | 154 | (void) close (comm[0]); |
154 | 155 | (void) close (comm[1]); |
… |
… |
do_background (struct FileOpContext *ctx, char *info) |
172 | 173 | close (1); |
173 | 174 | close (2); |
174 | 175 | |
175 | | if ((nullfd = open ("/dev/null", O_RDWR)) != -1) { |
| 176 | nullfd = open ("/dev/null", O_RDWR); |
| 177 | if (nullfd != -1) { |
176 | 178 | while (dup2 (nullfd, 0) == -1 && errno == EINTR); |
177 | 179 | while (dup2 (nullfd, 1) == -1 && errno == EINTR); |
178 | 180 | while (dup2 (nullfd, 2) == -1 && errno == EINTR); |
-
diff --git a/src/charsets.c b/src/charsets.c
index b374539..4b0ca95 100644
a
|
b
|
load_codepages_list (void) |
57 | 57 | char *default_codepage = NULL; |
58 | 58 | |
59 | 59 | fname = concat_dir_and_file (mc_home, CHARSETS_INDEX); |
60 | | if (!(f = fopen (fname, "r"))) { |
| 60 | f = fopen (fname, "r"); |
| 61 | if (!f) { |
61 | 62 | fprintf (stderr, _("Warning: file %s not found\n"), fname); |
62 | 63 | g_free (fname); |
63 | 64 | |
64 | 65 | fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX); |
65 | | if (!(f = fopen (fname, "r"))) { |
| 66 | f = fopen (fname, "r"); |
| 67 | if (!f) { |
66 | 68 | fprintf (stderr, _("Warning: file %s not found\n"), fname); |
67 | 69 | g_free (fname); |
68 | 70 | |
-
diff --git a/src/complete.c b/src/complete.c
index ef0dad8..118a1dc 100644
a
|
b
|
command_completion_function (const char *_text, int state, INPUT_COMPLETE_FLAGS |
564 | 564 | if (found == NULL) { |
565 | 565 | g_free (path); |
566 | 566 | path = NULL; |
567 | | } else if ((p = strrchr (found, PATH_SEP)) != NULL) { |
568 | | char *tmp = found; |
569 | | found = strutils_shell_escape (p + 1); |
570 | | g_free (tmp); |
| 567 | } else { |
| 568 | p = strrchr (found, PATH_SEP); |
| 569 | if (p != NULL) { |
| 570 | char *tmp = found; |
| 571 | found = strutils_shell_escape (p + 1); |
| 572 | g_free (tmp); |
| 573 | } |
571 | 574 | } |
572 | 575 | |
573 | 576 | g_free(text); |
-
diff --git a/src/file.c b/src/file.c
index c166320..cce15b1 100644
a
|
b
|
move_file_file (FileOpContext *ctx, const char *s, const char *d, |
1061 | 1061 | |
1062 | 1062 | if (!ctx->do_append) { |
1063 | 1063 | if (S_ISLNK (src_stats.st_mode) && ctx->stable_symlinks) { |
1064 | | if ((return_status = make_symlink (ctx, s, d)) == FILE_CONT) { |
| 1064 | return_status = make_symlink (ctx, s, d); |
| 1065 | if (return_status == FILE_CONT) |
1065 | 1066 | goto retry_src_remove; |
1066 | | } else |
1067 | | return return_status; |
| 1067 | return return_status; |
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | if (mc_rename (s, d) == 0) { |
-
diff --git a/src/filenot.c b/src/filenot.c
index 15a79c1..09b4b85 100644
a
|
b
|
my_mkdir_rec (char *s, mode_t mode) |
75 | 75 | q = vfs_canon (p); |
76 | 76 | g_free (p); |
77 | 77 | |
78 | | if (!(result = my_mkdir_rec (q, mode))) |
| 78 | result = my_mkdir_rec (q, mode); |
| 79 | if (!result) |
79 | 80 | result = mc_mkdir (s, mode); |
80 | 81 | |
81 | 82 | g_free (q); |
-
diff --git a/src/hotlist.c b/src/hotlist.c
index 03eafbe..f157a3c 100644
a
|
b
|
update_path_name (void) |
229 | 229 | do { \ |
230 | 230 | int i; \ |
231 | 231 | \ |
232 | | if ((i = strlen (current->label) + 3) > buflen) { \ |
| 232 | i = strlen (current->label) + 3; \ |
| 233 | if (i > buflen) { \ |
233 | 234 | g_free (buf); \ |
234 | 235 | buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \ |
235 | 236 | } \ |
… |
… |
again: |
1261 | 1262 | case '"': |
1262 | 1263 | while ((c = getc (hotlist_file)) != EOF && c != '"') { |
1263 | 1264 | if (c == '\\') |
1264 | | if ((c = getc (hotlist_file)) == EOF){ |
| 1265 | c = getc (hotlist_file); |
| 1266 | if (c == EOF) { |
1265 | 1267 | g_string_free (tkn_buf, TRUE); |
1266 | 1268 | return TKN_EOF; |
1267 | 1269 | } |
… |
… |
again: |
1273 | 1275 | ret = TKN_STRING; |
1274 | 1276 | break; |
1275 | 1277 | case '\\': |
1276 | | if ((c = getc (hotlist_file)) == EOF){ |
| 1278 | c = getc (hotlist_file); |
| 1279 | if (c == EOF) { |
1277 | 1280 | g_string_free (tkn_buf, TRUE); |
1278 | 1281 | return TKN_EOF; |
1279 | 1282 | } |
… |
… |
again: |
1307 | 1310 | |
1308 | 1311 | #define SKIP_TO_EOL { \ |
1309 | 1312 | int _tkn; \ |
1310 | | while ((_tkn = hot_next_token ()) != TKN_EOF && _tkn != TKN_EOL) ; \ |
| 1313 | _tkn = hot_next_token (); \ |
| 1314 | while (_tkn != TKN_EOF && _tkn != TKN_EOL) ; \ |
| 1315 | _tkn = hot_next_token (); \ |
1311 | 1316 | } |
1312 | 1317 | |
1313 | 1318 | #define CHECK_TOKEN(_TKN_) \ |
1314 | | if ((tkn = hot_next_token ()) != _TKN_) { \ |
| 1319 | tkn = hot_next_token (); \ |
| 1320 | if (tkn != _TKN_) { \ |
1315 | 1321 | hotlist_state.readonly = 1; \ |
1316 | 1322 | hotlist_state.file_error = 1; \ |
1317 | 1323 | while (tkn != TKN_EOL && tkn != TKN_EOF) \ |
1318 | 1324 | tkn = hot_next_token (); \ |
1319 | | break; \ |
| 1325 | break; \ |
1320 | 1326 | } |
1321 | 1327 | |
1322 | 1328 | static void |
… |
… |
load_hotlist (void) |
1461 | 1467 | */ |
1462 | 1468 | hotlist->directory = g_strdup ("Hotlist"); |
1463 | 1469 | |
1464 | | if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0) { |
| 1470 | hotlist_file = fopen (hotlist_file_name, "r"); |
| 1471 | if (hotlist_file == 0) { |
1465 | 1472 | int result; |
1466 | 1473 | |
1467 | 1474 | load_group (hotlist); |
… |
… |
int save_hotlist (void) |
1563 | 1570 | if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name) { |
1564 | 1571 | mc_util_make_backup_if_possible (hotlist_file_name, ".bak"); |
1565 | 1572 | |
1566 | | if ((hotlist_file = fopen (hotlist_file_name, "w")) != 0) { |
| 1573 | hotlist_file = fopen (hotlist_file_name, "w"); |
| 1574 | if (hotlist_file != 0) { |
1567 | 1575 | hot_save_group (hotlist); |
1568 | 1576 | fclose (hotlist_file); |
1569 | 1577 | stat (hotlist_file_name, &stat_buf); |
-
diff --git a/src/logging.c b/src/logging.c
index f8ed3de..92144b8 100644
a
|
b
|
mc_log(const char *fmt, ...) |
66 | 66 | if (is_logging_enabled()) { |
67 | 67 | va_start(args, fmt); |
68 | 68 | logfilename = g_strdup_printf("%s/%s/log", home_dir, MC_USERCONF_DIR); |
69 | | if ((f = fopen(logfilename, "a")) != NULL) { |
| 69 | f = fopen(logfilename, "a"); |
| 70 | if (f != NULL) { |
70 | 71 | (void)vfprintf(f, fmt, args); |
71 | 72 | (void)fclose(f); |
72 | 73 | } |
-
diff --git a/src/main.c b/src/main.c
index dd9dc25..0b732db 100644
a
|
b
|
get_parent_dir_name (const char *cwd, const char *lwd) |
434 | 434 | { |
435 | 435 | const char *p; |
436 | 436 | if (strlen (lwd) > strlen (cwd)) |
437 | | if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd) && |
| 437 | p = strrchr (lwd, PATH_SEP); |
| 438 | if (p && !strncmp (cwd, lwd, p - lwd) && |
438 | 439 | ((gsize)strlen (cwd) == (gsize) p - (gsize) lwd || (p == lwd && cwd[0] == PATH_SEP && |
439 | 440 | cwd[1] == '\0'))) { |
440 | 441 | return (p + 1); |
-
diff --git a/src/mountlist.c b/src/mountlist.c
index 847bf39..954980d 100644
a
|
b
|
read_filesystem_list(int need_fs_type, int all_fs) |
648 | 648 | |
649 | 649 | if (!getcwd(dir, _POSIX_PATH_MAX)) return (NULL); |
650 | 650 | |
651 | | if ((fd = open(dir, O_RDONLY)) == -1) return (NULL); |
| 651 | fd = open(dir, O_RDONLY); |
| 652 | if (fd == -1) return (NULL); |
652 | 653 | |
653 | 654 | i = disk_get_entry(fd, &de); |
654 | 655 | |
… |
… |
my_statfs (struct my_statfs *myfs_stats, const char *path) |
746 | 747 | struct mount_entry *entry; |
747 | 748 | struct fs_usage fs_use; |
748 | 749 | |
749 | | if ((entry = read_filesystem_list(0, 0)) != NULL) |
| 750 | entry = read_filesystem_list(0, 0); |
| 751 | if (entry != NULL) |
750 | 752 | { |
751 | 753 | get_fs_usage(entry->me_mountdir, &fs_use); |
752 | 754 | |
-
diff --git a/src/pipethrough.c b/src/pipethrough.c
index e31f816..af028bc 100644
a
|
b
|
extern int pipethrough(const char *command, |
393 | 393 | goto cleanup; |
394 | 394 | } |
395 | 395 | |
396 | | if ((pid = fork()) == (pid_t) -1) { |
| 396 | pid = fork(); |
| 397 | if (pid == (pid_t) -1) { |
397 | 398 | propagate(&firsterror, errno); |
398 | 399 | goto cleanup; |
399 | 400 | } |
-
diff --git a/src/subshell.c b/src/subshell.c
index a80f8a1..93017a2 100644
a
|
b
|
|
59 | 59 | #include "subshell.h" |
60 | 60 | #include "strutil.h" |
61 | 61 | #include "fileloc.h" |
62 | | |
63 | 62 | #include "../vfs/vfs.h" |
64 | 63 | |
65 | 64 | #ifndef WEXITSTATUS |
… |
… |
static int pty_open_master (char *pty_name) |
1187 | 1186 | pty_name [9] = *ptr2; |
1188 | 1187 | |
1189 | 1188 | /* Try to open master */ |
1190 | | if ((pty_master = open (pty_name, O_RDWR)) == -1) { |
| 1189 | pty_master = open (pty_name, O_RDWR); |
| 1190 | if (pty_master == -1) { |
1191 | 1191 | if (errno == ENOENT) /* Different from EIO */ |
1192 | 1192 | return -1; /* Out of pty devices */ |
1193 | 1193 | else |
… |
… |
pty_open_slave (const char *pty_name) |
1218 | 1218 | /* chown (pty_name, getuid (), group_info->gr_gid); FIXME */ |
1219 | 1219 | /* chmod (pty_name, S_IRUSR | S_IWUSR | S_IWGRP); FIXME */ |
1220 | 1220 | } |
1221 | | if ((pty_slave = open (pty_name, O_RDWR)) == -1) |
| 1221 | pty_slave = open (pty_name, O_RDWR); |
| 1222 | if (pty_slave == -1) |
1222 | 1223 | fprintf (stderr, "open (pty_name, O_RDWR): %s\r\n", pty_name); |
1223 | 1224 | fcntl(pty_slave, F_SETFD, FD_CLOEXEC); |
1224 | 1225 | return pty_slave; |
-
diff --git a/src/treestore.c b/src/treestore.c
index 39db5f2..957a5c8 100644
a
|
b
|
tree_store_save_to(char *name) |
331 | 331 | |
332 | 332 | if (vfs_file_is_local(current->name)) { |
333 | 333 | /* Clear-text compression */ |
334 | | if (current->prev |
335 | | && (common = |
336 | | str_common(current->prev->name, current->name)) > 2) { |
| 334 | common = str_common(current->prev->name, current->name); |
| 335 | if (current->prev && (common > 2)) { |
337 | 336 | char *encoded = encode(current->name + common); |
338 | 337 | |
339 | 338 | i = fprintf(file, "%d:%d %s\n", current->scanned, common, |
… |
… |
tree_store_save(void) |
374 | 373 | name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_TREESTORE_FILE, NULL); |
375 | 374 | mc_util_make_backup_if_possible (name, ".tmp"); |
376 | 375 | |
377 | | if ((retval = tree_store_save_to(name)) != 0) { |
| 376 | retval = tree_store_save_to(name); |
| 377 | if (retval != 0) { |
378 | 378 | mc_util_restore_from_backup_if_possible (name, ".tmp"); |
379 | 379 | g_free(name); |
380 | 380 | return retval; |
-
diff --git a/src/user.c b/src/user.c
index ed5fe81..a972e51 100644
a
|
b
|
user_menu_cmd (WEdit *edit_widget) |
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
785 | | if ((data = load_file (menu)) == NULL){ |
| 785 | data = load_file (menu); |
| 786 | if (data == NULL) { |
786 | 787 | message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), |
787 | 788 | menu, unix_error_string (errno)); |
788 | 789 | g_free (menu); |
-
diff --git a/src/util.c b/src/util.c
index 08c5777..e1f18c6 100644
a
|
b
|
strip_password (char *p, int has_prefix) |
480 | 480 | char *q; |
481 | 481 | |
482 | 482 | if (has_prefix) { |
483 | | if((q = strstr (p, prefixes[i].name)) == 0) |
| 483 | q = strstr (p, prefixes[i].name); |
| 484 | if (q == 0) |
484 | 485 | continue; |
485 | 486 | else |
486 | 487 | p = q + prefixes[i].len; |
487 | 488 | } |
488 | 489 | |
489 | | if ((dir = strchr (p, PATH_SEP)) != NULL) |
| 490 | dir = strchr (p, PATH_SEP); |
| 491 | if (dir != NULL) |
490 | 492 | *dir = '\0'; |
491 | 493 | |
492 | 494 | /* search for any possible user */ |
… |
… |
load_file (const char *filename) |
569 | 571 | char *data; |
570 | 572 | long read_size; |
571 | 573 | |
572 | | if ((data_file = fopen (filename, "r")) == NULL){ |
| 574 | data_file = fopen (filename, "r"); |
| 575 | if (data_file == NULL) |
573 | 576 | return 0; |
574 | | } |
| 577 | |
575 | 578 | if (fstat (fileno (data_file), &s) != 0){ |
576 | 579 | fclose (data_file); |
577 | 580 | return 0; |
-
diff --git a/src/utilunix.c b/src/utilunix.c
index 00db9d5..c8df45f 100644
a
|
b
|
char *get_owner (int uid) |
91 | 91 | char *name; |
92 | 92 | static int uid_last; |
93 | 93 | |
94 | | if ((name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE)) != NULL) |
| 94 | name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE); |
| 95 | if (name != NULL) |
95 | 96 | return name; |
96 | 97 | |
97 | 98 | pwd = getpwuid (uid); |
… |
… |
char *get_group (int gid) |
112 | 113 | char *name; |
113 | 114 | static int gid_last; |
114 | 115 | |
115 | | if ((name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE)) != NULL) |
| 116 | name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE); |
| 117 | if (name != NULL) |
116 | 118 | return name; |
117 | 119 | |
118 | 120 | grp = getgrgid (gid); |
… |
… |
int my_system (int flags, const char *shell, const char *command) |
150 | 152 | /* handler messing the screen after the SIGCONT */ |
151 | 153 | sigaction (SIGTSTP, &startup_handler, &save_stop); |
152 | 154 | |
153 | | if ((pid = fork ()) < 0){ |
| 155 | pid = fork (); |
| 156 | if (pid < 0) { |
154 | 157 | fprintf (stderr, "\n\nfork () = -1\n"); |
155 | 158 | return -1; |
156 | | } |
157 | | if (pid == 0){ |
| 159 | } else if (pid == 0) { |
158 | 160 | signal (SIGINT, SIG_DFL); |
159 | 161 | signal (SIGQUIT, SIG_DFL); |
160 | 162 | signal (SIGTSTP, SIG_DFL); |
-
diff --git a/src/viewer/datasource.c b/src/viewer/datasource.c
index d2d689a..ff3fd33 100644
a
|
b
|
mcview_load_command_output (mcview_t * view, const char *command) |
343 | 343 | mcview_close_datasource (view); |
344 | 344 | |
345 | 345 | open_error_pipe (); |
346 | | if ((fp = popen (command, "r")) == NULL) { |
| 346 | fp = popen (command, "r"); |
| 347 | if (fp == NULL) { |
347 | 348 | /* Avoid two messages. Message from stderr has priority. */ |
348 | 349 | mcview_display (view); |
349 | 350 | if (!close_error_pipe (mcview_is_in_panel (view) ? -1 : D_ERROR, NULL)) |
-
diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
index 89d67cc..8b3067d 100644
a
|
b
|
mcview_load (mcview_t * view, const char *command, const char *file, int start_l |
325 | 325 | retval = mcview_load_command_output (view, command); |
326 | 326 | } else if (file != NULL && file[0] != '\0') { |
327 | 327 | /* Open the file */ |
328 | | if ((fd = mc_open (file, O_RDONLY | O_NONBLOCK)) == -1) { |
| 328 | fd = mc_open (file, O_RDONLY | O_NONBLOCK); |
| 329 | if (fd == -1) { |
329 | 330 | g_snprintf (tmp, sizeof (tmp), _(" Cannot open \"%s\"\n %s "), |
330 | 331 | file, unix_error_string (errno)); |
331 | 332 | mcview_show_error (view, tmp); |
-
diff --git a/src/widget.c b/src/widget.c
index 9257fad..3fe7546 100644
a
|
b
|
history_put (const char *input_name, GList *h) |
1054 | 1054 | |
1055 | 1055 | profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_HISTORY_FILE, NULL); |
1056 | 1056 | |
1057 | | if ((i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) != -1) |
| 1057 | i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); |
| 1058 | if (i != -1) |
1058 | 1059 | close (i); |
1059 | 1060 | |
1060 | 1061 | /* Make sure the history is only readable by the user */ |
-
diff --git a/vfs/cpio.c b/vfs/cpio.c
index 0af9cda..94f4ad2 100644
a
|
b
|
cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, |
164 | 164 | mode_t mode; |
165 | 165 | struct vfs_s_inode *root; |
166 | 166 | |
167 | | if ((fd = mc_open (name, O_RDONLY)) == -1) { |
| 167 | fd = mc_open (name, O_RDONLY); |
| 168 | if (fd == -1) { |
168 | 169 | message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name); |
169 | 170 | return -1; |
170 | 171 | } |
… |
… |
cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, |
180 | 181 | |
181 | 182 | mc_close (fd); |
182 | 183 | s = g_strconcat (name, decompress_extension (type), (char *) NULL); |
183 | | if ((fd = mc_open (s, O_RDONLY)) == -1) { |
| 184 | fd = mc_open (s, O_RDONLY); |
| 185 | if (fd == -1) { |
184 | 186 | message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); |
185 | 187 | g_free (s); |
186 | 188 | return -1; |
… |
… |
static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super) |
246 | 248 | ptr -= top - 128; |
247 | 249 | top = 128; |
248 | 250 | } |
249 | | if((tmp = mc_read(super->u.arch.fd, buf, top)) == 0 || tmp == -1) { |
| 251 | tmp = mc_read(super->u.arch.fd, buf, top); |
| 252 | if (tmp == 0 || tmp == -1) { |
250 | 253 | message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name); |
251 | 254 | cpio_free_archive(me, super); |
252 | 255 | return CPIO_UNKNOWN; |
… |
… |
static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe |
418 | 421 | char *name; |
419 | 422 | struct stat st; |
420 | 423 | |
421 | | if((len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH) |
| 424 | len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH); |
| 425 | if (len < HEAD_LENGTH) |
422 | 426 | return STATUS_EOF; |
423 | 427 | CPIO_POS(super) += len; |
424 | 428 | if(super->u.arch.type == CPIO_BINRE) { |
… |
… |
static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe |
434 | 438 | return STATUS_FAIL; |
435 | 439 | } |
436 | 440 | name = g_malloc(u.buf.c_namesize); |
437 | | if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) { |
| 441 | len = mc_read(super->u.arch.fd, name, u.buf.c_namesize); |
| 442 | if (len < u.buf.c_namesize) { |
438 | 443 | g_free(name); |
439 | 444 | return STATUS_EOF; |
440 | 445 | } |
… |
… |
static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup |
492 | 497 | return STATUS_FAIL; |
493 | 498 | } |
494 | 499 | name = g_malloc(hd.c_namesize); |
495 | | if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 || |
496 | | (unsigned long) len < hd.c_namesize) { |
| 500 | len = mc_read(super->u.arch.fd, name, hd.c_namesize); |
| 501 | if ((len == -1) || ((unsigned long) len < hd.c_namesize)) { |
497 | 502 | g_free (name); |
498 | 503 | return STATUS_EOF; |
499 | 504 | } |
… |
… |
static ssize_t cpio_read(void *fh, char *buffer, int count) |
668 | 673 | |
669 | 674 | count = MIN(count, FH->ino->st.st_size - FH->pos); |
670 | 675 | |
671 | | if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1); |
| 676 | count = mc_read (fd, buffer, count); |
| 677 | if (count == -1) ERRNOR (errno, -1); |
672 | 678 | |
673 | 679 | FH->pos += count; |
674 | 680 | return count; |
-
diff --git a/vfs/direntry.c b/vfs/direntry.c
index e608d5e..a6b16c3 100644
a
|
b
|
vfs_s_get_path_mangle (struct vfs_class *me, char *inname, |
483 | 483 | vfs_split (inname, &local, &op); |
484 | 484 | retval = (local) ? local : ""; |
485 | 485 | |
486 | | if (MEDATA->archive_check) |
487 | | if (!(cookie = MEDATA->archive_check (me, archive_name, op))) |
| 486 | if (MEDATA->archive_check) { |
| 487 | cookie = MEDATA->archive_check (me, archive_name, op); |
| 488 | if (!cookie) |
488 | 489 | return NULL; |
| 490 | } |
489 | 491 | |
490 | 492 | for (super = MEDATA->supers; super != NULL; super = super->next) { |
491 | 493 | /* 0 == other, 1 == same, return it, 2 == other but stop scanning */ |
… |
… |
vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags) |
585 | 587 | struct vfs_s_inode *ino; |
586 | 588 | char *q; |
587 | 589 | |
588 | | if (!(q = vfs_s_get_path (me, name, &super, 0))) |
| 590 | q = vfs_s_get_path (me, name, &super, 0); |
| 591 | if (!q) |
589 | 592 | return NULL; |
590 | 593 | |
591 | 594 | ino = |
… |
… |
static int |
668 | 671 | vfs_s_chdir (struct vfs_class *me, const char *path) |
669 | 672 | { |
670 | 673 | void *data; |
671 | | if (!(data = vfs_s_opendir (me, path))) |
| 674 | data = vfs_s_opendir (me, path); |
| 675 | if (!data) |
672 | 676 | return -1; |
673 | 677 | vfs_s_closedir (data); |
674 | 678 | return 0; |
… |
… |
vfs_s_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, i |
681 | 685 | { |
682 | 686 | struct vfs_s_inode *ino; |
683 | 687 | |
684 | | if (!(ino = vfs_s_inode_from_path (me, path, flag))) |
| 688 | ino = vfs_s_inode_from_path (me, path, flag); |
| 689 | if (!ino) |
685 | 690 | return -1; |
686 | 691 | *buf = ino->st; |
687 | 692 | return 0; |
… |
… |
vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) |
739 | 744 | char *q; |
740 | 745 | struct vfs_s_inode *ino; |
741 | 746 | |
742 | | if ((q = vfs_s_get_path (me, file, &super, 0)) == NULL) |
| 747 | q = vfs_s_get_path (me, file, &super, 0); |
| 748 | if (q == NULL) |
743 | 749 | return NULL; |
744 | 750 | ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE); |
745 | 751 | if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) { |
… |
… |
vfs_s_getid (struct vfs_class *me, const char *path) |
1103 | 1109 | struct vfs_s_super *archive; |
1104 | 1110 | char *p; |
1105 | 1111 | |
1106 | | if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN))) |
| 1112 | p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN); |
| 1113 | if (!p) |
1107 | 1114 | return NULL; |
1108 | 1115 | g_free(p); |
1109 | 1116 | return (vfsid) archive; |
-
diff --git a/vfs/extfs.c b/vfs/extfs.c
index d30774e..7556a03 100644
a
|
b
|
extfs_read_archive (int fstype, const char *name, struct archive **pparc) |
323 | 323 | struct archive *current_archive; |
324 | 324 | char *current_file_name, *current_link_name; |
325 | 325 | |
326 | | if ((extfsd = |
327 | | extfs_open_archive (fstype, name, ¤t_archive)) == NULL) { |
| 326 | extfsd = extfs_open_archive (fstype, name, ¤t_archive); |
| 327 | if (extfsd == NULL) { |
328 | 328 | message (D_ERROR, MSG_ERROR, _("Cannot open %s archive\n%s"), |
329 | 329 | extfs_prefixes[fstype], name); |
330 | 330 | return -1; |
… |
… |
extfs_run (struct vfs_class *me, const char *file) |
655 | 655 | char *p, *q, *archive_name, *mc_extfsdir; |
656 | 656 | char *cmd; |
657 | 657 | |
658 | | if ((p = extfs_get_path (me, file, &archive, 0)) == NULL) |
| 658 | p = extfs_get_path (me, file, &archive, 0); |
| 659 | if (p == NULL) |
659 | 660 | return; |
660 | 661 | q = name_quote (p, 0); |
661 | 662 | g_free (p); |
… |
… |
extfs_open (struct vfs_class *me, const char *file, int flags, int mode) |
681 | 682 | int local_handle; |
682 | 683 | int created = 0; |
683 | 684 | |
684 | | if ((q = extfs_get_path (me, file, &archive, 0)) == NULL) |
| 685 | q = extfs_get_path (me, file, &archive, 0); |
| 686 | if (q == NULL) |
685 | 687 | return NULL; |
686 | 688 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
687 | 689 | if (entry == NULL && (flags & O_CREAT)) { |
… |
… |
extfs_open (struct vfs_class *me, const char *file, int flags, int mode) |
693 | 695 | g_free (q); |
694 | 696 | if (entry == NULL) |
695 | 697 | return NULL; |
696 | | if ((entry = extfs_resolve_symlinks (entry)) == NULL) |
| 698 | entry = extfs_resolve_symlinks (entry); |
| 699 | if (entry == NULL) |
697 | 700 | return NULL; |
698 | 701 | |
699 | 702 | if (S_ISDIR (entry->inode->mode)) |
… |
… |
extfs_find_entry_int (struct entry *dir, char *name, |
817 | 820 | if (!strcmp (p, "..")) |
818 | 821 | pent = pent->dir; |
819 | 822 | else { |
820 | | if ((pent = extfs_resolve_symlinks_int (pent, list))==NULL){ |
| 823 | pent = extfs_resolve_symlinks_int (pent, list); |
| 824 | if (pent == NULL) { |
821 | 825 | *q = c; |
822 | 826 | return NULL; |
823 | 827 | } |
… |
… |
static void * extfs_opendir (struct vfs_class *me, const char *dirname) |
893 | 897 | struct entry *entry; |
894 | 898 | struct entry **info; |
895 | 899 | |
896 | | if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL) |
| 900 | q = extfs_get_path (me, dirname, &archive, 0); |
| 901 | if (q == NULL) |
897 | 902 | return NULL; |
898 | 903 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
899 | 904 | g_free (q); |
900 | 905 | if (entry == NULL) |
901 | 906 | return NULL; |
902 | | if ((entry = extfs_resolve_symlinks (entry)) == NULL) |
| 907 | entry = extfs_resolve_symlinks (entry); |
| 908 | if (entry == NULL) |
903 | 909 | return NULL; |
904 | 910 | if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, NULL); |
905 | 911 | |
… |
… |
extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, |
965 | 971 | char *path2 = g_strdup (path); |
966 | 972 | int result = -1; |
967 | 973 | |
968 | | if ((q = extfs_get_path_mangle (me, path2, &archive, 0)) == NULL) |
| 974 | q = extfs_get_path_mangle (me, path2, &archive, 0); |
| 975 | if (q == NULL) |
969 | 976 | goto cleanup; |
970 | 977 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
971 | 978 | if (entry == NULL) |
972 | 979 | goto cleanup; |
973 | | if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL) |
| 980 | entry = extfs_resolve_symlinks (entry); |
| 981 | if (resolve && (entry == NULL)) |
974 | 982 | goto cleanup; |
975 | 983 | extfs_stat_move (buf, entry->inode); |
976 | 984 | result = 0; |
… |
… |
extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) |
1007 | 1015 | char *mpath = g_strdup (path); |
1008 | 1016 | int result = -1; |
1009 | 1017 | |
1010 | | if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL) |
| 1018 | q = extfs_get_path_mangle (me, mpath, &archive, 0); |
| 1019 | if (q == NULL) |
1011 | 1020 | goto cleanup; |
1012 | 1021 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
1013 | 1022 | if (entry == NULL) |
… |
… |
static int extfs_unlink (struct vfs_class *me, const char *file) |
1058 | 1067 | struct entry *entry; |
1059 | 1068 | int result = -1; |
1060 | 1069 | |
1061 | | if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL) |
| 1070 | q = extfs_get_path_mangle (me, mpath, &archive, 0); |
| 1071 | if (q == NULL) |
1062 | 1072 | goto cleanup; |
1063 | 1073 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
1064 | 1074 | if (entry == NULL) |
1065 | 1075 | goto cleanup; |
1066 | | if ((entry = extfs_resolve_symlinks (entry)) == NULL) |
| 1076 | entry = extfs_resolve_symlinks (entry); |
| 1077 | if (entry == NULL) |
1067 | 1078 | goto cleanup; |
1068 | 1079 | if (S_ISDIR (entry->inode->mode)) { |
1069 | 1080 | me->verrno = EISDIR; |
… |
… |
static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) |
1089 | 1100 | |
1090 | 1101 | (void) mode; |
1091 | 1102 | |
1092 | | if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL) |
| 1103 | q = extfs_get_path_mangle (me, mpath, &archive, 0); |
| 1104 | if (q == NULL) |
1093 | 1105 | goto cleanup; |
1094 | 1106 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
1095 | 1107 | if (entry != NULL) { |
… |
… |
static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) |
1099 | 1111 | entry = extfs_find_entry (archive->root_entry, q, 1, 0); |
1100 | 1112 | if (entry == NULL) |
1101 | 1113 | goto cleanup; |
1102 | | if ((entry = extfs_resolve_symlinks (entry)) == NULL) |
| 1114 | entry = extfs_resolve_symlinks (entry); |
| 1115 | if (entry == NULL) |
1103 | 1116 | goto cleanup; |
1104 | 1117 | if (!S_ISDIR (entry->inode->mode)) { |
1105 | 1118 | me->verrno = ENOTDIR; |
… |
… |
static int extfs_rmdir (struct vfs_class *me, const char *path) |
1124 | 1137 | struct entry *entry; |
1125 | 1138 | int result = -1; |
1126 | 1139 | |
1127 | | if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL) |
| 1140 | q = extfs_get_path_mangle (me, mpath, &archive, 0); |
| 1141 | if (q == NULL) |
1128 | 1142 | goto cleanup; |
1129 | 1143 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
1130 | 1144 | if (entry == NULL) |
1131 | 1145 | goto cleanup; |
1132 | | if ((entry = extfs_resolve_symlinks (entry)) == NULL) |
| 1146 | entry = extfs_resolve_symlinks (entry); |
| 1147 | if (entry == NULL) |
1133 | 1148 | goto cleanup; |
1134 | 1149 | if (!S_ISDIR (entry->inode->mode)) { |
1135 | 1150 | me->verrno = ENOTDIR; |
… |
… |
extfs_chdir (struct vfs_class *me, const char *path) |
1155 | 1170 | struct entry *entry; |
1156 | 1171 | |
1157 | 1172 | my_errno = ENOTDIR; |
1158 | | if ((q = extfs_get_path (me, path, &archive, 0)) == NULL) |
| 1173 | q = extfs_get_path (me, path, &archive, 0); |
| 1174 | if (q == NULL) |
1159 | 1175 | return -1; |
1160 | 1176 | entry = extfs_find_entry (archive->root_entry, q, 0, 0); |
1161 | 1177 | g_free (q); |
… |
… |
static int extfs_init (struct vfs_class *me) |
1352 | 1368 | if (*key == '#' || *key == '\n') |
1353 | 1369 | continue; |
1354 | 1370 | |
1355 | | if ((c = strchr (key, '\n'))){ |
| 1371 | c = strchr (key, '\n'); |
| 1372 | if (c) { |
1356 | 1373 | *c-- = 0; |
1357 | 1374 | } else { /* Last line without newline or strlen (key) > 255 */ |
1358 | 1375 | c = &key [strlen (key) - 1]; |
-
diff --git a/vfs/fish.c b/vfs/fish.c
index 04c8527..6ae6034 100644
a
|
b
|
fish_pipeopen(struct vfs_s_super *super, const char *path, const char *argv[]) |
199 | 199 | if ((pipe(fileset1)<0) || (pipe(fileset2)<0)) |
200 | 200 | vfs_die("Cannot pipe(): %m."); |
201 | 201 | |
202 | | if ((res = fork())) { |
| 202 | res = fork(); |
| 203 | if (res) { |
203 | 204 | if (res<0) vfs_die("Cannot fork(): %m."); |
204 | 205 | /* We are the parent */ |
205 | 206 | close(fileset1[0]); |
… |
… |
fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc |
787 | 788 | } |
788 | 789 | if (n == 0) |
789 | 790 | break; |
790 | | if ((t = write (SUP.sockw, buffer, n)) != n) { |
| 791 | t = write (SUP.sockw, buffer, n); |
| 792 | if (t != n) { |
791 | 793 | if (t == -1) { |
792 | 794 | me->verrno = errno; |
793 | 795 | } else { |
… |
… |
fish_linear_abort (struct vfs_class *me, struct vfs_s_fh *fh) |
873 | 875 | do { |
874 | 876 | n = MIN(8192, fh->u.fish.total - fh->u.fish.got); |
875 | 877 | if (n) { |
876 | | if ((n = read(SUP.sockr, buffer, n)) < 0) |
| 878 | n = read(SUP.sockr, buffer, n); |
| 879 | if (n < 0) |
877 | 880 | return; |
878 | 881 | fh->u.fish.got += n; |
879 | 882 | } |
… |
… |
fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c |
960 | 963 | const char *crpath; \ |
961 | 964 | char *rpath, *mpath = g_strdup (path); \ |
962 | 965 | struct vfs_s_super *super; \ |
963 | | if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ |
| 966 | crpath = vfs_s_get_path_mangle (me, mpath, &super, 0); \ |
| 967 | if (!crpath) { \ |
964 | 968 | g_free (mpath); \ |
965 | 969 | return -1; \ |
966 | 970 | } \ |
… |
… |
static int fish_##name (struct vfs_class *me, const char *path1, const char *pat |
993 | 997 | const char *crpath1, *crpath2; \ |
994 | 998 | char *rpath1, *rpath2, *mpath1, *mpath2; \ |
995 | 999 | struct vfs_s_super *super1, *super2; \ |
996 | | if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) { \ |
| 1000 | crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0); \ |
| 1001 | if (!crpath1) { \ |
997 | 1002 | g_free (mpath1); \ |
998 | 1003 | return -1; \ |
999 | 1004 | } \ |
1000 | | if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \ |
| 1005 | crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0); \ |
| 1006 | if (!crpath2) { \ |
1001 | 1007 | g_free (mpath1); \ |
1002 | 1008 | g_free (mpath2); \ |
1003 | 1009 | return -1; \ |
… |
… |
fish_chown (struct vfs_class *me, const char *path, int owner, int group) |
1049 | 1055 | struct passwd *pw; |
1050 | 1056 | struct group *gr; |
1051 | 1057 | |
1052 | | if ((pw = getpwuid (owner)) == NULL) |
| 1058 | pw = getpwuid (owner); |
| 1059 | if (pw == NULL) |
1053 | 1060 | return 0; |
1054 | 1061 | |
1055 | | if ((gr = getgrgid (group)) == NULL) |
| 1062 | gr = getgrgid (group); |
| 1063 | if (gr == NULL) |
1056 | 1064 | return 0; |
1057 | 1065 | |
1058 | 1066 | sowner = pw->pw_name; |
-
diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c
index c4be6bf..02fd946 100644
a
|
b
|
ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha |
218 | 218 | ret = g_strdup (remote_path); |
219 | 219 | |
220 | 220 | /* replace first occurance of ":/" with ":" */ |
221 | | if ((p = strchr (ret, ':')) && *(p + 1) == '/') |
| 221 | p = strchr (ret, ':'); |
| 222 | if (p && (*(p + 1) == '/')) |
222 | 223 | strcpy (p + 1, p + 2); |
223 | 224 | |
224 | 225 | /* strip trailing "/." */ |
225 | | if ((p = strrchr (ret, '/')) && *(p + 1) == '.' && *(p + 2) == '\0') |
| 226 | p = strrchr (ret, '/'); |
| 227 | if (p && (*(p + 1) == '.') && (*(p + 2) == '\0')) |
226 | 228 | *p = '\0'; |
227 | 229 | return ret; |
228 | 230 | } |
… |
… |
ftpfs_load_no_proxy_list (void) |
579 | 581 | return; |
580 | 582 | |
581 | 583 | mc_file = concat_dir_and_file (mc_home, "mc.no_proxy"); |
582 | | if (exist_file (mc_file) && |
583 | | (npf = fopen (mc_file, "r"))) { |
584 | | while (fgets (s, sizeof (s), npf)) { |
585 | | if (!(p = strchr (s, '\n'))) { /* skip bogus entries */ |
586 | | while ((c = fgetc (npf)) != EOF && c != '\n') |
587 | | ; |
588 | | continue; |
589 | | } |
590 | | |
591 | | if (p == s) |
592 | | continue; |
593 | | |
594 | | *p = '\0'; |
595 | | |
596 | | np = g_new (struct no_proxy_entry, 1); |
597 | | np->domain = g_strdup (s); |
598 | | np->next = NULL; |
599 | | if (no_proxy) |
600 | | current->next = np; |
601 | | else |
602 | | no_proxy = np; |
603 | | current = np; |
| 584 | if (exist_file (mc_file)) { |
| 585 | npf = fopen (mc_file, "r"); |
| 586 | if (npf) { |
| 587 | while (fgets (s, sizeof (s), npf)) { |
| 588 | p = strchr (s, '\n'); |
| 589 | if (!p) { /* skip bogus entries */ |
| 590 | while ((c = fgetc (npf)) != EOF && c != '\n') |
| 591 | ; |
| 592 | continue; |
| 593 | } |
| 594 | |
| 595 | if (p == s) |
| 596 | continue; |
| 597 | |
| 598 | *p = '\0'; |
| 599 | |
| 600 | np = g_new (struct no_proxy_entry, 1); |
| 601 | np->domain = g_strdup (s); |
| 602 | np->next = NULL; |
| 603 | if (no_proxy) |
| 604 | current->next = np; |
| 605 | else |
| 606 | no_proxy = np; |
| 607 | current = np; |
| 608 | } |
| 609 | |
| 610 | fclose (npf); |
604 | 611 | } |
605 | | |
606 | | fclose (npf); |
607 | 612 | } |
608 | 613 | g_free (mc_file); |
609 | 614 | } |
… |
… |
ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con |
1091 | 1096 | int s, j, data; |
1092 | 1097 | socklen_t fromlen = sizeof(from); |
1093 | 1098 | |
1094 | | if ((s = ftpfs_initconn (me, super)) == -1) |
| 1099 | s = ftpfs_initconn (me, super); |
| 1100 | if (s == -1) |
1095 | 1101 | return -1; |
1096 | 1102 | if (ftpfs_changetype (me, super, isbinary) == -1) |
1097 | 1103 | return -1; |
… |
… |
ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd, |
1620 | 1626 | int r; |
1621 | 1627 | int flush_directory_cache = (flags & OPT_FLUSH); |
1622 | 1628 | |
1623 | | if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) { |
| 1629 | rpath = vfs_s_get_path_mangle(me, mpath, &super, 0); |
| 1630 | if (!rpath) { |
1624 | 1631 | g_free(mpath); |
1625 | 1632 | return -1; |
1626 | 1633 | } |
… |
… |
static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) |
2043 | 2050 | /* Find our own domain name */ |
2044 | 2051 | if (gethostname (hostname, sizeof (hostname)) < 0) |
2045 | 2052 | *hostname = 0; |
2046 | | if (!(domain = strchr (hostname, '.'))) |
| 2053 | domain = strchr (hostname, '.'); |
| 2054 | if (!domain) |
2047 | 2055 | domain = ""; |
2048 | 2056 | |
2049 | 2057 | /* Scan for "default" and matching "machine" keywords */ |
-
diff --git a/vfs/mcfs.c b/vfs/mcfs.c
index 9903e57..661a897 100644
a
|
b
|
mcfs_get_remote_port (struct sockaddr_in *sin, int *version) |
212 | 212 | #ifdef HAVE_PMAP_GETPORT |
213 | 213 | int port; |
214 | 214 | for (*version = RPC_PROGVER; *version >= 1; (*version)--) |
215 | | if (port = pmap_getport (sin, RPC_PROGNUM, *version, IPPROTO_TCP)) |
| 215 | port = pmap_getport (sin, RPC_PROGNUM, *version, IPPROTO_TCP); |
| 216 | if (port) |
216 | 217 | return port; |
217 | 218 | #endif /* HAVE_PMAP_GETPORT */ |
218 | 219 | *version = 1; |
… |
… |
mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal |
237 | 238 | server_address.sin_family = AF_INET; |
238 | 239 | |
239 | 240 | /* Try to use the dotted decimal number */ |
240 | | if ((inaddr = inet_addr (host)) != INADDR_NONE) |
| 241 | inaddr = inet_addr (host); |
| 242 | if (inaddr != INADDR_NONE) |
241 | 243 | memcpy ((char *) &server_address.sin_addr, (char *) &inaddr, |
242 | 244 | sizeof (inaddr)); |
243 | 245 | else { |
244 | | if ((hp = gethostbyname (host)) == NULL) { |
| 246 | hp = gethostbyname (host); |
| 247 | if (hp == NULL) { |
245 | 248 | message (D_ERROR, caller, _(" Cannot locate hostname: %s "), |
246 | 249 | host); |
247 | 250 | return 0; |
… |
… |
mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal |
260 | 263 | |
261 | 264 | server_address.sin_port = htons (*port); |
262 | 265 | |
263 | | if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { |
| 266 | my_socket = socket (AF_INET, SOCK_STREAM, 0); |
| 267 | if (my_socket < 0) { |
264 | 268 | message (D_ERROR, caller, _(" Cannot create socket: %s "), |
265 | 269 | unix_error_string (errno)); |
266 | 270 | return 0; |
… |
… |
mcfs_open_link (char *host, char *user, int *port, char *netrcpass) |
341 | 345 | return 0; |
342 | 346 | } |
343 | 347 | |
344 | | if (! |
345 | | (sock = |
346 | | mcfs_open_tcp_link (host, user, port, netrcpass, &version))) |
| 348 | sock = mcfs_open_tcp_link (host, user, port, netrcpass, &version); |
| 349 | if (!sock) |
347 | 350 | return 0; |
348 | 351 | |
349 | 352 | bucket = mcfs_get_free_bucket (); |
… |
… |
mcfs_get_path (mcfs_connection **mc, const char *path) |
394 | 397 | * remote portmapper to get the port number |
395 | 398 | */ |
396 | 399 | port = 0; |
397 | | if ((remote_path = |
398 | | mcfs_get_host_and_username (path, &host, &user, &port, &pass))) |
399 | | if (!(*mc = mcfs_open_link (host, user, &port, pass))) { |
| 400 | remote_path = mcfs_get_host_and_username (path, &host, &user, &port, &pass); |
| 401 | if (remote_path) { |
| 402 | *mc = mcfs_open_link (host, user, &port, pass); |
| 403 | if (!(*mc)) { |
400 | 404 | g_free (remote_path); |
401 | 405 | remote_path = NULL; |
402 | 406 | } |
| 407 | } |
403 | 408 | g_free (host); |
404 | 409 | g_free (user); |
405 | 410 | if (pass) |
… |
… |
mcfs_rpc_two_paths (int command, const char *s1, const char *s2) |
445 | 450 | mcfs_connection *mc; |
446 | 451 | char *r1, *r2; |
447 | 452 | |
448 | | if ((r1 = mcfs_get_path (&mc, s1)) == 0) |
| 453 | r1 = mcfs_get_path (&mc, s1); |
| 454 | if (r1 == 0) |
449 | 455 | return -1; |
450 | 456 | |
451 | | if ((r2 = mcfs_get_path (&mc, s2)) == 0) { |
| 457 | r2 = mcfs_get_path (&mc, s2); |
| 458 | if (r2 == 0) { |
452 | 459 | g_free (r1); |
453 | 460 | return -1; |
454 | 461 | } |
… |
… |
mcfs_rpc_path (int command, const char *path) |
466 | 473 | mcfs_connection *mc; |
467 | 474 | char *remote_file; |
468 | 475 | |
469 | | if ((remote_file = mcfs_get_path (&mc, path)) == 0) |
| 476 | remote_file = mcfs_get_path (&mc, path); |
| 477 | if (remote_file == 0) |
470 | 478 | return -1; |
471 | 479 | |
472 | 480 | rpc_send (mc->sock, |
… |
… |
mcfs_rpc_path_int (int command, const char *path, int data) |
482 | 490 | mcfs_connection *mc; |
483 | 491 | char *remote_file; |
484 | 492 | |
485 | | if ((remote_file = mcfs_get_path (&mc, path)) == 0) |
| 493 | remote_file = mcfs_get_path (&mc, path); |
| 494 | if (remote_file == 0) |
486 | 495 | return -1; |
487 | 496 | |
488 | 497 | rpc_send (mc->sock, |
… |
… |
mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2) |
499 | 508 | mcfs_connection *mc; |
500 | 509 | char *remote_file; |
501 | 510 | |
502 | | if ((remote_file = mcfs_get_path (&mc, path)) == 0) |
| 511 | remote_file = mcfs_get_path (&mc, path); |
| 512 | if (remote_file == 0) |
503 | 513 | return -1; |
504 | 514 | |
505 | 515 | rpc_send (mc->sock, |
… |
… |
mcfs_open (struct vfs_class *me, const char *file, int flags, int mode) |
537 | 547 | |
538 | 548 | (void) me; |
539 | 549 | |
540 | | if (!(remote_file = mcfs_get_path (&mc, file))) |
| 550 | remote_file = mcfs_get_path (&mc, file); |
| 551 | if (!remote_file) |
541 | 552 | return 0; |
542 | 553 | |
543 | 554 | rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT, |
… |
… |
mcfs_opendir (struct vfs_class *me, const char *dirname) |
661 | 672 | |
662 | 673 | (void) me; |
663 | 674 | |
664 | | if (!(remote_dir = mcfs_get_path (&mc, dirname))) |
| 675 | remote_dir = mcfs_get_path (&mc, dirname); |
| 676 | if (!remote_dir) |
665 | 677 | return 0; |
666 | 678 | |
667 | 679 | rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, |
… |
… |
mcfs_stat_cmd (int cmd, const char *path, struct stat *buf) |
880 | 892 | mcfs_connection *mc; |
881 | 893 | int status, error; |
882 | 894 | |
883 | | if ((remote_file = mcfs_get_path (&mc, path)) == 0) |
| 895 | remote_file = mcfs_get_path (&mc, path); |
| 896 | if (remote_file == 0) |
884 | 897 | return -1; |
885 | 898 | |
886 | 899 | rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END); |
… |
… |
mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times) |
970 | 983 | |
971 | 984 | (void) me; |
972 | 985 | |
973 | | if (!(file = mcfs_get_path (&mc, path))) |
| 986 | file = mcfs_get_path (&mc, path); |
| 987 | if (!file) |
974 | 988 | return -1; |
975 | 989 | |
976 | 990 | status = 0; |
… |
… |
mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) |
1005 | 1019 | |
1006 | 1020 | (void) me; |
1007 | 1021 | |
1008 | | if (!(remote_file = mcfs_get_path (&mc, path))) |
| 1022 | remote_file = mcfs_get_path (&mc, path); |
| 1023 | if (!remote_file) |
1009 | 1024 | return -1; |
1010 | 1025 | |
1011 | 1026 | rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, |
… |
… |
mcfs_chdir (struct vfs_class *me, const char *path) |
1062 | 1077 | |
1063 | 1078 | (void) me; |
1064 | 1079 | |
1065 | | if (!(remote_dir = mcfs_get_path (&mc, path))) |
| 1080 | remote_dir = mcfs_get_path (&mc, path); |
| 1081 | if (!remote_dir) |
1066 | 1082 | return -1; |
1067 | 1083 | |
1068 | 1084 | rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, |
… |
… |
mcfs_forget (const char *path) |
1140 | 1156 | if (path[0] == '/' && path[1] == '/') |
1141 | 1157 | path += 2; |
1142 | 1158 | |
1143 | | if ((p = |
1144 | | mcfs_get_host_and_username (path, &host, &user, &port, |
1145 | | &pass)) == 0) { |
| 1159 | p = mcfs_get_host_and_username (path, &host, &user, &port, &pass); |
| 1160 | if (p == 0) { |
1146 | 1161 | g_free (host); |
1147 | 1162 | g_free (user); |
1148 | 1163 | if (pass) |
-
diff --git a/vfs/mcserv.c b/vfs/mcserv.c
index 3f38ac4..807bce1 100644
a
|
b
|
mc_pam_auth (const char *username, const char *password) |
798 | 798 | up.password = password; |
799 | 799 | conv.appdata_ptr = &up; |
800 | 800 | |
801 | | if ((status = |
802 | | pam_start ("mcserv", username, &conv, &pamh)) != PAM_SUCCESS) |
| 801 | status = pam_start ("mcserv", username, &conv, &pamh); |
| 802 | if (status != PAM_SUCCESS) |
803 | 803 | goto failed_pam; |
804 | | if ((status = pam_authenticate (pamh, 0)) != PAM_SUCCESS) |
| 804 | status = pam_authenticate (pamh, 0); |
| 805 | if (status != PAM_SUCCESS) |
805 | 806 | goto failed_pam; |
806 | | if ((status = pam_acct_mgmt (pamh, 0)) != PAM_SUCCESS) |
| 807 | status = pam_acct_mgmt (pamh, 0); |
| 808 | if (status != PAM_SUCCESS) |
807 | 809 | goto failed_pam; |
808 | | if ((status = pam_setcred (pamh, PAM_ESTABLISH_CRED)) != PAM_SUCCESS) |
| 810 | status = pam_setcred (pamh, PAM_ESTABLISH_CRED); |
| 811 | if (status != PAM_SUCCESS) |
809 | 812 | goto failed_pam; |
810 | 813 | pam_end (pamh, status); |
811 | 814 | return 0; |
… |
… |
do_ftp_auth (const char *username, const char *password) |
865 | 868 | local_address.sin_port = htons (21); |
866 | 869 | |
867 | 870 | /* Convert localhost to usable format */ |
868 | | if ((inaddr = inet_addr ("127.0.0.1")) != INADDR_NONE) |
| 871 | inaddr = inet_addr ("127.0.0.1"); |
| 872 | if (inaddr != INADDR_NONE) |
869 | 873 | memcpy ((char *) &local_address.sin_addr, (char *) &inaddr, |
870 | 874 | sizeof (inaddr)); |
871 | 875 | |
872 | | if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { |
| 876 | my_socket = socket (AF_INET, SOCK_STREAM, 0); |
| 877 | if (my_socket < 0) { |
873 | 878 | if (!isDaemon) |
874 | 879 | fprintf (stderr, "do_auth: can't create socket\n"); |
875 | 880 | return 0; |
… |
… |
do_classic_auth (const char *username, const char *password) |
915 | 920 | struct spwd *spw; |
916 | 921 | #endif |
917 | 922 | |
918 | | if ((pw = getpwnam (username)) == 0) |
| 923 | pw = getpwnam (username); |
| 924 | if (pw == 0) |
919 | 925 | return 0; |
920 | 926 | |
921 | 927 | #ifdef HAVE_SHADOW |
922 | 928 | setspent (); |
923 | 929 | |
924 | 930 | /* Password expiration is not checked! */ |
925 | | if ((spw = getspnam (username)) == NULL) |
| 931 | spw = getspnam (username); |
| 932 | if (spw == NULL) |
926 | 933 | encr_pwd = "*"; |
927 | 934 | else |
928 | 935 | encr_pwd = spw->sp_pwdp; |
… |
… |
get_client (int port) |
1197 | 1204 | struct sockaddr_in client_address, server_address; |
1198 | 1205 | int yes = 1; |
1199 | 1206 | |
1200 | | if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) |
| 1207 | sock = socket (AF_INET, SOCK_STREAM, 0); |
| 1208 | if (sock < 0) |
1201 | 1209 | return "Cannot create socket"; |
1202 | 1210 | |
1203 | 1211 | /* Use this to debug: */ |
… |
… |
get_client (int port) |
1224 | 1232 | newsocket = |
1225 | 1233 | accept (sock, (struct sockaddr *) &client_address, &clilen); |
1226 | 1234 | |
1227 | | if (isDaemon && (child = fork ())) { |
| 1235 | child = fork (); |
| 1236 | if (isDaemon && child) { |
1228 | 1237 | int status; |
1229 | 1238 | |
1230 | 1239 | close (newsocket); |
… |
… |
register_port (int port, int abort_if_fail) |
1296 | 1305 | exit (1); |
1297 | 1306 | } |
1298 | 1307 | #else |
1299 | | (void) port; |
1300 | 1308 | if (abort_if_fail) { |
1301 | 1309 | fprintf (stderr, |
1302 | 1310 | "This system lacks port registration, try using the -p\n" |
… |
… |
main (int argc, char *argv[]) |
1370 | 1378 | register_port (portnum, 0); |
1371 | 1379 | if (verbose) |
1372 | 1380 | printf ("Using port %d\n", portnum); |
1373 | | if ((result = get_client (portnum))) |
| 1381 | result = get_client (portnum); |
| 1382 | if (result) |
1374 | 1383 | perror (result); |
1375 | 1384 | #ifdef HAVE_PMAP_SET |
1376 | 1385 | if (!isDaemon) |
-
diff --git a/vfs/sfs.c b/vfs/sfs.c
index ade71ee..8f14b8a 100644
a
|
b
|
sfs_vfmake (struct vfs_class *me, const char *name, char *cache) |
84 | 84 | |
85 | 85 | pname = g_strdup (name); |
86 | 86 | vfs_split (pname, &inpath, &op); |
87 | | if ((w = (*me->which) (me, op)) == -1) |
| 87 | |
| 88 | w = (*me->which) (me, op); |
| 89 | if (w == -1) |
88 | 90 | vfs_die ("This cannot happen... Hopefully.\n"); |
89 | 91 | |
90 | 92 | if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) { |
… |
… |
static int sfs_init (struct vfs_class *me) |
394 | 396 | goto invalid_line; |
395 | 397 | c++; |
396 | 398 | *(semi+1) = 0; |
397 | | if ((semi = strchr (c, '\n'))) |
| 399 | semi = strchr (c, '\n'); |
| 400 | if (semi) |
398 | 401 | *semi = 0; |
399 | 402 | |
400 | 403 | sfs_prefix [sfs_no] = g_strdup (key); |
-
diff --git a/vfs/tar.c b/vfs/tar.c
index acf4abb..4a038d3 100644
a
|
b
|
tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, |
665 | 665 | |
666 | 666 | current_tar_position = 0; |
667 | 667 | /* Open for reading */ |
668 | | if ((tard = tar_open_archive_int (me, name, archive)) == -1) |
| 668 | tard = tar_open_archive_int (me, name, archive); |
| 669 | if (tard == -1) |
669 | 670 | return -1; |
670 | 671 | |
671 | 672 | for (;;) { |
… |
… |
static ssize_t tar_read (void *fh, char *buffer, int count) |
771 | 772 | |
772 | 773 | count = MIN(count, FH->ino->st.st_size - FH->pos); |
773 | 774 | |
774 | | if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1); |
| 775 | count = mc_read (fd, buffer, count); |
| 776 | if (count == -1) ERRNOR (errno, -1); |
775 | 777 | |
776 | 778 | FH->pos += count; |
777 | 779 | return count; |
-
diff --git a/vfs/undelfs.c b/vfs/undelfs.c
index 3f45570..43fea75 100644
a
|
b
|
undelfs_loaddel (void) |
200 | 200 | message (D_ERROR, undelfserr, _(" while allocating block buffer ")); |
201 | 201 | goto free_delarray; |
202 | 202 | } |
203 | | if ((retval = ext2fs_open_inode_scan (fs, 0, &scan))) { |
| 203 | retval = ext2fs_open_inode_scan (fs, 0, &scan); |
| 204 | if (retval) { |
204 | 205 | message (D_ERROR, undelfserr, _(" open_inode_scan: %d "), retval); |
205 | 206 | goto free_block_buf; |
206 | 207 | } |
207 | | if ((retval = ext2fs_get_next_inode (scan, &ino, &inode))) { |
| 208 | retval = ext2fs_get_next_inode (scan, &ino, &inode); |
| 209 | if (retval) { |
208 | 210 | message (D_ERROR, undelfserr, _(" while starting inode scan %d "), |
209 | 211 | retval); |
210 | 212 | goto error_out; |
… |
… |
undelfs_chdir(struct vfs_class *me, const char *path) |
640 | 642 | /* We may use access because ext2 file systems are local */ |
641 | 643 | /* this could be fixed by making an ext2fs io manager to use */ |
642 | 644 | /* our vfs, but that is left as an excercise for the reader */ |
643 | | if ((fd = open (file, O_RDONLY)) == -1){ |
| 645 | fd = open (file, O_RDONLY); |
| 646 | if (fd == -1) { |
644 | 647 | message (D_ERROR, undelfserr, _(" Cannot open file %s "), file); |
645 | 648 | g_free (f); |
646 | 649 | g_free (file); |
-
diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c
index 79bec13..db50f7e 100644
a
|
b
|
is_week (const char *str, struct tm *tim) |
355 | 355 | if (!str) |
356 | 356 | return 0; |
357 | 357 | |
358 | | if ((pos = strstr (week, str)) != NULL) { |
| 358 | pos = strstr (week, str); |
| 359 | if (pos != NULL) { |
359 | 360 | if (tim != NULL) |
360 | 361 | tim->tm_wday = (pos - week) / 3; |
361 | 362 | return 1; |
… |
… |
is_month (const char *str, struct tm *tim) |
372 | 373 | if (!str) |
373 | 374 | return 0; |
374 | 375 | |
375 | | if ((pos = strstr (month, str)) != NULL) { |
| 376 | pos = strstr (month, str); |
| 377 | if (pos != NULL) { |
376 | 378 | if (tim != NULL) |
377 | 379 | tim->tm_mon = (pos - month) / 3; |
378 | 380 | return 1; |
… |
… |
is_time (const char *str, struct tm *tim) |
412 | 414 | if (!str) |
413 | 415 | return 0; |
414 | 416 | |
415 | | if ((p = strchr (str, ':')) && (p2 = strrchr (str, ':'))) { |
| 417 | p = strchr (str, ':'); |
| 418 | p2 = strrchr (str, ':'); |
| 419 | if (p && p2) { |
416 | 420 | if (p != p2) { |
417 | 421 | if (sscanf |
418 | 422 | (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, |
… |
… |
vfs_parse_filedate (int idx, time_t *t) |
741 | 745 | |
742 | 746 | tim.tm_year--; |
743 | 747 | |
744 | | if (l10n || (*t = mktime (&tim)) < 0) |
| 748 | *t = mktime (&tim); |
| 749 | if (l10n || (*t < 0)) |
745 | 750 | *t = 0; |
746 | 751 | return idx; |
747 | 752 | } |
-
diff --git a/vfs/vfs.c b/vfs/vfs.c
index 57ff3d7..9875b85 100644
a
|
b
|
vfs_strip_suffix_from_filename (const char *filename) |
233 | 233 | vfs_die ("vfs_strip_suffix_from_path got NULL: impossible"); |
234 | 234 | |
235 | 235 | p = g_strdup (filename); |
236 | | if (!(semi = strrchr (p, '#'))) |
| 236 | semi = strrchr (p, '#'); |
| 237 | if (!semi) |
237 | 238 | return p; |
238 | 239 | |
239 | 240 | /* Avoid last class (localfs) that would accept any prefix */ |
… |
… |
vfs_split (char *path, char **inpath, char **op) |
306 | 307 | if (slash) |
307 | 308 | *slash = 0; |
308 | 309 | |
309 | | if ((ret = vfs_prefix_to_class (semi+1))){ |
| 310 | ret = vfs_prefix_to_class (semi + 1); |
| 311 | if (ret) { |
310 | 312 | if (op) |
311 | 313 | *op = semi + 1; |
312 | 314 | if (inpath) |