Просмотр исходного кода

Ticket #2097: clean up before 4.7.2 release.

Split assignments and conditions. Type accuracy. Minor optimization.

Thanks Vit Rosin for original patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 15 лет назад
Родитель
Сommit
4cea5be1ac
10 измененных файлов с 195 добавлено и 125 удалено
  1. 2 1
      lib/logging.c
  2. 8 4
      lib/util.c
  3. 10 7
      lib/utilunix.c
  4. 15 8
      lib/vfs/mc-vfs/cpio.c
  5. 17 9
      lib/vfs/mc-vfs/direntry.c
  6. 26 22
      lib/vfs/mc-vfs/fish.c
  7. 39 27
      lib/vfs/mc-vfs/ftpfs.c
  8. 45 32
      lib/vfs/mc-vfs/mcfs.c
  9. 28 13
      lib/vfs/mc-vfs/mcserv.c
  10. 5 2
      lib/vfs/mc-vfs/sfs.c

+ 2 - 1
lib/logging.c

@@ -67,7 +67,8 @@ mc_log(const char *fmt, ...)
 	if (is_logging_enabled()) {
 	if (is_logging_enabled()) {
 		va_start(args, fmt);
 		va_start(args, fmt);
 		logfilename = g_strdup_printf("%s/%s/log", home_dir, MC_USERCONF_DIR);
 		logfilename = g_strdup_printf("%s/%s/log", home_dir, MC_USERCONF_DIR);
-		if ((f = fopen(logfilename, "a")) != NULL) {
+		f = fopen (logfilename, "a");
+		if (f != NULL) {
 			(void)vfprintf(f, fmt, args);
 			(void)vfprintf(f, fmt, args);
 			(void)fclose(f);
 			(void)fclose(f);
 		}
 		}

+ 8 - 4
lib/util.c

@@ -526,13 +526,15 @@ strip_password (char *p, int has_prefix)
 
 
         if (has_prefix)
         if (has_prefix)
         {
         {
-            if ((q = strstr (p, prefixes[i].name)) == 0)
+            q = strstr (p, prefixes[i].name);
+            if (q == NULL)
                 continue;
                 continue;
             else
             else
                 p = q + prefixes[i].len;
                 p = q + prefixes[i].len;
         }
         }
 
 
-        if ((dir = strchr (p, PATH_SEP)) != NULL)
+        dir = strchr (p, PATH_SEP);
+        if (dir != NULL)
             *dir = '\0';
             *dir = '\0';
 
 
         /* search for any possible user */
         /* search for any possible user */
@@ -559,7 +561,8 @@ strip_home_and_password (const char *dir)
     size_t len;
     size_t len;
     static char newdir[MC_MAXPATHLEN];
     static char newdir[MC_MAXPATHLEN];
 
 
-    if (home_dir && !strncmp (dir, home_dir, len = strlen (home_dir)) &&
+    len = strlen (home_dir);
+    if (home_dir != NULL && strncmp (dir, home_dir, len) == 0 &&
         (dir[len] == PATH_SEP || dir[len] == '\0'))
         (dir[len] == PATH_SEP || dir[len] == '\0'))
     {
     {
         newdir[0] = '~';
         newdir[0] = '~';
@@ -619,7 +622,8 @@ load_file (const char *filename)
     char *data;
     char *data;
     long read_size;
     long read_size;
 
 
-    if ((data_file = fopen (filename, "r")) == NULL)
+    data_file = fopen (filename, "r");
+    if (data_file == NULL)
     {
     {
         return 0;
         return 0;
     }
     }

+ 10 - 7
lib/utilunix.c

@@ -94,11 +94,12 @@ get_owner (int uid)
     char *name;
     char *name;
     static int uid_last;
     static int uid_last;
 
 
-    if ((name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE)) != NULL)
+    name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE);
+    if (name != NULL)
         return name;
         return name;
 
 
     pwd = getpwuid (uid);
     pwd = getpwuid (uid);
-    if (pwd)
+    if (pwd != NULL)
     {
     {
         i_cache_add (uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, &uid_last);
         i_cache_add (uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, &uid_last);
         return pwd->pw_name;
         return pwd->pw_name;
@@ -118,11 +119,12 @@ get_group (int gid)
     char *name;
     char *name;
     static int gid_last;
     static int gid_last;
 
 
-    if ((name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE)) != NULL)
+    name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE);
+    if (name != NULL)
         return name;
         return name;
 
 
     grp = getgrgid (gid);
     grp = getgrgid (gid);
-    if (grp)
+    if (grp != NULL)
     {
     {
         i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
         i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
         return grp->gr_name;
         return grp->gr_name;
@@ -161,7 +163,8 @@ my_system (int flags, const char *shell, const char *command)
     /* handler messing the screen after the SIGCONT */
     /* handler messing the screen after the SIGCONT */
     sigaction (SIGTSTP, &startup_handler, &save_stop);
     sigaction (SIGTSTP, &startup_handler, &save_stop);
 
 
-    if ((pid = fork ()) < 0)
+    pid = fork ();
+    if (pid < 0)
     {
     {
         fprintf (stderr, "\n\nfork () = -1\n");
         fprintf (stderr, "\n\nfork () = -1\n");
         return -1;
         return -1;
@@ -179,12 +182,12 @@ my_system (int flags, const char *shell, const char *command)
         {
         {
             gchar **shell_tokens;
             gchar **shell_tokens;
             const gchar *only_cmd;
             const gchar *only_cmd;
-            shell_tokens = g_strsplit (shell, " ", 2);
 
 
+            shell_tokens = g_strsplit (shell, " ", 2);
             if (shell_tokens == NULL)
             if (shell_tokens == NULL)
                 only_cmd = shell;
                 only_cmd = shell;
             else
             else
-                only_cmd = (*shell_tokens) ? *shell_tokens : shell;
+                only_cmd = (*shell_tokens != NULL) ? *shell_tokens : shell;
 
 
             execlp (only_cmd, shell, command, (char *) NULL);
             execlp (only_cmd, shell, command, (char *) NULL);
 
 

+ 15 - 8
lib/vfs/mc-vfs/cpio.c

@@ -165,7 +165,8 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
     mode_t mode;
     mode_t mode;
     struct vfs_s_inode *root;
     struct vfs_s_inode *root;
 
 
-    if ((fd = mc_open (name, O_RDONLY)) == -1) {
+    fd = mc_open (name, O_RDONLY);
+    if (fd == -1) {
 	message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
 	message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
 	return -1;
 	return -1;
     }
     }
@@ -181,7 +182,8 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
 
 
 	mc_close (fd);
 	mc_close (fd);
 	s = g_strconcat (name, decompress_extension (type), (char *) NULL);
 	s = g_strconcat (name, decompress_extension (type), (char *) NULL);
-	if ((fd = mc_open (s, O_RDONLY)) == -1) {
+	fd = mc_open (s, O_RDONLY);
+	if (fd == -1) {
 	    message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
 	    message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
 	    g_free (s);
 	    g_free (s);
 	    return -1;
 	    return -1;
@@ -247,7 +249,8 @@ static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super)
 		ptr -= top - 128;
 		ptr -= top - 128;
 		top = 128;
 		top = 128;
 	    }
 	    }
-	    if((tmp = mc_read(super->u.arch.fd, buf, top)) == 0 || tmp == -1) {
+	    tmp = mc_read (super->u.arch.fd, buf, top);
+	    if (tmp == 0 || tmp == -1) {
 		message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name);
 		message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name);
 		cpio_free_archive(me, super);
 		cpio_free_archive(me, super);
 		return CPIO_UNKNOWN;
 		return CPIO_UNKNOWN;
@@ -419,7 +422,8 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
     char *name;
     char *name;
     struct stat st;
     struct stat st;
 
 
-    if((len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH)
+    len = mc_read (super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH);
+    if (len < HEAD_LENGTH)
 	return STATUS_EOF;
 	return STATUS_EOF;
     CPIO_POS(super) += len;
     CPIO_POS(super) += len;
     if(super->u.arch.type == CPIO_BINRE) {
     if(super->u.arch.type == CPIO_BINRE) {
@@ -435,7 +439,8 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
 	return STATUS_FAIL;
 	return STATUS_FAIL;
     }
     }
     name = g_malloc(u.buf.c_namesize);
     name = g_malloc(u.buf.c_namesize);
-    if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) {
+    len = mc_read (super->u.arch.fd, name, u.buf.c_namesize);
+    if (len < u.buf.c_namesize) {
 	g_free(name);
 	g_free(name);
 	return STATUS_EOF;
 	return STATUS_EOF;
     }
     }
@@ -493,8 +498,8 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup
 	return STATUS_FAIL;
 	return STATUS_FAIL;
     }
     }
     name = g_malloc(hd.c_namesize);
     name = g_malloc(hd.c_namesize);
-    if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 ||
-       (unsigned long) len < hd.c_namesize) {
+    len = mc_read (super->u.arch.fd, name, hd.c_namesize);
+    if ((len == -1) || ((unsigned long) len < hd.c_namesize)) {
 	g_free (name);
 	g_free (name);
 	return STATUS_EOF;
 	return STATUS_EOF;
     }
     }
@@ -669,7 +674,9 @@ static ssize_t cpio_read(void *fh, char *buffer, int count)
 
 
     count = MIN(count, FH->ino->st.st_size - FH->pos);
     count = MIN(count, FH->ino->st.st_size - FH->pos);
 
 
-    if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1);
+    count = mc_read (fd, buffer, count);
+    if (count == -1) 
+        ERRNOR (errno, -1);
 
 
     FH->pos += count;
     FH->pos += count;
     return count;
     return count;

+ 17 - 9
lib/vfs/mc-vfs/direntry.c

@@ -493,11 +493,14 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **
 
 
     archive_name = inname;
     archive_name = inname;
     vfs_split (inname, &local, &op);
     vfs_split (inname, &local, &op);
-    retval = (local) ? local : "";
+    retval = (local != NULL) ? local : "";
 
 
-    if (MEDATA->archive_check)
-        if (!(cookie = MEDATA->archive_check (me, archive_name, op)))
+    if (MEDATA->archive_check != NULL)
+    {
+        cookie = MEDATA->archive_check (me, archive_name, op);
+        if (cookie == NULL)
             return NULL;
             return NULL;
+    }
 
 
     for (super = MEDATA->supers; super != NULL; super = super->next)
     for (super = MEDATA->supers; super != NULL; super = super->next)
     {
     {
@@ -686,7 +689,9 @@ static int
 vfs_s_chdir (struct vfs_class *me, const char *path)
 vfs_s_chdir (struct vfs_class *me, const char *path)
 {
 {
     void *data;
     void *data;
-    if (!(data = vfs_s_opendir (me, path)))
+
+    data = vfs_s_opendir (me, path);
+    if (data == NULL)
         return -1;
         return -1;
     vfs_s_closedir (data);
     vfs_s_closedir (data);
     return 0;
     return 0;
@@ -699,7 +704,8 @@ vfs_s_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, i
 {
 {
     struct vfs_s_inode *ino;
     struct vfs_s_inode *ino;
 
 
-    if (!(ino = vfs_s_inode_from_path (me, path, flag)))
+    ino = vfs_s_inode_from_path (me, path, flag);
+    if (ino == NULL)
         return -1;
         return -1;
     *buf = ino->st;
     *buf = ino->st;
     return 0;
     return 0;
@@ -757,7 +763,8 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
     char *q;
     char *q;
     struct vfs_s_inode *ino;
     struct vfs_s_inode *ino;
 
 
-    if ((q = vfs_s_get_path (me, file, &super, 0)) == NULL)
+    q = vfs_s_get_path (me, file, &super, 0);
+    if (q == NULL)
         return NULL;
         return NULL;
     ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
     ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
     if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
     if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
@@ -1115,7 +1122,7 @@ vfs_s_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
         {
         {
             struct vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0);
             struct vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0);
 
 
-            if (!ino)
+            if (ino == NULL)
                 return 0;
                 return 0;
             if (arg)
             if (arg)
                 ino->super->want_stale = 1;
                 ino->super->want_stale = 1;
@@ -1142,10 +1149,11 @@ vfs_s_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
 static vfsid
 static vfsid
 vfs_s_getid (struct vfs_class *me, const char *path)
 vfs_s_getid (struct vfs_class *me, const char *path)
 {
 {
-    struct vfs_s_super *archive;
+    struct vfs_s_super *archive = NULL;
     char *p;
     char *p;
 
 
-    if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
+    p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN);
+    if (p == NULL)
         return NULL;
         return NULL;
     g_free (p);
     g_free (p);
     return (vfsid) archive;
     return (vfsid) archive;

+ 26 - 22
lib/vfs/mc-vfs/fish.c

@@ -206,7 +206,9 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[])
     if ((pipe (fileset1) < 0) || (pipe (fileset2) < 0))
     if ((pipe (fileset1) < 0) || (pipe (fileset2) < 0))
         vfs_die ("Cannot pipe(): %m.");
         vfs_die ("Cannot pipe(): %m.");
 
 
-    if ((res = fork ()))
+    res = fork ();
+
+    if (res != 0)
     {
     {
         if (res < 0)
         if (res < 0)
             vfs_die ("Cannot fork(): %m.");
             vfs_die ("Cannot fork(): %m.");
@@ -828,18 +830,17 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
             close (h);
             close (h);
             h = open ("/dev/zero", O_RDONLY);
             h = open ("/dev/zero", O_RDONLY);
         }
         }
+
         if (n == 0)
         if (n == 0)
             break;
             break;
-        if ((t = write (SUP.sockw, buffer, n)) != n)
+
+        t = write (SUP.sockw, buffer, n);
+        if (t != n)
         {
         {
             if (t == -1)
             if (t == -1)
-            {
                 me->verrno = errno;
                 me->verrno = errno;
-            }
             else
             else
-            {
                 me->verrno = EIO;
                 me->verrno = EIO;
-            }
             goto error_return;
             goto error_return;
         }
         }
         tty_disable_interrupt_key ();
         tty_disable_interrupt_key ();
@@ -923,14 +924,15 @@ fish_linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
     do
     do
     {
     {
         n = MIN (8192, fh->u.fish.total - fh->u.fish.got);
         n = MIN (8192, fh->u.fish.total - fh->u.fish.got);
-        if (n)
+        if (n != 0)
         {
         {
-            if ((n = read (SUP.sockr, buffer, n)) < 0)
+            n = read (SUP.sockr, buffer, n);
+            if (n < 0)
                 return;
                 return;
             fh->u.fish.got += n;
             fh->u.fish.got += n;
         }
         }
     }
     }
-    while (n);
+    while (n != 0);
 
 
     if (fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
     if (fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
         print_vfs_message (_("Error reported after abort."));
         print_vfs_message (_("Error reported after abort."));
@@ -955,9 +957,9 @@ fish_linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
 
 
     if (n > 0)
     if (n > 0)
         fh->u.fish.got += n;
         fh->u.fish.got += n;
-    if (n < 0)
+    else if (n < 0)
         fish_linear_abort (me, fh);
         fish_linear_abort (me, fh);
-    if ((!n) && ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)))
+    else if (fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
         ERRNOR (E_REMOTE, -1);
         ERRNOR (E_REMOTE, -1);
     ERRNOR (errno, n);
     ERRNOR (errno, n);
 }
 }
@@ -1018,17 +1020,18 @@ fish_send_command (struct vfs_class *me, struct vfs_s_super *super, const char *
     const char *crpath; \
     const char *crpath; \
     char *rpath, *mpath = g_strdup (path); \
     char *rpath, *mpath = g_strdup (path); \
     struct vfs_s_super *super; \
     struct vfs_s_super *super; \
-    if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) \
+    crpath = vfs_s_get_path_mangle (me, mpath, &super, 0); \
+    if (crpath == NULL) \
     { \
     { \
 	g_free (mpath); \
 	g_free (mpath); \
 	return -1; \
 	return -1; \
     } \
     } \
-    rpath = strutils_shell_escape(crpath); \
+    rpath = strutils_shell_escape (crpath); \
     g_free (mpath);
     g_free (mpath);
 
 
 #define POSTFIX(flags) \
 #define POSTFIX(flags) \
     g_free (rpath); \
     g_free (rpath); \
-    return fish_send_command(me, super, buf, flags);
+    return fish_send_command (me, super, buf, flags);
 
 
 static int
 static int
 fish_chmod (struct vfs_class *me, const char *path, int mode)
 fish_chmod (struct vfs_class *me, const char *path, int mode)
@@ -1055,12 +1058,14 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat
     const char *crpath1, *crpath2; \
     const char *crpath1, *crpath2; \
     char *rpath1, *rpath2, *mpath1, *mpath2; \
     char *rpath1, *rpath2, *mpath1, *mpath2; \
     struct vfs_s_super *super1, *super2; \
     struct vfs_s_super *super1, *super2; \
-    if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) \
+    crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0); \
+    if (crpath1 == NULL) \
     { \
     { \
         g_free (mpath1); \
         g_free (mpath1); \
         return -1; \
         return -1; \
     } \
     } \
-    if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) \
+    crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0); \
+    if (crpath2 == NULL) \
     { \
     { \
         g_free (mpath1); \
         g_free (mpath1); \
         g_free (mpath2); \
         g_free (mpath2); \
@@ -1119,10 +1124,12 @@ fish_chown (struct vfs_class *me, const char *path, int owner, int group)
     struct passwd *pw;
     struct passwd *pw;
     struct group *gr;
     struct group *gr;
 
 
-    if ((pw = getpwuid (owner)) == NULL)
+    pw = getpwuid (owner);
+    if (pw == NULL)
         return 0;
         return 0;
 
 
-    if ((gr = getgrgid (group)) == NULL)
+    gr = getgrgid (group);
+    if (gr == NULL)
         return 0;
         return 0;
 
 
     sowner = pw->pw_name;
     sowner = pw->pw_name;
@@ -1179,10 +1186,7 @@ fish_exists (struct vfs_class *me, const char *path)
 
 
     g_free (rpath);
     g_free (rpath);
 
 
-    if (fish_send_command (me, super, buf, OPT_FLUSH) == 0)
-        return 1;
-
-    return 0;
+    return (fish_send_command (me, super, buf, OPT_FLUSH) == 0) ? 1 : 0;
 }
 }
 
 
 
 

+ 39 - 27
lib/vfs/mc-vfs/ftpfs.c

@@ -227,8 +227,10 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
             memmove (p + 1, p + 2, strlen (p + 2) + 1);
             memmove (p + 1, p + 2, strlen (p + 2) + 1);
 
 
         /* strip trailing "/." */
         /* strip trailing "/." */
-        if ((p = strrchr (ret, '/')) && *(p + 1) == '.' && *(p + 2) == '\0')
+        p = strrchr (ret, '/');
+        if ((p != NULL) && (*(p + 1) == '.') && (*(p + 2) == '\0'))
             *p = '\0';
             *p = '\0';
+
         return ret;
         return ret;
     }
     }
 }
 }
@@ -608,33 +610,37 @@ ftpfs_load_no_proxy_list (void)
         return;
         return;
 
 
     mc_file = concat_dir_and_file (mc_home, "mc.no_proxy");
     mc_file = concat_dir_and_file (mc_home, "mc.no_proxy");
-    if (exist_file (mc_file) && (npf = fopen (mc_file, "r")))
+    if (exist_file (mc_file))
     {
     {
-        while (fgets (s, sizeof (s), npf))
+        npf = fopen (mc_file, "r");
+        if (npf != NULL)
         {
         {
-            if (!(p = strchr (s, '\n')))
-            {                   /* skip bogus entries */
-                while ((c = fgetc (npf)) != EOF && c != '\n')
-                    ;
-                continue;
-            }
+            while (fgets (s, sizeof (s), npf) != NULL)
+            {
+                p = strchr (s, '\n');
+                if (p == NULL) {  /* skip bogus entries */
+                {
+                    while ((c = fgetc (npf)) != EOF && c != '\n')
+                        ;
+                    continue;
+                }
 
 
-            if (p == s)
-                continue;
+                if (p == s)
+                    continue;
 
 
-            *p = '\0';
+                *p = '\0';
 
 
-            np = g_new (struct no_proxy_entry, 1);
-            np->domain = g_strdup (s);
-            np->next = NULL;
-            if (no_proxy)
-                current->next = np;
-            else
-                no_proxy = np;
-            current = np;
+                np = g_new (struct no_proxy_entry, 1);
+                np->domain = g_strdup (s);
+                np->next   = NULL;
+                if (no_proxy)
+                    current->next = np;
+                else
+                    no_proxy = np;
+                current = np;
+            }
+            fclose (npf);
         }
         }
-
-        fclose (npf);
     }
     }
     g_free (mc_file);
     g_free (mc_file);
 }
 }
@@ -1169,10 +1175,12 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
 {
 {
     struct sockaddr_storage from;
     struct sockaddr_storage from;
     int s, j, data;
     int s, j, data;
-    socklen_t fromlen = sizeof (from);
+    socklen_t fromlen = sizeof(from);
 
 
-    if ((s = ftpfs_initconn (me, super)) == -1)
+    s = ftpfs_initconn (me, super);
+    if (s == -1)
         return -1;
         return -1;
+
     if (ftpfs_changetype (me, super, isbinary) == -1)
     if (ftpfs_changetype (me, super, isbinary) == -1)
         return -1;
         return -1;
     if (reget > 0)
     if (reget > 0)
@@ -1191,6 +1199,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
     }
     }
     else
     else
         j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd);
         j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd);
+
     if (j != PRELIM)
     if (j != PRELIM)
         ERRNOR (EPERM, -1);
         ERRNOR (EPERM, -1);
     tty_enable_interrupt_key ();
     tty_enable_interrupt_key ();
@@ -1750,7 +1759,8 @@ ftpfs_send_command (struct vfs_class *me, const char *filename, const char *cmd,
     int r;
     int r;
     int flush_directory_cache = (flags & OPT_FLUSH);
     int flush_directory_cache = (flags & OPT_FLUSH);
 
 
-    if (!(rpath = vfs_s_get_path_mangle (me, mpath, &super, 0)))
+    rpath = vfs_s_get_path_mangle (me, mpath, &super, 0);
+    if (rpath == NULL)
     {
     {
         g_free (mpath);
         g_free (mpath);
         return -1;
         return -1;
@@ -2216,8 +2226,10 @@ ftpfs_netrc_lookup (const char *host, char **login, char **pass)
 
 
     /* Find our own domain name */
     /* Find our own domain name */
     if (gethostname (hostname, sizeof (hostname)) < 0)
     if (gethostname (hostname, sizeof (hostname)) < 0)
-        *hostname = 0;
-    if (!(domain = strchr (hostname, '.')))
+        *hostname = '\0';
+
+    domain = strchr (hostname, '.');
+    if (domain == NULL)
         domain = "";
         domain = "";
 
 
     /* Scan for "default" and matching "machine" keywords */
     /* Scan for "default" and matching "machine" keywords */

+ 45 - 32
lib/vfs/mc-vfs/mcfs.c

@@ -212,7 +212,8 @@ mcfs_get_remote_port (struct sockaddr_in *sin, int *version)
 #ifdef HAVE_PMAP_GETPORT
 #ifdef HAVE_PMAP_GETPORT
     int port;
     int port;
     for (*version = RPC_PROGVER; *version >= 1; (*version)--)
     for (*version = RPC_PROGVER; *version >= 1; (*version)--)
-	if (port = pmap_getport (sin, RPC_PROGNUM, *version, IPPROTO_TCP))
+	port = pmap_getport (sin, RPC_PROGNUM, *version, IPPROTO_TCP);
+	if (port != NULL)
 	    return port;
 	    return port;
 #endif				/* HAVE_PMAP_GETPORT */
 #endif				/* HAVE_PMAP_GETPORT */
     *version = 1;
     *version = 1;
@@ -237,11 +238,13 @@ mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal
     server_address.sin_family = AF_INET;
     server_address.sin_family = AF_INET;
 
 
     /*  Try to use the dotted decimal number */
     /*  Try to use the dotted decimal number */
-    if ((inaddr = inet_addr (host)) != INADDR_NONE)
+    inaddr = inet_addr (host);
+    if (inaddr != INADDR_NONE) {
 	memcpy ((char *) &server_address.sin_addr, (char *) &inaddr,
 	memcpy ((char *) &server_address.sin_addr, (char *) &inaddr,
 		sizeof (inaddr));
 		sizeof (inaddr));
-    else {
-	if ((hp = gethostbyname (host)) == NULL) {
+    } else {
+	hp = gethostbyname (host);
+	if (hp == NULL) {
 	    message (D_ERROR, caller, _(" Cannot locate hostname: %s "),
 	    message (D_ERROR, caller, _(" Cannot locate hostname: %s "),
 			host);
 			host);
 	    return 0;
 	    return 0;
@@ -259,8 +262,8 @@ mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal
 	*version = 1;
 	*version = 1;
 
 
     server_address.sin_port = htons (*port);
     server_address.sin_port = htons (*port);
-
-    if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
+    my_socket = socket (AF_INET, SOCK_STREAM, 0);
+    if (my_socket < 0) {
 	message (D_ERROR, caller, _(" Cannot create socket: %s "),
 	message (D_ERROR, caller, _(" Cannot create socket: %s "),
 		    unix_error_string (errno));
 		    unix_error_string (errno));
 	return 0;
 	return 0;
@@ -340,10 +343,8 @@ mcfs_open_link (char *host, char *user, int *port, char *netrcpass)
 	message (D_ERROR, MSG_ERROR, _(" Too many open connections "));
 	message (D_ERROR, MSG_ERROR, _(" Too many open connections "));
 	return 0;
 	return 0;
     }
     }
-
-    if (!
-	(sock =
-	 mcfs_open_tcp_link (host, user, port, netrcpass, &version)))
+    sock = mcfs_open_tcp_link (host, user, port, netrcpass, &version);
+    if (sock == 0)
 	return 0;
 	return 0;
 
 
     bucket = mcfs_get_free_bucket ();
     bucket = mcfs_get_free_bucket ();
@@ -394,12 +395,14 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
      * remote portmapper to get the port number
      * remote portmapper to get the port number
      */
      */
     port = 0;
     port = 0;
-    if ((remote_path =
-	 mcfs_get_host_and_username (path, &host, &user, &port, &pass)))
-	if (!(*mc = mcfs_open_link (host, user, &port, pass))) {
+    remote_path = mcfs_get_host_and_username (path, &host, &user, &port, &pass);
+    if (remote_path != NULL) {
+	*mc = mcfs_open_link (host, user, &port, pass);
+	if (*mc == NULL) {
 	    g_free (remote_path);
 	    g_free (remote_path);
 	    remote_path = NULL;
 	    remote_path = NULL;
 	}
 	}
+    }
     g_free (host);
     g_free (host);
     g_free (user);
     g_free (user);
     if (pass)
     if (pass)
@@ -445,10 +448,12 @@ mcfs_rpc_two_paths (int command, const char *s1, const char *s2)
     mcfs_connection *mc;
     mcfs_connection *mc;
     char *r1, *r2;
     char *r1, *r2;
 
 
-    if ((r1 = mcfs_get_path (&mc, s1)) == 0)
+    r1 = mcfs_get_path (&mc, s1);
+    if (r1 == NULL)
 	return -1;
 	return -1;
 
 
-    if ((r2 = mcfs_get_path (&mc, s2)) == 0) {
+    r2 = mcfs_get_path (&mc, s2);
+    if (r2 == NULL) {
 	g_free (r1);
 	g_free (r1);
 	return -1;
 	return -1;
     }
     }
@@ -466,7 +471,8 @@ mcfs_rpc_path (int command, const char *path)
     mcfs_connection *mc;
     mcfs_connection *mc;
     char *remote_file;
     char *remote_file;
 
 
-    if ((remote_file = mcfs_get_path (&mc, path)) == 0)
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock,
     rpc_send (mc->sock,
@@ -482,7 +488,8 @@ mcfs_rpc_path_int (int command, const char *path, int data)
     mcfs_connection *mc;
     mcfs_connection *mc;
     char *remote_file;
     char *remote_file;
 
 
-    if ((remote_file = mcfs_get_path (&mc, path)) == 0)
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock,
     rpc_send (mc->sock,
@@ -499,7 +506,8 @@ mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2)
     mcfs_connection *mc;
     mcfs_connection *mc;
     char *remote_file;
     char *remote_file;
 
 
-    if ((remote_file = mcfs_get_path (&mc, path)) == 0)
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock,
     rpc_send (mc->sock,
@@ -537,7 +545,8 @@ mcfs_open (struct vfs_class *me, const char *file, int flags, int mode)
 
 
     (void) me;
     (void) me;
 
 
-    if (!(remote_file = mcfs_get_path (&mc, file)))
+    remote_file = mcfs_get_path (&mc, file);
+    if (remote_file == NULL)
 	return 0;
 	return 0;
 
 
     rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT,
     rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT,
@@ -661,8 +670,9 @@ mcfs_opendir (struct vfs_class *me, const char *dirname)
 
 
     (void) me;
     (void) me;
 
 
-    if (!(remote_dir = mcfs_get_path (&mc, dirname)))
-	return 0;
+    remote_dir = mcfs_get_path (&mc, dirname);
+    if (remote_dir == NULL)
+	return NULL;
 
 
     rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir,
     rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir,
 	      RPC_END);
 	      RPC_END);
@@ -670,10 +680,10 @@ mcfs_opendir (struct vfs_class *me, const char *dirname)
 
 
     if (0 ==
     if (0 ==
 	rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
 	rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
-	return 0;
+	return NULL;
 
 
     if (mcfs_is_error (result, error_num))
     if (mcfs_is_error (result, error_num))
-	return 0;
+	return NULL;
 
 
     handle = result;
     handle = result;
 
 
@@ -683,7 +693,7 @@ mcfs_opendir (struct vfs_class *me, const char *dirname)
     mcfs_info->entries = 0;
     mcfs_info->entries = 0;
     mcfs_info->current = 0;
     mcfs_info->current = 0;
 
 
-    return mcfs_info;
+    return (void *) mcfs_info;
 }
 }
 
 
 static int mcfs_get_stat_info (mcfs_connection * mc, struct stat *buf);
 static int mcfs_get_stat_info (mcfs_connection * mc, struct stat *buf);
@@ -880,7 +890,8 @@ mcfs_stat_cmd (int cmd, const char *path, struct stat *buf)
     mcfs_connection *mc;
     mcfs_connection *mc;
     int status, error;
     int status, error;
 
 
-    if ((remote_file = mcfs_get_path (&mc, path)) == 0)
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
     rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
@@ -970,7 +981,8 @@ mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
 
 
     (void) me;
     (void) me;
 
 
-    if (!(file = mcfs_get_path (&mc, path)))
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     status = 0;
     status = 0;
@@ -1005,7 +1017,8 @@ mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
 
 
     (void) me;
     (void) me;
 
 
-    if (!(remote_file = mcfs_get_path (&mc, path)))
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file,
     rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file,
@@ -1062,7 +1075,8 @@ mcfs_chdir (struct vfs_class *me, const char *path)
 
 
     (void) me;
     (void) me;
 
 
-    if (!(remote_dir = mcfs_get_path (&mc, path)))
+    remote_file = mcfs_get_path (&mc, path);
+    if (remote_file == NULL)
 	return -1;
 	return -1;
 
 
     rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir,
     rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir,
@@ -1137,12 +1151,11 @@ mcfs_forget (const char *path)
 	return;
 	return;
 
 
     path += 5;
     path += 5;
-    if (path[0] == '/' && path[1] == '/')
+    if ((path[0] == '/') && (path[1] == '/'))
 	path += 2;
 	path += 2;
 
 
-    if ((p =
-	 mcfs_get_host_and_username (path, &host, &user, &port,
-				     &pass)) == 0) {
+    p = mcfs_get_host_and_username (path, &host, &user, &port, &pass);
+    if (p == NULL) {
 	g_free (host);
 	g_free (host);
 	g_free (user);
 	g_free (user);
 	if (pass)
 	if (pass)

+ 28 - 13
lib/vfs/mc-vfs/mcserv.c

@@ -799,15 +799,22 @@ mc_pam_auth (const char *username, const char *password)
     up.password = password;
     up.password = password;
     conv.appdata_ptr = &up;
     conv.appdata_ptr = &up;
 
 
-    if ((status =
-	 pam_start ("mcserv", username, &conv, &pamh)) != PAM_SUCCESS)
+    status = pam_start ("mcserv", username, &conv, &pamh);
+    if (status != PAM_SUCCESS)
 	goto failed_pam;
 	goto failed_pam;
-    if ((status = pam_authenticate (pamh, 0)) != PAM_SUCCESS)
+
+    status = pam_authenticate (pamh, 0);
+    if (status != PAM_SUCCESS)
 	goto failed_pam;
 	goto failed_pam;
-    if ((status = pam_acct_mgmt (pamh, 0)) != PAM_SUCCESS)
+
+    status = pam_acct_mgmt (pamh, 0);
+    if (status != PAM_SUCCESS)
 	goto failed_pam;
 	goto failed_pam;
-    if ((status = pam_setcred (pamh, PAM_ESTABLISH_CRED)) != PAM_SUCCESS)
+
+    status = pam_setcred (pamh, PAM_ESTABLISH_CRED);
+    if (status != PAM_SUCCESS)
 	goto failed_pam;
 	goto failed_pam;
+
     pam_end (pamh, status);
     pam_end (pamh, status);
     return 0;
     return 0;
 
 
@@ -866,11 +873,13 @@ do_ftp_auth (const char *username, const char *password)
     local_address.sin_port = htons (21);
     local_address.sin_port = htons (21);
 
 
     /*  Convert localhost to usable format */
     /*  Convert localhost to usable format */
-    if ((inaddr = inet_addr ("127.0.0.1")) != INADDR_NONE)
+    inaddr = inet_addr ("127.0.0.1");
+    if (inaddr != INADDR_NONE)
 	memcpy ((char *) &local_address.sin_addr, (char *) &inaddr,
 	memcpy ((char *) &local_address.sin_addr, (char *) &inaddr,
 		sizeof (inaddr));
 		sizeof (inaddr));
 
 
-    if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
+    my_socket = socket (AF_INET, SOCK_STREAM, 0);
+    if (my_socket < 0) {
 	if (!isDaemon)
 	if (!isDaemon)
 	    fprintf (stderr, "do_auth: can't create socket\n");
 	    fprintf (stderr, "do_auth: can't create socket\n");
 	return 0;
 	return 0;
@@ -916,14 +925,16 @@ do_classic_auth (const char *username, const char *password)
     struct spwd *spw;
     struct spwd *spw;
 #endif
 #endif
 
 
-    if ((pw = getpwnam (username)) == 0)
+    pw = getpwnam (username);
+    if (pw == NULL)
 	return 0;
 	return 0;
 
 
 #ifdef HAVE_SHADOW
 #ifdef HAVE_SHADOW
     setspent ();
     setspent ();
 
 
     /* Password expiration is not checked! */
     /* Password expiration is not checked! */
-    if ((spw = getspnam (username)) == NULL)
+    spw = getspnam (username);
+    if (spw == NULL)
 	encr_pwd = "*";
 	encr_pwd = "*";
     else
     else
 	encr_pwd = spw->sp_pwdp;
 	encr_pwd = spw->sp_pwdp;
@@ -1200,7 +1211,8 @@ get_client (int port)
     struct sockaddr_in client_address, server_address;
     struct sockaddr_in client_address, server_address;
     int yes = 1;
     int yes = 1;
 
 
-    if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+    sock = socket (AF_INET, SOCK_STREAM, 0);
+    if (sock < 0)
 	return "Cannot create socket";
 	return "Cannot create socket";
 
 
     /* Use this to debug: */
     /* Use this to debug: */
@@ -1227,7 +1239,8 @@ get_client (int port)
 	newsocket =
 	newsocket =
 	    accept (sock, (struct sockaddr *) &client_address, &clilen);
 	    accept (sock, (struct sockaddr *) &client_address, &clilen);
 
 
-	if (isDaemon && (child = fork ())) {
+	child = fork ();
+	if (isDaemon != 0 && child != 0) {
 	    int status;
 	    int status;
 
 
 	    close (newsocket);
 	    close (newsocket);
@@ -1373,10 +1386,12 @@ main (int argc, char *argv[])
 	register_port (portnum, 0);
 	register_port (portnum, 0);
 	if (verbose)
 	if (verbose)
 	    printf ("Using port %d\n", portnum);
 	    printf ("Using port %d\n", portnum);
-	if ((result = get_client (portnum)))
+
+	result = get_client (portnum);
+	if (result != NULL)
 	    perror (result);
 	    perror (result);
 #ifdef HAVE_PMAP_SET
 #ifdef HAVE_PMAP_SET
-	if (!isDaemon)
+	if (isDaemon == 0)
 	    pmap_unset (RPC_PROGNUM, RPC_PROGVER);
 	    pmap_unset (RPC_PROGNUM, RPC_PROGVER);
 #endif
 #endif
     }
     }

+ 5 - 2
lib/vfs/mc-vfs/sfs.c

@@ -84,7 +84,8 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
 
 
     pname = g_strdup (name);
     pname = g_strdup (name);
     vfs_split (pname, &inpath, &op);
     vfs_split (pname, &inpath, &op);
-    if ((w = (*me->which) (me, op)) == -1)
+    w = (*me->which) (me, op);
+    if (w == -1)
 	vfs_die ("This cannot happen... Hopefully.\n");
 	vfs_die ("This cannot happen... Hopefully.\n");
 
 
     if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) {
     if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) {
@@ -392,9 +393,11 @@ static int sfs_init (struct vfs_class *me)
 	}
 	}
 	if (!*c)
 	if (!*c)
 	    goto invalid_line;
 	    goto invalid_line;
+
 	c++;
 	c++;
 	*(semi+1) = 0;
 	*(semi+1) = 0;
-	if ((semi = strchr (c, '\n')))
+	semi = strchr (c, '\n');
+	if (semi != NULL)
 	    *semi = 0;
 	    *semi = 0;
 
 
 	sfs_prefix [sfs_no] = g_strdup (key);
 	sfs_prefix [sfs_no] = g_strdup (key);

Некоторые файлы не были показаны из-за большого количества измененных файлов