Ticket #1923: 1923-getting-out-assignments-from-some-ifs.patch

File 1923-getting-out-assignments-from-some-ifs.patch, 51.0 KB (added by vit_r, 15 years ago)

Getting out assignments(X = foo) from some if-calls

  • edit/choosesyntax.c

    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) { 
    7777    edit_load_syntax (NULL, &names, NULL); 
    7878    while (names[count++] != NULL); 
    7979    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) { 
    8282        for (i = 0; names[i]; i++) { 
    8383            g_free (names[i]); 
    8484        } 
  • edit/edit.c

    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) 
    294294    edit->curs2 = edit->last_byte; 
    295295    buf2 = edit->curs2 >> S_EDIT_BUF_SIZE; 
    296296    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) { 
    298299        GString *errmsg = g_string_new(NULL); 
    299300        g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename); 
    300301        edit_error_dialog (_("Error"), get_sys_error (errmsg->str)); 
    int 
    487488edit_insert_file (WEdit *edit, const char *filename) 
    488489{ 
    489490    char *p; 
    490     if ((p = edit_get_filter (filename))) { 
     491    p = edit_get_filter (filename); 
     492    if (p) { 
    491493        FILE *f; 
    492494        long current = edit->curs1; 
    493495        f = (FILE *) popen (p, "r"); 
    edit_insert_file (WEdit *edit, const char *filename) 
    516518        long current = edit->curs1; 
    517519        int vertical_insertion = 0; 
    518520        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) 
    520523            return 0; 
    521524        buf = g_malloc0 (TEMP_BUF_LEN); 
    522525        blocklen = mc_read (file, buf, sizeof(VERTICAL_MAGIC)); 
    pop_action (WEdit * edit) 
    11051108        return STACK_BOTTOM; 
    11061109    } 
    11071110    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) { 
    11091113/*      edit->undo_stack[sp] = '@'; */ 
    11101114        edit->stack_pointer = (edit->stack_pointer - 1) & edit->stack_size_mask; 
    11111115        return c; 
  • edit/editcmd.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) 
    267267        goto error_save; 
    268268 
    269269/* pipe save */ 
    270     if ((p = edit_get_write_filter (savename, real_filename))) { 
     270    p = edit_get_write_filter (savename, real_filename); 
     271    if (p) { 
    271272        FILE *file; 
    272273 
    273274        mc_close (fd); 
    edit_save_as_cmd (WEdit *edit) 
    565566            if (strcmp (edit->filename, exp)) { 
    566567                int file; 
    567568                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) { 
    569571                    /* the file exists */ 
    570572                    mc_close (file); 
    571573                    /* Overwrite the current file or cancel the operation */ 
    static FILE *edit_open_macro_file (const char *r) 
    648650    FILE *fd; 
    649651    int file; 
    650652    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) { 
    652655        g_free(filename); 
    653656        return 0; 
    654657    } 
    edit_delete_macro (WEdit * edit, int k) 
    688691    (void) edit; 
    689692 
    690693    if (saved_macros_loaded) 
    691         if ((j = macro_exists (k)) < 0) 
     694        j = macro_exists (k); 
     695        if (j < 0) 
    692696            return 0; 
    693697    tmp = concat_dir_and_file (home_dir, EDIT_TEMP_FILE); 
    694698    g = fopen (tmp , "w"); 
    int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) 
    794798        if (macro_exists (k) < 0) 
    795799            return 0; 
    796800 
    797     if ((f = edit_open_macro_file ("r"))) { 
     801    f = edit_open_macro_file ("r"); 
     802    if (f) { 
    798803        struct macro dummy; 
    799804        do { 
    800805            int u; 
  • edit/editlock.c

    diff --git a/edit/editlock.c b/edit/editlock.c
    index 9199031..102c011 100644
    a b lock_get_info (const char *lockfname) 
    150150{ 
    151151    int cnt; 
    152152    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)) 
    155155        return NULL; 
    156156    buf[cnt] = '\0'; 
    157157    return buf; 
  • edit/syntax.c

    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) 
    146146    int argc; 
    147147 
    148148    while (*argv && argv < argv_end) { 
    149         if ((t = g_tree_lookup (defines, *argv))) { 
     149        t = g_tree_lookup (defines, *argv); 
     150        if (t) { 
    150151            int count = 0; 
    151152 
    152153            /* Count argv array members */ 
    static struct syntax_rule apply_rules_going_right (WEdit * edit, long i, struct 
    308309    int is_end; 
    309310    long end = 0; 
    310311    struct syntax_rule _rule = rule; 
    311  
    312     if (!(c = edit_get_byte (edit, i))) 
     312    c = edit_get_byte (edit, i); 
     313    if (!c) 
    313314        return rule; 
    314315    is_end = (rule.end == (unsigned char) i); 
    315316 
    static int read_one_line (char **line, FILE * f) 
    533534        r++; 
    534535        /* handle all of \r\n, \r, \n correctly. */ 
    535536        if (c == '\r') { 
    536             if ( (c = fgetc (f)) == '\n') 
     537            c = fgetc (f); 
     538            if (c == '\n') 
    537539                r++; 
    538540            else 
    539541                ungetc (c, f); 
    edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) 
    927929 
    928930            if (argc < 3) 
    929931                break_a; 
    930             if ((argv = g_tree_lookup (edit->defines, key))) { 
     932            argv = g_tree_lookup (edit->defines, key); 
     933            if (argv) { 
    931934                mc_defines_destroy (NULL, argv, NULL); 
    932935            } else { 
    933936                key = g_strdup (key); 
    edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, 
    10661069        if (!found && !strcmp (args[0], "include")) { 
    10671070            if (g) 
    10681071                continue; 
    1069             if (!args[1] || !(g = open_include_file (args[1]))) { 
     1072            g = open_include_file (args[1]); 
     1073            if (!args[1] || !g) { 
    10701074                result = line; 
    10711075                break; 
    10721076            } 
  • src/background.c

    diff --git a/src/background.c b/src/background.c
    index c34a95b..19dc79e 100644
    a b do_background (struct FileOpContext *ctx, char *info) 
    148148    if (pipe (back_comm) == -1) 
    149149        return -1; 
    150150 
    151     if ((pid = fork ()) == -1) { 
     151    pid = fork (); 
     152    if (pid == -1) { 
    152153        int saved_errno = errno; 
    153154        (void) close (comm[0]); 
    154155        (void) close (comm[1]); 
    do_background (struct FileOpContext *ctx, char *info) 
    172173        close (1); 
    173174        close (2); 
    174175 
    175         if ((nullfd = open ("/dev/null", O_RDWR)) != -1) { 
     176        nullfd = open ("/dev/null", O_RDWR); 
     177        if (nullfd != -1) { 
    176178            while (dup2 (nullfd, 0) == -1 && errno == EINTR); 
    177179            while (dup2 (nullfd, 1) == -1 && errno == EINTR); 
    178180            while (dup2 (nullfd, 2) == -1 && errno == EINTR); 
  • src/charsets.c

    diff --git a/src/charsets.c b/src/charsets.c
    index b374539..4b0ca95 100644
    a b load_codepages_list (void) 
    5757    char *default_codepage = NULL; 
    5858 
    5959    fname = concat_dir_and_file (mc_home, CHARSETS_INDEX); 
    60     if (!(f = fopen (fname, "r"))) { 
     60    f = fopen (fname, "r"); 
     61    if (!f) { 
    6162        fprintf (stderr, _("Warning: file %s not found\n"), fname); 
    6263        g_free (fname); 
    6364 
    6465        fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX); 
    65         if (!(f = fopen (fname, "r"))) { 
     66        f = fopen (fname, "r"); 
     67        if (!f) { 
    6668            fprintf (stderr, _("Warning: file %s not found\n"), fname); 
    6769            g_free (fname); 
    6870 
  • src/complete.c

    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 
    564564    if (found == NULL) { 
    565565        g_free (path); 
    566566        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        } 
    571574    } 
    572575 
    573576    g_free(text); 
  • src/file.c

    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, 
    10611061 
    10621062    if (!ctx->do_append) { 
    10631063        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) 
    10651066                goto retry_src_remove; 
    1066             } else 
    1067                 return return_status; 
     1067            return return_status; 
    10681068        } 
    10691069 
    10701070        if (mc_rename (s, d) == 0) { 
  • src/filenot.c

    diff --git a/src/filenot.c b/src/filenot.c
    index 15a79c1..09b4b85 100644
    a b my_mkdir_rec (char *s, mode_t mode) 
    7575    q = vfs_canon (p); 
    7676    g_free (p); 
    7777 
    78     if (!(result = my_mkdir_rec (q, mode))) 
     78    result = my_mkdir_rec (q, mode); 
     79    if (!result) 
    7980        result = mc_mkdir (s, mode); 
    8081 
    8182    g_free (q); 
  • src/hotlist.c

    diff --git a/src/hotlist.c b/src/hotlist.c
    index 03eafbe..f157a3c 100644
    a b update_path_name (void) 
    229229do { \ 
    230230    int               i; \ 
    231231\ 
    232     if ((i = strlen (current->label) + 3) > buflen) { \ 
     232    i = strlen (current->label) + 3; \ 
     233    if (i > buflen) { \ 
    233234      g_free (buf); \ 
    234235      buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \ 
    235236    } \ 
    again: 
    12611262    case '"': 
    12621263        while ((c = getc (hotlist_file)) != EOF && c != '"') { 
    12631264            if (c == '\\') 
    1264                 if ((c = getc (hotlist_file)) == EOF){ 
     1265                c = getc (hotlist_file); 
     1266                if (c == EOF) { 
    12651267                    g_string_free (tkn_buf, TRUE); 
    12661268                    return TKN_EOF; 
    12671269                } 
    again: 
    12731275            ret = TKN_STRING; 
    12741276        break; 
    12751277    case '\\': 
    1276         if ((c = getc (hotlist_file)) == EOF){ 
     1278        c = getc (hotlist_file); 
     1279        if (c == EOF) { 
    12771280            g_string_free (tkn_buf, TRUE); 
    12781281            return TKN_EOF; 
    12791282        } 
    again: 
    13071310 
    13081311#define SKIP_TO_EOL     { \ 
    13091312int _tkn; \ 
    1310 while ((_tkn = hot_next_token ()) != TKN_EOF && _tkn != TKN_EOL) ; \ 
     1313_tkn = hot_next_token (); \ 
     1314while (_tkn != TKN_EOF && _tkn != TKN_EOL) ; \ 
     1315    _tkn = hot_next_token (); \ 
    13111316} 
    13121317 
    13131318#define CHECK_TOKEN(_TKN_) \ 
    1314 if ((tkn = hot_next_token ()) != _TKN_) { \ 
     1319tkn = hot_next_token (); \ 
     1320if (tkn != _TKN_) { \ 
    13151321    hotlist_state.readonly = 1; \ 
    13161322    hotlist_state.file_error = 1; \ 
    13171323    while (tkn != TKN_EOL && tkn != TKN_EOF) \ 
    13181324        tkn = hot_next_token (); \ 
    1319 break; \ 
     1325    break; \ 
    13201326} 
    13211327 
    13221328static void 
    load_hotlist (void) 
    14611467     */ 
    14621468    hotlist->directory = g_strdup ("Hotlist"); 
    14631469 
    1464     if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0) { 
     1470    hotlist_file = fopen (hotlist_file_name, "r"); 
     1471    if (hotlist_file == 0) { 
    14651472        int     result; 
    14661473 
    14671474        load_group (hotlist); 
    int save_hotlist (void) 
    15631570    if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name) { 
    15641571        mc_util_make_backup_if_possible (hotlist_file_name, ".bak"); 
    15651572 
    1566         if ((hotlist_file = fopen (hotlist_file_name, "w")) != 0) { 
     1573        hotlist_file = fopen (hotlist_file_name, "w"); 
     1574        if (hotlist_file != 0) { 
    15671575            hot_save_group (hotlist); 
    15681576            fclose (hotlist_file); 
    15691577            stat (hotlist_file_name, &stat_buf); 
  • src/logging.c

    diff --git a/src/logging.c b/src/logging.c
    index f8ed3de..92144b8 100644
    a b mc_log(const char *fmt, ...) 
    6666        if (is_logging_enabled()) { 
    6767                va_start(args, fmt); 
    6868                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) { 
    7071                        (void)vfprintf(f, fmt, args); 
    7172                        (void)fclose(f); 
    7273                } 
  • src/main.c

    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) 
    434434{ 
    435435    const char *p; 
    436436    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) && 
    438439         ((gsize)strlen (cwd) == (gsize) p - (gsize) lwd || (p == lwd && cwd[0] == PATH_SEP && 
    439440          cwd[1] == '\0'))) { 
    440441            return (p + 1); 
  • src/mountlist.c

    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) 
    648648 
    649649        if (!getcwd(dir, _POSIX_PATH_MAX)) return (NULL); 
    650650 
    651         if ((fd = open(dir, O_RDONLY)) == -1) return (NULL); 
     651        fd = open(dir, O_RDONLY); 
     652        if (fd == -1) return (NULL); 
    652653 
    653654        i = disk_get_entry(fd, &de); 
    654655 
    my_statfs (struct my_statfs *myfs_stats, const char *path) 
    746747        struct mount_entry      *entry; 
    747748    struct fs_usage             fs_use; 
    748749 
    749         if ((entry = read_filesystem_list(0, 0)) != NULL) 
     750        entry = read_filesystem_list(0, 0); 
     751        if (entry != NULL) 
    750752        { 
    751753                get_fs_usage(entry->me_mountdir, &fs_use); 
    752754 
  • src/pipethrough.c

    diff --git a/src/pipethrough.c b/src/pipethrough.c
    index e31f816..af028bc 100644
    a b extern int pipethrough(const char *command, 
    393393                goto cleanup; 
    394394        } 
    395395 
    396         if ((pid = fork()) == (pid_t) -1) { 
     396        pid = fork(); 
     397        if (pid == (pid_t) -1) { 
    397398                propagate(&firsterror, errno); 
    398399                goto cleanup; 
    399400        } 
  • src/subshell.c

    diff --git a/src/subshell.c b/src/subshell.c
    index a80f8a1..93017a2 100644
    a b  
    5959#include "subshell.h" 
    6060#include "strutil.h" 
    6161#include "fileloc.h" 
    62  
    6362#include "../vfs/vfs.h" 
    6463 
    6564#ifndef WEXITSTATUS 
    static int pty_open_master (char *pty_name) 
    11871186            pty_name [9] = *ptr2; 
    11881187 
    11891188            /* 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) { 
    11911191                if (errno == ENOENT)  /* Different from EIO */ 
    11921192                    return -1;        /* Out of pty devices */ 
    11931193                else 
    pty_open_slave (const char *pty_name) 
    12181218        /* chown (pty_name, getuid (), group_info->gr_gid);  FIXME */ 
    12191219        /* chmod (pty_name, S_IRUSR | S_IWUSR | S_IWGRP);   FIXME */ 
    12201220    } 
    1221     if ((pty_slave = open (pty_name, O_RDWR)) == -1) 
     1221    pty_slave = open (pty_name, O_RDWR); 
     1222    if (pty_slave == -1) 
    12221223        fprintf (stderr, "open (pty_name, O_RDWR): %s\r\n", pty_name); 
    12231224    fcntl(pty_slave, F_SETFD, FD_CLOEXEC); 
    12241225    return pty_slave; 
  • src/treestore.c

    diff --git a/src/treestore.c b/src/treestore.c
    index 39db5f2..957a5c8 100644
    a b tree_store_save_to(char *name) 
    331331 
    332332        if (vfs_file_is_local(current->name)) { 
    333333            /* 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)) { 
    337336                char *encoded = encode(current->name + common); 
    338337 
    339338                i = fprintf(file, "%d:%d %s\n", current->scanned, common, 
    tree_store_save(void) 
    374373    name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_TREESTORE_FILE, NULL); 
    375374    mc_util_make_backup_if_possible (name, ".tmp"); 
    376375 
    377     if ((retval = tree_store_save_to(name)) != 0) { 
     376    retval = tree_store_save_to(name); 
     377    if (retval != 0) { 
    378378        mc_util_restore_from_backup_if_possible (name, ".tmp"); 
    379379        g_free(name); 
    380380        return retval; 
  • src/user.c

    diff --git a/src/user.c b/src/user.c
    index ed5fe81..a972e51 100644
    a b user_menu_cmd (WEdit *edit_widget) 
    782782        } 
    783783    } 
    784784 
    785     if ((data = load_file (menu)) == NULL){ 
     785    data = load_file (menu); 
     786    if (data == NULL) { 
    786787        message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), 
    787788                 menu, unix_error_string (errno)); 
    788789        g_free (menu); 
  • src/util.c

    diff --git a/src/util.c b/src/util.c
    index 08c5777..e1f18c6 100644
    a b strip_password (char *p, int has_prefix) 
    480480        char *q; 
    481481 
    482482        if (has_prefix) { 
    483             if((q = strstr (p, prefixes[i].name)) == 0) 
     483            q = strstr (p, prefixes[i].name); 
     484            if (q == 0) 
    484485               continue; 
    485486            else 
    486487                p = q + prefixes[i].len; 
    487488        } 
    488489 
    489         if ((dir = strchr (p, PATH_SEP)) != NULL) 
     490        dir = strchr (p, PATH_SEP); 
     491        if (dir != NULL) 
    490492            *dir = '\0'; 
    491493 
    492494        /* search for any possible user */ 
    load_file (const char *filename) 
    569571    char *data; 
    570572    long read_size; 
    571573     
    572     if ((data_file = fopen (filename, "r")) == NULL){ 
     574    data_file = fopen (filename, "r"); 
     575    if (data_file == NULL) 
    573576        return 0; 
    574     } 
     577 
    575578    if (fstat (fileno (data_file), &s) != 0){ 
    576579        fclose (data_file); 
    577580        return 0; 
  • src/utilunix.c

    diff --git a/src/utilunix.c b/src/utilunix.c
    index 00db9d5..c8df45f 100644
    a b char *get_owner (int uid) 
    9191    char   *name; 
    9292    static int uid_last; 
    9393     
    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) 
    9596        return name; 
    9697     
    9798    pwd = getpwuid (uid); 
    char *get_group (int gid) 
    112113    char *name; 
    113114    static int  gid_last; 
    114115     
    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) 
    116118        return name; 
    117119     
    118120    grp = getgrgid (gid); 
    int my_system (int flags, const char *shell, const char *command) 
    150152    /* handler messing the screen after the SIGCONT */ 
    151153    sigaction (SIGTSTP, &startup_handler, &save_stop); 
    152154 
    153     if ((pid = fork ()) < 0){ 
     155    pid = fork (); 
     156    if (pid < 0) { 
    154157        fprintf (stderr, "\n\nfork () = -1\n"); 
    155158        return -1; 
    156     } 
    157     if (pid == 0){ 
     159    } else if (pid == 0) { 
    158160        signal (SIGINT, SIG_DFL); 
    159161        signal (SIGQUIT, SIG_DFL); 
    160162        signal (SIGTSTP, SIG_DFL); 
  • src/viewer/datasource.c

    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) 
    343343    mcview_close_datasource (view); 
    344344 
    345345    open_error_pipe (); 
    346     if ((fp = popen (command, "r")) == NULL) { 
     346    fp = popen (command, "r"); 
     347    if (fp == NULL) { 
    347348        /* Avoid two messages.  Message from stderr has priority.  */ 
    348349        mcview_display (view); 
    349350        if (!close_error_pipe (mcview_is_in_panel (view) ? -1 : D_ERROR, NULL)) 
  • src/viewer/mcviewer.c

    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 
    325325        retval = mcview_load_command_output (view, command); 
    326326    } else if (file != NULL && file[0] != '\0') { 
    327327        /* 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) { 
    329330            g_snprintf (tmp, sizeof (tmp), _(" Cannot open \"%s\"\n %s "), 
    330331                        file, unix_error_string (errno)); 
    331332            mcview_show_error (view, tmp); 
  • src/widget.c

    diff --git a/src/widget.c b/src/widget.c
    index 9257fad..3fe7546 100644
    a b history_put (const char *input_name, GList *h) 
    10541054 
    10551055    profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_HISTORY_FILE, NULL); 
    10561056 
    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) 
    10581059        close (i); 
    10591060 
    10601061    /* Make sure the history is only readable by the user */ 
  • vfs/cpio.c

    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, 
    164164    mode_t mode; 
    165165    struct vfs_s_inode *root; 
    166166 
    167     if ((fd = mc_open (name, O_RDONLY)) == -1) { 
     167    fd = mc_open (name, O_RDONLY); 
     168    if (fd == -1) { 
    168169        message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name); 
    169170        return -1; 
    170171    } 
    cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, 
    180181 
    181182        mc_close (fd); 
    182183        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) { 
    184186            message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); 
    185187            g_free (s); 
    186188            return -1; 
    static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super) 
    246248                ptr -= top - 128; 
    247249                top = 128; 
    248250            } 
    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) { 
    250253                message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name); 
    251254                cpio_free_archive(me, super); 
    252255                return CPIO_UNKNOWN; 
    static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe 
    418421    char *name; 
    419422    struct stat st; 
    420423 
    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) 
    422426        return STATUS_EOF; 
    423427    CPIO_POS(super) += len; 
    424428    if(super->u.arch.type == CPIO_BINRE) { 
    static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe 
    434438        return STATUS_FAIL; 
    435439    } 
    436440    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) { 
    438443        g_free(name); 
    439444        return STATUS_EOF; 
    440445    } 
    static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup 
    492497        return STATUS_FAIL; 
    493498    } 
    494499    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)) { 
    497502        g_free (name); 
    498503        return STATUS_EOF; 
    499504    } 
    static ssize_t cpio_read(void *fh, char *buffer, int count) 
    668673 
    669674    count = MIN(count, FH->ino->st.st_size - FH->pos); 
    670675 
    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); 
    672678 
    673679    FH->pos += count; 
    674680    return count; 
  • vfs/direntry.c

    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, 
    483483    vfs_split (inname, &local, &op); 
    484484    retval = (local) ? local : ""; 
    485485 
    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) 
    488489            return NULL; 
     490    } 
    489491 
    490492    for (super = MEDATA->supers; super != NULL; super = super->next) { 
    491493        /* 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) 
    585587    struct vfs_s_inode *ino; 
    586588    char *q; 
    587589 
    588     if (!(q = vfs_s_get_path (me, name, &super, 0))) 
     590    q = vfs_s_get_path (me, name, &super, 0); 
     591    if (!q) 
    589592        return NULL; 
    590593 
    591594    ino = 
    static int 
    668671vfs_s_chdir (struct vfs_class *me, const char *path) 
    669672{ 
    670673    void *data; 
    671     if (!(data = vfs_s_opendir (me, path))) 
     674    data = vfs_s_opendir (me, path); 
     675    if (!data) 
    672676        return -1; 
    673677    vfs_s_closedir (data); 
    674678    return 0; 
    vfs_s_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, i 
    681685{ 
    682686    struct vfs_s_inode *ino; 
    683687 
    684     if (!(ino = vfs_s_inode_from_path (me, path, flag))) 
     688    ino = vfs_s_inode_from_path (me, path, flag); 
     689    if (!ino) 
    685690        return -1; 
    686691    *buf = ino->st; 
    687692    return 0; 
    vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) 
    739744    char *q; 
    740745    struct vfs_s_inode *ino; 
    741746 
    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) 
    743749        return NULL; 
    744750    ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE); 
    745751    if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) { 
    vfs_s_getid (struct vfs_class *me, const char *path) 
    11031109    struct vfs_s_super *archive; 
    11041110    char *p; 
    11051111 
    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) 
    11071114        return NULL; 
    11081115    g_free(p); 
    11091116    return (vfsid) archive;     
  • vfs/extfs.c

    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) 
    323323    struct archive *current_archive; 
    324324    char *current_file_name, *current_link_name; 
    325325 
    326     if ((extfsd = 
    327          extfs_open_archive (fstype, name, &current_archive)) == NULL) { 
     326    extfsd = extfs_open_archive (fstype, name, &current_archive); 
     327    if (extfsd == NULL) { 
    328328        message (D_ERROR, MSG_ERROR, _("Cannot open %s archive\n%s"), 
    329329                 extfs_prefixes[fstype], name); 
    330330        return -1; 
    extfs_run (struct vfs_class *me, const char *file) 
    655655    char *p, *q, *archive_name, *mc_extfsdir; 
    656656    char *cmd; 
    657657 
    658     if ((p = extfs_get_path (me, file, &archive, 0)) == NULL) 
     658    p = extfs_get_path (me, file, &archive, 0); 
     659    if (p == NULL) 
    659660        return; 
    660661    q = name_quote (p, 0); 
    661662    g_free (p); 
    extfs_open (struct vfs_class *me, const char *file, int flags, int mode) 
    681682    int local_handle; 
    682683    int created = 0; 
    683684 
    684     if ((q = extfs_get_path (me, file, &archive, 0)) == NULL) 
     685    q = extfs_get_path (me, file, &archive, 0); 
     686    if (q == NULL) 
    685687        return NULL; 
    686688    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    687689    if (entry == NULL && (flags & O_CREAT)) { 
    extfs_open (struct vfs_class *me, const char *file, int flags, int mode) 
    693695    g_free (q); 
    694696    if (entry == NULL) 
    695697        return NULL; 
    696     if ((entry = extfs_resolve_symlinks (entry)) == NULL) 
     698    entry = extfs_resolve_symlinks (entry); 
     699    if (entry == NULL) 
    697700        return NULL; 
    698701 
    699702    if (S_ISDIR (entry->inode->mode)) 
    extfs_find_entry_int (struct entry *dir, char *name, 
    817820            if (!strcmp (p, ".."))  
    818821                pent = pent->dir; 
    819822            else { 
    820                 if ((pent = extfs_resolve_symlinks_int (pent, list))==NULL){ 
     823                pent = extfs_resolve_symlinks_int (pent, list); 
     824                if (pent == NULL) { 
    821825                    *q = c; 
    822826                    return NULL; 
    823827                } 
    static void * extfs_opendir (struct vfs_class *me, const char *dirname) 
    893897    struct entry *entry; 
    894898    struct entry **info; 
    895899 
    896     if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL) 
     900    q = extfs_get_path (me, dirname, &archive, 0); 
     901    if (q == NULL) 
    897902        return NULL; 
    898903    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    899904    g_free (q); 
    900905    if (entry == NULL) 
    901906        return NULL; 
    902     if ((entry = extfs_resolve_symlinks (entry)) == NULL) 
     907    entry = extfs_resolve_symlinks (entry); 
     908    if (entry == NULL) 
    903909        return NULL; 
    904910    if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, NULL); 
    905911 
    extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, 
    965971    char *path2 = g_strdup (path); 
    966972    int result = -1; 
    967973 
    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) 
    969976        goto cleanup; 
    970977    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    971978    if (entry == NULL) 
    972979        goto cleanup; 
    973     if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL) 
     980    entry = extfs_resolve_symlinks (entry); 
     981    if (resolve && (entry == NULL)) 
    974982        goto cleanup; 
    975983    extfs_stat_move (buf, entry->inode); 
    976984    result = 0; 
    extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) 
    10071015    char *mpath = g_strdup (path); 
    10081016    int result = -1; 
    10091017 
    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) 
    10111020        goto cleanup; 
    10121021    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    10131022    if (entry == NULL) 
    static int extfs_unlink (struct vfs_class *me, const char *file) 
    10581067    struct entry *entry; 
    10591068    int result = -1; 
    10601069 
    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) 
    10621072        goto cleanup; 
    10631073    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    10641074    if (entry == NULL) 
    10651075        goto cleanup; 
    1066     if ((entry = extfs_resolve_symlinks (entry)) == NULL) 
     1076    entry = extfs_resolve_symlinks (entry); 
     1077    if (entry == NULL) 
    10671078        goto cleanup; 
    10681079    if (S_ISDIR (entry->inode->mode)) { 
    10691080        me->verrno = EISDIR; 
    static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) 
    10891100 
    10901101    (void) mode; 
    10911102 
    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) 
    10931105        goto cleanup; 
    10941106    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    10951107    if (entry != NULL) { 
    static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) 
    10991111    entry = extfs_find_entry (archive->root_entry, q, 1, 0); 
    11001112    if (entry == NULL) 
    11011113        goto cleanup; 
    1102     if ((entry = extfs_resolve_symlinks (entry)) == NULL) 
     1114    entry = extfs_resolve_symlinks (entry); 
     1115    if (entry == NULL) 
    11031116        goto cleanup; 
    11041117    if (!S_ISDIR (entry->inode->mode)) { 
    11051118        me->verrno = ENOTDIR; 
    static int extfs_rmdir (struct vfs_class *me, const char *path) 
    11241137    struct entry *entry; 
    11251138    int result = -1; 
    11261139 
    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) 
    11281142        goto cleanup; 
    11291143    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    11301144    if (entry == NULL) 
    11311145        goto cleanup; 
    1132     if ((entry = extfs_resolve_symlinks (entry)) == NULL) 
     1146    entry = extfs_resolve_symlinks (entry); 
     1147    if (entry == NULL) 
    11331148        goto cleanup; 
    11341149    if (!S_ISDIR (entry->inode->mode)) { 
    11351150        me->verrno = ENOTDIR; 
    extfs_chdir (struct vfs_class *me, const char *path) 
    11551170    struct entry *entry; 
    11561171 
    11571172    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) 
    11591175        return -1; 
    11601176    entry = extfs_find_entry (archive->root_entry, q, 0, 0); 
    11611177    g_free (q); 
    static int extfs_init (struct vfs_class *me) 
    13521368        if (*key == '#' || *key == '\n') 
    13531369            continue; 
    13541370 
    1355         if ((c = strchr (key, '\n'))){ 
     1371        c = strchr (key, '\n'); 
     1372        if (c) { 
    13561373            *c-- = 0; 
    13571374        } else {        /* Last line without newline or strlen (key) > 255 */ 
    13581375            c = &key [strlen (key) - 1]; 
  • vfs/fish.c

    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[]) 
    199199    if ((pipe(fileset1)<0) || (pipe(fileset2)<0))  
    200200        vfs_die("Cannot pipe(): %m."); 
    201201     
    202     if ((res = fork())) { 
     202    res = fork(); 
     203    if (res) { 
    203204        if (res<0) vfs_die("Cannot fork(): %m."); 
    204205        /* We are the parent */ 
    205206        close(fileset1[0]); 
    fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc 
    787788        } 
    788789        if (n == 0) 
    789790            break; 
    790         if ((t = write (SUP.sockw, buffer, n)) != n) { 
     791        t = write (SUP.sockw, buffer, n); 
     792        if (t != n) { 
    791793            if (t == -1) { 
    792794                me->verrno = errno; 
    793795            } else {  
    fish_linear_abort (struct vfs_class *me, struct vfs_s_fh *fh) 
    873875    do { 
    874876        n = MIN(8192, fh->u.fish.total - fh->u.fish.got); 
    875877        if (n) { 
    876             if ((n = read(SUP.sockr, buffer, n)) < 0) 
     878            n = read(SUP.sockr, buffer, n); 
     879            if (n < 0) 
    877880                return; 
    878881            fh->u.fish.got += n; 
    879882        } 
    fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c 
    960963    const char *crpath; \ 
    961964    char *rpath, *mpath = g_strdup (path); \ 
    962965    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) { \ 
    964968        g_free (mpath); \ 
    965969        return -1; \ 
    966970    } \ 
    static int fish_##name (struct vfs_class *me, const char *path1, const char *pat 
    993997    const char *crpath1, *crpath2; \ 
    994998    char *rpath1, *rpath2, *mpath1, *mpath2; \ 
    995999    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) { \ 
    9971002        g_free (mpath1); \ 
    9981003        return -1; \ 
    9991004    } \ 
    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) { \ 
    10011007        g_free (mpath1); \ 
    10021008        g_free (mpath2); \ 
    10031009        return -1; \ 
    fish_chown (struct vfs_class *me, const char *path, int owner, int group) 
    10491055    struct passwd *pw; 
    10501056    struct group *gr; 
    10511057 
    1052     if ((pw = getpwuid (owner)) == NULL) 
     1058    pw = getpwuid (owner); 
     1059    if (pw == NULL) 
    10531060        return 0; 
    10541061 
    1055     if ((gr = getgrgid (group)) == NULL) 
     1062    gr = getgrgid (group); 
     1063    if (gr == NULL) 
    10561064        return 0; 
    10571065 
    10581066    sowner = pw->pw_name; 
  • vfs/ftpfs.c

    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 
    218218        ret = g_strdup (remote_path); 
    219219 
    220220        /* replace first occurance of ":/" with ":" */ 
    221         if ((p = strchr (ret, ':')) && *(p + 1) == '/') 
     221        p = strchr (ret, ':'); 
     222        if (p && (*(p + 1) == '/')) 
    222223            strcpy (p + 1, p + 2); 
    223224 
    224225        /* strip trailing "/." */ 
    225         if ((p = strrchr (ret, '/')) && *(p + 1) == '.' && *(p + 2) == '\0') 
     226        p = strrchr (ret, '/'); 
     227        if (p && (*(p + 1) == '.') && (*(p + 2) == '\0')) 
    226228            *p = '\0'; 
    227229        return ret; 
    228230    } 
    ftpfs_load_no_proxy_list (void) 
    579581        return; 
    580582 
    581583    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); 
    604611        } 
    605  
    606         fclose (npf); 
    607612    } 
    608613    g_free (mc_file); 
    609614} 
    ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con 
    10911096    int s, j, data; 
    10921097    socklen_t fromlen = sizeof(from); 
    10931098     
    1094     if ((s = ftpfs_initconn (me, super)) == -1) 
     1099    s = ftpfs_initconn (me, super); 
     1100    if (s == -1) 
    10951101        return -1; 
    10961102    if (ftpfs_changetype (me, super, isbinary) == -1) 
    10971103        return -1; 
    ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd, 
    16201626    int r; 
    16211627    int flush_directory_cache = (flags & OPT_FLUSH); 
    16221628 
    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) { 
    16241631        g_free(mpath); 
    16251632        return -1; 
    16261633    } 
    static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) 
    20432050    /* Find our own domain name */ 
    20442051    if (gethostname (hostname, sizeof (hostname)) < 0) 
    20452052        *hostname = 0; 
    2046     if (!(domain = strchr (hostname, '.'))) 
     2053    domain = strchr (hostname, '.'); 
     2054    if (!domain) 
    20472055        domain = ""; 
    20482056 
    20492057    /* Scan for "default" and matching "machine" keywords */ 
  • vfs/mcfs.c

    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) 
    212212#ifdef HAVE_PMAP_GETPORT 
    213213    int port; 
    214214    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) 
    216217            return port; 
    217218#endif                          /* HAVE_PMAP_GETPORT */ 
    218219    *version = 1; 
    mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal 
    237238    server_address.sin_family = AF_INET; 
    238239 
    239240    /*  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) 
    241243        memcpy ((char *) &server_address.sin_addr, (char *) &inaddr, 
    242244                sizeof (inaddr)); 
    243245    else { 
    244         if ((hp = gethostbyname (host)) == NULL) { 
     246        hp = gethostbyname (host); 
     247        if (hp == NULL) { 
    245248            message (D_ERROR, caller, _(" Cannot locate hostname: %s "), 
    246249                        host); 
    247250            return 0; 
    mcfs_create_tcp_link (const char *host, int *port, int *version, const char *cal 
    260263 
    261264    server_address.sin_port = htons (*port); 
    262265 
    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) { 
    264268        message (D_ERROR, caller, _(" Cannot create socket: %s "), 
    265269                    unix_error_string (errno)); 
    266270        return 0; 
    mcfs_open_link (char *host, char *user, int *port, char *netrcpass) 
    341345        return 0; 
    342346    } 
    343347 
    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) 
    347350        return 0; 
    348351 
    349352    bucket = mcfs_get_free_bucket (); 
    mcfs_get_path (mcfs_connection **mc, const char *path) 
    394397     * remote portmapper to get the port number 
    395398     */ 
    396399    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)) { 
    400404            g_free (remote_path); 
    401405            remote_path = NULL; 
    402406        } 
     407    } 
    403408    g_free (host); 
    404409    g_free (user); 
    405410    if (pass) 
    mcfs_rpc_two_paths (int command, const char *s1, const char *s2) 
    445450    mcfs_connection *mc; 
    446451    char *r1, *r2; 
    447452 
    448     if ((r1 = mcfs_get_path (&mc, s1)) == 0) 
     453    r1 = mcfs_get_path (&mc, s1); 
     454    if (r1 == 0) 
    449455        return -1; 
    450456 
    451     if ((r2 = mcfs_get_path (&mc, s2)) == 0) { 
     457    r2 = mcfs_get_path (&mc, s2); 
     458    if (r2 == 0) { 
    452459        g_free (r1); 
    453460        return -1; 
    454461    } 
    mcfs_rpc_path (int command, const char *path) 
    466473    mcfs_connection *mc; 
    467474    char *remote_file; 
    468475 
    469     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     476    remote_file = mcfs_get_path (&mc, path); 
     477    if (remote_file == 0) 
    470478        return -1; 
    471479 
    472480    rpc_send (mc->sock, 
    mcfs_rpc_path_int (int command, const char *path, int data) 
    482490    mcfs_connection *mc; 
    483491    char *remote_file; 
    484492 
    485     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     493    remote_file = mcfs_get_path (&mc, path); 
     494    if (remote_file == 0) 
    486495        return -1; 
    487496 
    488497    rpc_send (mc->sock, 
    mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2) 
    499508    mcfs_connection *mc; 
    500509    char *remote_file; 
    501510 
    502     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     511    remote_file = mcfs_get_path (&mc, path); 
     512    if (remote_file == 0) 
    503513        return -1; 
    504514 
    505515    rpc_send (mc->sock, 
    mcfs_open (struct vfs_class *me, const char *file, int flags, int mode) 
    537547 
    538548    (void) me; 
    539549 
    540     if (!(remote_file = mcfs_get_path (&mc, file))) 
     550    remote_file = mcfs_get_path (&mc, file); 
     551    if (!remote_file) 
    541552        return 0; 
    542553 
    543554    rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT, 
    mcfs_opendir (struct vfs_class *me, const char *dirname) 
    661672 
    662673    (void) me; 
    663674 
    664     if (!(remote_dir = mcfs_get_path (&mc, dirname))) 
     675    remote_dir = mcfs_get_path (&mc, dirname); 
     676    if (!remote_dir) 
    665677        return 0; 
    666678 
    667679    rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, 
    mcfs_stat_cmd (int cmd, const char *path, struct stat *buf) 
    880892    mcfs_connection *mc; 
    881893    int status, error; 
    882894 
    883     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     895    remote_file = mcfs_get_path (&mc, path); 
     896    if (remote_file == 0) 
    884897        return -1; 
    885898 
    886899    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) 
    970983 
    971984    (void) me; 
    972985 
    973     if (!(file = mcfs_get_path (&mc, path))) 
     986    file = mcfs_get_path (&mc, path); 
     987    if (!file) 
    974988        return -1; 
    975989 
    976990    status = 0; 
    mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) 
    10051019 
    10061020    (void) me; 
    10071021 
    1008     if (!(remote_file = mcfs_get_path (&mc, path))) 
     1022    remote_file = mcfs_get_path (&mc, path); 
     1023    if (!remote_file) 
    10091024        return -1; 
    10101025 
    10111026    rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, 
    mcfs_chdir (struct vfs_class *me, const char *path) 
    10621077 
    10631078    (void) me; 
    10641079 
    1065     if (!(remote_dir = mcfs_get_path (&mc, path))) 
     1080    remote_dir = mcfs_get_path (&mc, path); 
     1081    if (!remote_dir) 
    10661082        return -1; 
    10671083 
    10681084    rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, 
    mcfs_forget (const char *path) 
    11401156    if (path[0] == '/' && path[1] == '/') 
    11411157        path += 2; 
    11421158 
    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) { 
    11461161        g_free (host); 
    11471162        g_free (user); 
    11481163        if (pass) 
  • vfs/mcserv.c

    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) 
    798798    up.password = password; 
    799799    conv.appdata_ptr = &up; 
    800800 
    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) 
    803803        goto failed_pam; 
    804     if ((status = pam_authenticate (pamh, 0)) != PAM_SUCCESS) 
     804    status = pam_authenticate (pamh, 0); 
     805    if (status != PAM_SUCCESS) 
    805806        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) 
    807809        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) 
    809812        goto failed_pam; 
    810813    pam_end (pamh, status); 
    811814    return 0; 
    do_ftp_auth (const char *username, const char *password) 
    865868    local_address.sin_port = htons (21); 
    866869 
    867870    /*  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) 
    869873        memcpy ((char *) &local_address.sin_addr, (char *) &inaddr, 
    870874                sizeof (inaddr)); 
    871875 
    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) { 
    873878        if (!isDaemon) 
    874879            fprintf (stderr, "do_auth: can't create socket\n"); 
    875880        return 0; 
    do_classic_auth (const char *username, const char *password) 
    915920    struct spwd *spw; 
    916921#endif 
    917922 
    918     if ((pw = getpwnam (username)) == 0) 
     923    pw = getpwnam (username); 
     924    if (pw == 0) 
    919925        return 0; 
    920926 
    921927#ifdef HAVE_SHADOW 
    922928    setspent (); 
    923929 
    924930    /* Password expiration is not checked! */ 
    925     if ((spw = getspnam (username)) == NULL) 
     931    spw = getspnam (username); 
     932    if (spw == NULL) 
    926933        encr_pwd = "*"; 
    927934    else 
    928935        encr_pwd = spw->sp_pwdp; 
    get_client (int port) 
    11971204    struct sockaddr_in client_address, server_address; 
    11981205    int yes = 1; 
    11991206 
    1200     if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) 
     1207    sock = socket (AF_INET, SOCK_STREAM, 0); 
     1208    if (sock < 0) 
    12011209        return "Cannot create socket"; 
    12021210 
    12031211    /* Use this to debug: */ 
    get_client (int port) 
    12241232        newsocket = 
    12251233            accept (sock, (struct sockaddr *) &client_address, &clilen); 
    12261234 
    1227         if (isDaemon && (child = fork ())) { 
     1235        child = fork (); 
     1236        if (isDaemon && child) { 
    12281237            int status; 
    12291238 
    12301239            close (newsocket); 
    register_port (int port, int abort_if_fail) 
    12961305            exit (1); 
    12971306    } 
    12981307#else 
    1299     (void) port; 
    13001308    if (abort_if_fail) { 
    13011309        fprintf (stderr, 
    13021310                 "This system lacks port registration, try using the -p\n" 
    main (int argc, char *argv[]) 
    13701378        register_port (portnum, 0); 
    13711379        if (verbose) 
    13721380            printf ("Using port %d\n", portnum); 
    1373         if ((result = get_client (portnum))) 
     1381        result = get_client (portnum); 
     1382        if (result) 
    13741383            perror (result); 
    13751384#ifdef HAVE_PMAP_SET 
    13761385        if (!isDaemon) 
  • vfs/sfs.c

    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) 
    8484 
    8585    pname = g_strdup (name); 
    8686    vfs_split (pname, &inpath, &op); 
    87     if ((w = (*me->which) (me, op)) == -1) 
     87 
     88    w = (*me->which) (me, op); 
     89    if (w == -1) 
    8890        vfs_die ("This cannot happen... Hopefully.\n"); 
    8991 
    9092    if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) { 
    static int sfs_init (struct vfs_class *me) 
    394396            goto invalid_line; 
    395397        c++; 
    396398        *(semi+1) = 0; 
    397         if ((semi = strchr (c, '\n'))) 
     399        semi = strchr (c, '\n'); 
     400        if (semi) 
    398401            *semi = 0; 
    399402 
    400403        sfs_prefix [sfs_no] = g_strdup (key); 
  • vfs/tar.c

    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, 
    665665 
    666666    current_tar_position = 0; 
    667667    /* 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) 
    669670        return -1; 
    670671 
    671672    for (;;) { 
    static ssize_t tar_read (void *fh, char *buffer, int count) 
    771772 
    772773    count = MIN(count, FH->ino->st.st_size - FH->pos); 
    773774 
    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); 
    775777 
    776778    FH->pos += count; 
    777779    return count; 
  • vfs/undelfs.c

    diff --git a/vfs/undelfs.c b/vfs/undelfs.c
    index 3f45570..43fea75 100644
    a b undelfs_loaddel (void) 
    200200        message (D_ERROR, undelfserr, _(" while allocating block buffer ")); 
    201201        goto free_delarray; 
    202202    } 
    203     if ((retval = ext2fs_open_inode_scan (fs, 0, &scan))) { 
     203    retval = ext2fs_open_inode_scan (fs, 0, &scan); 
     204    if (retval) { 
    204205        message (D_ERROR, undelfserr, _(" open_inode_scan: %d "), retval); 
    205206        goto free_block_buf; 
    206207    } 
    207     if ((retval = ext2fs_get_next_inode (scan, &ino, &inode))) { 
     208    retval = ext2fs_get_next_inode (scan, &ino, &inode); 
     209    if (retval) { 
    208210        message (D_ERROR, undelfserr, _(" while starting inode scan %d "), 
    209211                 retval); 
    210212        goto error_out; 
    undelfs_chdir(struct vfs_class *me, const char *path) 
    640642    /* We may use access because ext2 file systems are local */ 
    641643    /* this could be fixed by making an ext2fs io manager to use */ 
    642644    /* 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) { 
    644647        message (D_ERROR, undelfserr, _(" Cannot open file %s "), file); 
    645648        g_free (f); 
    646649        g_free (file); 
  • vfs/utilvfs.c

    diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c
    index 79bec13..db50f7e 100644
    a b is_week (const char *str, struct tm *tim) 
    355355    if (!str) 
    356356        return 0; 
    357357 
    358     if ((pos = strstr (week, str)) != NULL) { 
     358    pos = strstr (week, str); 
     359    if (pos != NULL) { 
    359360        if (tim != NULL) 
    360361            tim->tm_wday = (pos - week) / 3; 
    361362        return 1; 
    is_month (const char *str, struct tm *tim) 
    372373    if (!str) 
    373374        return 0; 
    374375 
    375     if ((pos = strstr (month, str)) != NULL) { 
     376    pos = strstr (month, str); 
     377    if (pos != NULL) { 
    376378        if (tim != NULL) 
    377379            tim->tm_mon = (pos - month) / 3; 
    378380        return 1; 
    is_time (const char *str, struct tm *tim) 
    412414    if (!str) 
    413415        return 0; 
    414416 
    415     if ((p = strchr (str, ':')) && (p2 = strrchr (str, ':'))) { 
     417    p = strchr (str, ':'); 
     418    p2 = strrchr (str, ':'); 
     419    if (p && p2) { 
    416420        if (p != p2) { 
    417421            if (sscanf 
    418422                (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, 
    vfs_parse_filedate (int idx, time_t *t) 
    741745 
    742746        tim.tm_year--; 
    743747 
    744     if (l10n || (*t = mktime (&tim)) < 0) 
     748    *t = mktime (&tim); 
     749    if (l10n || (*t < 0)) 
    745750        *t = 0; 
    746751    return idx; 
    747752} 
  • vfs/vfs.c

    diff --git a/vfs/vfs.c b/vfs/vfs.c
    index 57ff3d7..9875b85 100644
    a b vfs_strip_suffix_from_filename (const char *filename) 
    233233        vfs_die ("vfs_strip_suffix_from_path got NULL: impossible"); 
    234234 
    235235    p = g_strdup (filename); 
    236     if (!(semi = strrchr (p, '#'))) 
     236    semi = strrchr (p, '#'); 
     237    if (!semi) 
    237238        return p; 
    238239 
    239240    /* Avoid last class (localfs) that would accept any prefix */ 
    vfs_split (char *path, char **inpath, char **op) 
    306307    if (slash) 
    307308        *slash = 0; 
    308309 
    309     if ((ret = vfs_prefix_to_class (semi+1))){ 
     310    ret = vfs_prefix_to_class (semi + 1); 
     311    if (ret) { 
    310312        if (op)  
    311313            *op = semi + 1; 
    312314        if (inpath)