Ticket #2097: Clean-up-of-4.7.1-assignments-02.diff

File Clean-up-of-4.7.1-assignments-02.diff, 48.1 KB (added by vit_r, 14 years ago)

getting-out-assignments-from-some-ifs

  • intl/localcharset.c

    diff -urN mc-4.7.1_old/intl/localcharset.c mc-4.7.1_new/intl/localcharset.c
    old new  
    141141          } 
    142142      } 
    143143 
    144       if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL) 
     144      fp = fopen (file_name, "r"); 
     145      if (file_name == NULL || fp == NULL) 
    145146        /* Out of memory or file not found, treat it as empty.  */ 
    146147        cp = ""; 
    147148      else 
  • intl/plural.c

    diff -urN mc-4.7.1_old/intl/plural.c mc-4.7.1_new/intl/plural.c
    old new  
    15321532  case 12: 
    15331533#line 195 "/srv/work/mc/git/intl/plural.y" 
    15341534    { 
    1535             if (((yyval.exp) = new_exp_0 (num)) != NULL) 
     1535            yyval.exp = new_exp_0 (num); 
     1536            if (yyval.exp != NULL) 
    15361537              (yyval.exp)->val.num = (yyvsp[(1) - (1)].num); 
    15371538          } 
    15381539    break; 
  • lib/logging.c

    diff -urN mc-4.7.1_old/lib/logging.c mc-4.7.1_new/lib/logging.c
    old new  
    6767        if (is_logging_enabled()) { 
    6868                va_start(args, fmt); 
    6969                logfilename = g_strdup_printf("%s/%s/log", home_dir, MC_USERCONF_DIR); 
    70                 if ((f = fopen(logfilename, "a")) != NULL) { 
     70                f = fopen (logfilename, "a"); 
     71                if (f != NULL) { 
    7172                        (void)vfprintf(f, fmt, args); 
    7273                        (void)fclose(f); 
    7374                } 
  • lib/util.c

    diff -urN mc-4.7.1_old/lib/util.c mc-4.7.1_new/lib/util.c
    old new  
    519519 
    520520        if (has_prefix) 
    521521        { 
    522             if ((q = strstr (p, prefixes[i].name)) == 0) 
     522            q = strstr (p, prefixes[i].name); 
     523            if (q == NULL) 
    523524                continue; 
    524525            else 
    525526                p = q + prefixes[i].len; 
    526527        } 
    527528 
    528         if ((dir = strchr (p, PATH_SEP)) != NULL) 
     529        dir = strchr (p, PATH_SEP); 
     530        if (dir != NULL) 
    529531            *dir = '\0'; 
    530532 
    531533        /* search for any possible user */ 
     
    552554    size_t len; 
    553555    static char newdir[MC_MAXPATHLEN]; 
    554556 
    555     if (home_dir && !strncmp (dir, home_dir, len = strlen (home_dir)) && 
     557    len = strlen (home_dir); 
     558    if (home_dir && !strncmp (dir, home_dir, len) && 
    556559        (dir[len] == PATH_SEP || dir[len] == '\0')) 
    557560    { 
    558561        newdir[0] = '~'; 
     
    612615    char *data; 
    613616    long read_size; 
    614617 
    615     if ((data_file = fopen (filename, "r")) == NULL) 
     618    data_file = fopen (filename, "r"); 
     619    if (data_file == NULL) 
    616620    { 
    617621        return 0; 
    618622    } 
  • lib/utilunix.c

    diff -urN mc-4.7.1_old/lib/utilunix.c mc-4.7.1_new/lib/utilunix.c
    old new  
    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); 
     
    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); 
     
    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); 
  • lib/vfs/mc-vfs/cpio.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/cpio.c mc-4.7.1_new/lib/vfs/mc-vfs/cpio.c
    old new  
    165165    mode_t mode; 
    166166    struct vfs_s_inode *root; 
    167167 
    168     if ((fd = mc_open (name, O_RDONLY)) == -1) { 
     168    fd = mc_open (name, O_RDONLY); 
     169    if (fd == -1) { 
    169170        message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name); 
    170171        return -1; 
    171172    } 
     
    181182 
    182183        mc_close (fd); 
    183184        s = g_strconcat (name, decompress_extension (type), (char *) NULL); 
    184         if ((fd = mc_open (s, O_RDONLY)) == -1) { 
     185        fd = mc_open (s, O_RDONLY); 
     186        if (fd == -1) { 
    185187            message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); 
    186188            g_free (s); 
    187189            return -1; 
     
    247249                ptr -= top - 128; 
    248250                top = 128; 
    249251            } 
    250             if((tmp = mc_read(super->u.arch.fd, buf, top)) == 0 || tmp == -1) { 
     252            tmp = mc_read(super->u.arch.fd, buf, top); 
     253            if (tmp == 0 || tmp == -1) { 
    251254                message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name); 
    252255                cpio_free_archive(me, super); 
    253256                return CPIO_UNKNOWN; 
     
    419422    char *name; 
    420423    struct stat st; 
    421424 
    422     if((len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH) 
     425    len = mc_read (super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH); 
     426    if (len < HEAD_LENGTH) 
    423427        return STATUS_EOF; 
    424428    CPIO_POS(super) += len; 
    425429    if(super->u.arch.type == CPIO_BINRE) { 
     
    435439        return STATUS_FAIL; 
    436440    } 
    437441    name = g_malloc(u.buf.c_namesize); 
    438     if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) { 
     442    len = mc_read (super->u.arch.fd, name, u.buf.c_namesize); 
     443    if (len < u.buf.c_namesize) { 
    439444        g_free(name); 
    440445        return STATUS_EOF; 
    441446    } 
     
    493498        return STATUS_FAIL; 
    494499    } 
    495500    name = g_malloc(hd.c_namesize); 
    496     if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 || 
    497        (unsigned long) len < hd.c_namesize) { 
     501    len = mc_read (super->u.arch.fd, name, hd.c_namesize); 
     502    if ((len == -1) || ((unsigned long) len < hd.c_namesize)) { 
    498503        g_free (name); 
    499504        return STATUS_EOF; 
    500505    } 
     
    669674 
    670675    count = MIN(count, FH->ino->st.st_size - FH->pos); 
    671676 
    672     if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1); 
     677    count = mc_read (fd, buffer, count); 
     678    if (count == -1)  
     679        ERRNOR (errno, -1); 
    673680 
    674681    FH->pos += count; 
    675682    return count; 
  • lib/vfs/mc-vfs/direntry.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/direntry.c mc-4.7.1_new/lib/vfs/mc-vfs/direntry.c
    old new  
    485485    vfs_split (inname, &local, &op); 
    486486    retval = (local) ? local : ""; 
    487487 
    488     if (MEDATA->archive_check) 
    489         if (!(cookie = MEDATA->archive_check (me, archive_name, op))) 
     488    if (MEDATA->archive_check) { 
     489        cookie = MEDATA->archive_check (me, archive_name, op); 
     490        if (cookie == NULL) 
    490491            return NULL; 
     492    } 
    491493 
    492494    for (super = MEDATA->supers; super != NULL; super = super->next) { 
    493495        /* 0 == other, 1 == same, return it, 2 == other but stop scanning */ 
     
    587589    struct vfs_s_inode *ino; 
    588590    char *q; 
    589591 
    590     if (!(q = vfs_s_get_path (me, name, &super, 0))) 
     592    q = vfs_s_get_path (me, name, &super, 0); 
     593    if (q == NULL) 
    591594        return NULL; 
    592595 
    593596    ino = 
     
    670673vfs_s_chdir (struct vfs_class *me, const char *path) 
    671674{ 
    672675    void *data; 
    673     if (!(data = vfs_s_opendir (me, path))) 
     676 
     677    data = vfs_s_opendir (me, path); 
     678    if (data == NULL) 
    674679        return -1; 
     680 
    675681    vfs_s_closedir (data); 
    676682    return 0; 
    677683} 
     
    683689{ 
    684690    struct vfs_s_inode *ino; 
    685691 
    686     if (!(ino = vfs_s_inode_from_path (me, path, flag))) 
     692    ino = vfs_s_inode_from_path (me, path, flag); 
     693    if (ino == NULL) 
    687694        return -1; 
     695 
    688696    *buf = ino->st; 
    689697    return 0; 
    690698} 
     
    741749    char *q; 
    742750    struct vfs_s_inode *ino; 
    743751 
    744     if ((q = vfs_s_get_path (me, file, &super, 0)) == NULL) 
     752    q = vfs_s_get_path (me, file, &super, 0); 
     753    if (q == NULL) 
    745754        return NULL; 
    746755    ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE); 
    747756    if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) { 
     
    11051114    struct vfs_s_super *archive; 
    11061115    char *p; 
    11071116 
    1108     if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN))) 
     1117    p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN); 
     1118    if (p == NULL) 
    11091119        return NULL; 
     1120         
    11101121    g_free(p); 
    11111122    return (vfsid) archive;     
    11121123} 
  • lib/vfs/mc-vfs/fish.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/fish.c mc-4.7.1_new/lib/vfs/mc-vfs/fish.c
    old new  
    197197    if ((pipe(fileset1)<0) || (pipe(fileset2)<0))  
    198198        vfs_die("Cannot pipe(): %m."); 
    199199     
    200     if ((res = fork())) { 
    201         if (res<0) vfs_die("Cannot fork(): %m."); 
     200    res = fork(); 
     201    if (res < 0) { 
     202        vfs_die("Cannot fork(): %m."); 
     203    } else if (res > 0) { 
    202204        /* We are the parent */ 
    203205        close(fileset1[0]); 
    204206        SUP.sockw = fileset1[1]; 
     
    785787        } 
    786788        if (n == 0) 
    787789            break; 
    788         if ((t = write (SUP.sockw, buffer, n)) != n) { 
     790 
     791        t = write (SUP.sockw, buffer, n); 
     792        if (t != n) { 
    789793            if (t == -1) { 
    790794                me->verrno = errno; 
    791795            } else {  
     
    871875    do { 
    872876        n = MIN(8192, fh->u.fish.total - fh->u.fish.got); 
    873877        if (n) { 
    874             if ((n = read(SUP.sockr, buffer, n)) < 0) 
     878            n = read(SUP.sockr, buffer, n); 
     879            if (n < 0) 
    875880                return; 
     881 
    876882            fh->u.fish.got += n; 
    877883        } 
    878884    } while (n); 
     
    897903    } 
    898904    tty_enable_interrupt_key(); 
    899905 
    900     if (n>0) fh->u.fish.got += n; 
    901     if (n<0) fish_linear_abort(me, fh); 
    902     if ((!n) && ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE))) 
     906    if (n > 0)  
     907        fh->u.fish.got += n; 
     908    else if (n < 0) 
     909        fish_linear_abort (me, fh); 
     910    else if (fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) 
    903911        ERRNOR (E_REMOTE, -1); 
     912 
    904913    ERRNOR (errno, n); 
    905914} 
    906915 
     
    958967    const char *crpath; \ 
    959968    char *rpath, *mpath = g_strdup (path); \ 
    960969    struct vfs_s_super *super; \ 
    961     if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ 
     970    crpath = vfs_s_get_path_mangle (me, mpath, &super, 0); \ 
     971    if (crpath == NULL) { \ 
    962972        g_free (mpath); \ 
    963973        return -1; \ 
    964974    } \ 
     
    9911001    const char *crpath1, *crpath2; \ 
    9921002    char *rpath1, *rpath2, *mpath1, *mpath2; \ 
    9931003    struct vfs_s_super *super1, *super2; \ 
    994     if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) { \ 
     1004    crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0); \ 
     1005    if (crpath1 == NULL) { \ 
    9951006        g_free (mpath1); \ 
    9961007        return -1; \ 
    9971008    } \ 
    998     if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \ 
     1009    crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0); \ 
     1010    if (crpath2 == NULL) { \ 
    9991011        g_free (mpath1); \ 
    10001012        g_free (mpath2); \ 
    10011013        return -1; \ 
     
    10471059    struct passwd *pw; 
    10481060    struct group *gr; 
    10491061 
    1050     if ((pw = getpwuid (owner)) == NULL) 
     1062    pw = getpwuid (owner); 
     1063    if (pw == NULL) 
    10511064        return 0; 
    10521065 
    1053     if ((gr = getgrgid (group)) == NULL) 
     1066    gr = getgrgid (group); 
     1067    if (gr == NULL) 
    10541068        return 0; 
    10551069 
    10561070    sowner = pw->pw_name; 
  • lib/vfs/mc-vfs/ftpfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/ftpfs.c mc-4.7.1_new/lib/vfs/mc-vfs/ftpfs.c
    old new  
    223223            memmove (p + 1, p + 2, strlen (p + 2) + 1); 
    224224 
    225225        /* strip trailing "/." */ 
    226         if ((p = strrchr (ret, '/')) && *(p + 1) == '.' && *(p + 2) == '\0') 
     226        p = strrchr (ret, '/'); 
     227        if ((p != NULL) && (*(p + 1) == '.') && (*(p + 2) == '\0')) 
    227228            *p = '\0'; 
     229             
    228230        return ret; 
    229231    } 
    230232} 
     
    580582        return; 
    581583 
    582584    mc_file = concat_dir_and_file (mc_home, "mc.no_proxy"); 
    583     if (exist_file (mc_file) && 
    584         (npf = fopen (mc_file, "r"))) { 
    585         while (fgets (s, sizeof (s), npf)) { 
    586             if (!(p = strchr (s, '\n'))) {      /* skip bogus entries */  
    587                 while ((c = fgetc (npf)) != EOF && c != '\n') 
    588                     ; 
    589                 continue; 
    590             } 
    591  
    592             if (p == s) 
    593                 continue; 
    594  
    595             *p = '\0'; 
    596              
    597             np = g_new (struct no_proxy_entry, 1); 
    598             np->domain = g_strdup (s); 
    599             np->next   = NULL; 
    600             if (no_proxy) 
    601                 current->next = np; 
    602             else 
    603                 no_proxy = np; 
    604             current = np; 
    605         } 
    606  
    607         fclose (npf); 
     585    if (exist_file (mc_file)) { 
     586        npf = fopen (mc_file, "r"); 
     587        if (npf != NULL) { 
     588            while (fgets (s, sizeof (s), npf)) { 
     589                p = strchr (s, '\n'); 
     590                if (p == NULL) {  /* skip bogus entries */ 
     591                    while ((c = fgetc (npf)) != EOF && c != '\n') 
     592                        ; 
     593                    continue; 
     594                } 
     595 
     596                if (p == s) 
     597                    continue; 
     598 
     599                *p = '\0'; 
     600 
     601                np = g_new (struct no_proxy_entry, 1); 
     602                np->domain = g_strdup (s); 
     603                np->next   = NULL; 
     604                if (no_proxy) 
     605                    current->next = np; 
     606                else 
     607                    no_proxy = np; 
     608                current = np; 
     609            } 
     610            fclose (npf); 
     611        } 
    608612    } 
    609613    g_free (mc_file); 
    610614} 
     
    10931097    int s, j, data; 
    10941098    socklen_t fromlen = sizeof(from); 
    10951099     
    1096     if ((s = ftpfs_initconn (me, super)) == -1) 
     1100    s = ftpfs_initconn (me, super);  
     1101    if (s == -1) 
    10971102        return -1; 
     1103 
    10981104    if (ftpfs_changetype (me, super, isbinary) == -1) 
    10991105        return -1; 
     1106 
    11001107    if (reget > 0){ 
    11011108        j = ftpfs_command (me, super, WAIT_REPLY, "REST %d", reget); 
    11021109        if (j != CONTINUE) 
     
    16221629    int r; 
    16231630    int flush_directory_cache = (flags & OPT_FLUSH); 
    16241631 
    1625     if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) { 
    1626         g_free(mpath); 
     1632    rpath = vfs_s_get_path_mangle (me, mpath, &super, 0); 
     1633    if (rpath == NULL) { 
     1634        g_free (mpath); 
    16271635        return -1; 
    16281636    } 
    16291637    p = ftpfs_translate_path (me, super, rpath); 
     
    16321640    vfs_stamp_create (&vfs_ftpfs_ops, super); 
    16331641    if (flags & OPT_IGNORE_ERROR) 
    16341642        r = COMPLETE; 
     1643         
    16351644    if (r != COMPLETE) { 
    16361645        me->verrno = EPERM; 
    16371646        g_free (mpath); 
     
    20482057    /* Find our own domain name */ 
    20492058    if (gethostname (hostname, sizeof (hostname)) < 0) 
    20502059        *hostname = 0; 
    2051     if (!(domain = strchr (hostname, '.'))) 
     2060 
     2061    domain = strchr (hostname, '.'); 
     2062    if (domain == NULL) 
    20522063        domain = ""; 
    20532064 
    20542065    /* Scan for "default" and matching "machine" keywords */ 
  • lib/vfs/mc-vfs/mcfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/mcfs.c mc-4.7.1_new/lib/vfs/mc-vfs/mcfs.c
    old new  
    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 != NULL) 
    216217            return port; 
    217218#endif                          /* HAVE_PMAP_GETPORT */ 
    218219    *version = 1; 
     
    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)); 
    243     else { 
    244         if ((hp = gethostbyname (host)) == NULL) { 
     245    } else { 
     246        hp = gethostbyname (host); 
     247        if (hp == NULL) { 
    245248            message (D_ERROR, caller, _(" Cannot locate hostname: %s "), 
    246249                        host); 
    247250            return 0; 
     
    259262        *version = 1; 
    260263 
    261264    server_address.sin_port = htons (*port); 
    262  
    263     if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { 
     265    my_socket = socket (AF_INET, SOCK_STREAM, 0); 
     266    if (my_socket < 0) { 
    264267        message (D_ERROR, caller, _(" Cannot create socket: %s "), 
    265268                    unix_error_string (errno)); 
    266269        return 0; 
     
    340343        message (D_ERROR, MSG_ERROR, _(" Too many open connections ")); 
    341344        return 0; 
    342345    } 
    343  
    344     if (! 
    345         (sock = 
    346          mcfs_open_tcp_link (host, user, port, netrcpass, &version))) 
     346    sock = mcfs_open_tcp_link (host, user, port, netrcpass, &version); 
     347    if (sock == 0) 
    347348        return 0; 
    348349 
    349350    bucket = mcfs_get_free_bucket (); 
     
    394395     * remote portmapper to get the port number 
    395396     */ 
    396397    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))) { 
     398    remote_path = mcfs_get_host_and_username (path, &host, &user, &port, &pass); 
     399    if (remote_path != NULL) { 
     400        *mc = mcfs_open_link (host, user, &port, pass); 
     401        if (*mc == NULL) { 
    400402            g_free (remote_path); 
    401403            remote_path = NULL; 
    402404        } 
     405    } 
    403406    g_free (host); 
    404407    g_free (user); 
    405408    if (pass) 
     
    445448    mcfs_connection *mc; 
    446449    char *r1, *r2; 
    447450 
    448     if ((r1 = mcfs_get_path (&mc, s1)) == 0) 
     451    r1 = mcfs_get_path (&mc, s1); 
     452    if (r1 == NULL) 
    449453        return -1; 
    450454 
    451     if ((r2 = mcfs_get_path (&mc, s2)) == 0) { 
     455    r2 = mcfs_get_path (&mc, s2); 
     456    if (r2 == NULL) { 
    452457        g_free (r1); 
    453458        return -1; 
    454459    } 
     
    466471    mcfs_connection *mc; 
    467472    char *remote_file; 
    468473 
    469     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     474    remote_file = mcfs_get_path (&mc, path); 
     475    if (remote_file == NULL) 
    470476        return -1; 
    471477 
    472478    rpc_send (mc->sock, 
     
    482488    mcfs_connection *mc; 
    483489    char *remote_file; 
    484490 
    485     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     491    remote_file = mcfs_get_path (&mc, path); 
     492    if (remote_file == NULL) 
    486493        return -1; 
    487494 
    488495    rpc_send (mc->sock, 
     
    499506    mcfs_connection *mc; 
    500507    char *remote_file; 
    501508 
    502     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     509    remote_file = mcfs_get_path (&mc, path); 
     510    if (remote_file == NULL) 
    503511        return -1; 
    504512 
    505513    rpc_send (mc->sock, 
     
    537545 
    538546    (void) me; 
    539547 
    540     if (!(remote_file = mcfs_get_path (&mc, file))) 
     548    remote_file = mcfs_get_path (&mc, file); 
     549    if (remote_file == NULL) 
    541550        return 0; 
    542551 
    543552    rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT, 
     
    661670 
    662671    (void) me; 
    663672 
    664     if (!(remote_dir = mcfs_get_path (&mc, dirname))) 
    665         return 0; 
     673    remote_dir = mcfs_get_path (&mc, dirname); 
     674    if (remote_dir == NULL) 
     675        return NULL; 
    666676 
    667677    rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, 
    668678              RPC_END); 
     
    670680 
    671681    if (0 == 
    672682        rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) 
    673         return 0; 
     683        return NULL; 
    674684 
    675685    if (mcfs_is_error (result, error_num)) 
    676         return 0; 
     686        return NULL; 
    677687 
    678688    handle = result; 
    679689 
     
    683693    mcfs_info->entries = 0; 
    684694    mcfs_info->current = 0; 
    685695 
    686     return mcfs_info; 
     696    return (void *) mcfs_info; 
    687697} 
    688698 
    689699static int mcfs_get_stat_info (mcfs_connection * mc, struct stat *buf); 
     
    880890    mcfs_connection *mc; 
    881891    int status, error; 
    882892 
    883     if ((remote_file = mcfs_get_path (&mc, path)) == 0) 
     893    remote_file = mcfs_get_path (&mc, path); 
     894    if (remote_file == NULL) 
    884895        return -1; 
    885896 
    886897    rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END); 
     
    970981 
    971982    (void) me; 
    972983 
    973     if (!(file = mcfs_get_path (&mc, path))) 
     984    remote_file = mcfs_get_path (&mc, path); 
     985    if (remote_file == NULL) 
    974986        return -1; 
    975987 
    976988    status = 0; 
     
    10051017 
    10061018    (void) me; 
    10071019 
    1008     if (!(remote_file = mcfs_get_path (&mc, path))) 
     1020    remote_file = mcfs_get_path (&mc, path); 
     1021    if (remote_file == NULL) 
    10091022        return -1; 
    10101023 
    10111024    rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, 
     
    10621075 
    10631076    (void) me; 
    10641077 
    1065     if (!(remote_dir = mcfs_get_path (&mc, path))) 
     1078    remote_file = mcfs_get_path (&mc, path); 
     1079    if (remote_file == NULL) 
    10661080        return -1; 
    10671081 
    10681082    rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, 
     
    11371151        return; 
    11381152 
    11391153    path += 5; 
    1140     if (path[0] == '/' && path[1] == '/') 
     1154    if ((path[0] == '/') && (path[1] == '/')) 
    11411155        path += 2; 
    11421156 
    1143     if ((p = 
    1144          mcfs_get_host_and_username (path, &host, &user, &port, 
    1145                                      &pass)) == 0) { 
     1157    p = mcfs_get_host_and_username (path, &host, &user, &port, &pass); 
     1158    if (p == NULL) { 
    11461159        g_free (host); 
    11471160        g_free (user); 
    11481161        if (pass) 
  • lib/vfs/mc-vfs/mcserv.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/mcserv.c mc-4.7.1_new/lib/vfs/mc-vfs/mcserv.c
    old new  
    799799    up.password = password; 
    800800    conv.appdata_ptr = &up; 
    801801 
    802     if ((status = 
    803          pam_start ("mcserv", username, &conv, &pamh)) != PAM_SUCCESS) 
     802    status = pam_start ("mcserv", username, &conv, &pamh); 
     803    if (status != PAM_SUCCESS) 
    804804        goto failed_pam; 
    805     if ((status = pam_authenticate (pamh, 0)) != PAM_SUCCESS) 
     805 
     806    status = pam_authenticate (pamh, 0); 
     807    if (status != PAM_SUCCESS) 
    806808        goto failed_pam; 
    807     if ((status = pam_acct_mgmt (pamh, 0)) != PAM_SUCCESS) 
     809 
     810    status = pam_acct_mgmt (pamh, 0); 
     811    if (status != PAM_SUCCESS) 
    808812        goto failed_pam; 
    809     if ((status = pam_setcred (pamh, PAM_ESTABLISH_CRED)) != PAM_SUCCESS) 
     813 
     814    status = pam_setcred (pamh, PAM_ESTABLISH_CRED); 
     815    if (status != PAM_SUCCESS) 
    810816        goto failed_pam; 
     817 
    811818    pam_end (pamh, status); 
    812819    return 0; 
    813820 
     
    866873    local_address.sin_port = htons (21); 
    867874 
    868875    /*  Convert localhost to usable format */ 
    869     if ((inaddr = inet_addr ("127.0.0.1")) != INADDR_NONE) 
     876    inaddr = inet_addr ("127.0.0.1"); 
     877    if (inaddr != INADDR_NONE) 
    870878        memcpy ((char *) &local_address.sin_addr, (char *) &inaddr, 
    871879                sizeof (inaddr)); 
    872880 
    873     if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { 
     881    my_socket = socket (AF_INET, SOCK_STREAM, 0); 
     882    if (my_socket < 0) { 
    874883        if (!isDaemon) 
    875884            fprintf (stderr, "do_auth: can't create socket\n"); 
    876885        return 0; 
     
    916925    struct spwd *spw; 
    917926#endif 
    918927 
    919     if ((pw = getpwnam (username)) == 0) 
     928    pw = getpwnam (username); 
     929    if (pw == NULL) 
    920930        return 0; 
    921931 
    922932#ifdef HAVE_SHADOW 
    923933    setspent (); 
    924934 
    925935    /* Password expiration is not checked! */ 
    926     if ((spw = getspnam (username)) == NULL) 
     936    spw = getspnam (username); 
     937    if (spw == NULL) 
    927938        encr_pwd = "*"; 
    928939    else 
    929940        encr_pwd = spw->sp_pwdp; 
     
    12001211    struct sockaddr_in client_address, server_address; 
    12011212    int yes = 1; 
    12021213 
    1203     if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) 
     1214    sock = socket (AF_INET, SOCK_STREAM, 0); 
     1215    if (sock < 0) 
    12041216        return "Cannot create socket"; 
    12051217 
    12061218    /* Use this to debug: */ 
     
    12271239        newsocket = 
    12281240            accept (sock, (struct sockaddr *) &client_address, &clilen); 
    12291241 
    1230         if (isDaemon && (child = fork ())) { 
     1242        child = fork (); 
     1243        if (isDaemon && child) { 
    12311244            int status; 
    12321245 
    12331246            close (newsocket); 
     
    13731386        register_port (portnum, 0); 
    13741387        if (verbose) 
    13751388            printf ("Using port %d\n", portnum); 
    1376         if ((result = get_client (portnum))) 
     1389 
     1390        result = get_client (portnum); 
     1391        if (result != NULL) 
    13771392            perror (result); 
    13781393#ifdef HAVE_PMAP_SET 
    1379         if (!isDaemon) 
     1394        if (isDaemon == NULL) 
    13801395            pmap_unset (RPC_PROGNUM, RPC_PROGVER); 
    13811396#endif 
    13821397    } 
  • lib/vfs/mc-vfs/sfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/sfs.c mc-4.7.1_new/lib/vfs/mc-vfs/sfs.c
    old new  
    8484 
    8585    pname = g_strdup (name); 
    8686    vfs_split (pname, &inpath, &op); 
    87     if ((w = (*me->which) (me, op)) == -1) 
     87    w = (*me->which) (me, op); 
     88    if (w == -1) 
    8889        vfs_die ("This cannot happen... Hopefully.\n"); 
    8990 
    9091    if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) { 
     
    392393        } 
    393394        if (!*c) 
    394395            goto invalid_line; 
     396 
    395397        c++; 
    396398        *(semi+1) = 0; 
    397         if ((semi = strchr (c, '\n'))) 
     399        semi = strchr (c, '\n'); 
     400        if (semi != NULL) 
    398401            *semi = 0; 
    399402 
    400403        sfs_prefix [sfs_no] = g_strdup (key); 
  • lib/vfs/mc-vfs/tar.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/tar.c mc-4.7.1_new/lib/vfs/mc-vfs/tar.c
    old new  
    666666 
    667667    current_tar_position = 0; 
    668668    /* Open for reading */ 
    669     if ((tard = tar_open_archive_int (me, name, archive)) == -1) 
     669    tard = tar_open_archive_int (me, name, archive); 
     670    if (tard == -1) 
    670671        return -1; 
    671672 
    672673    for (;;) { 
     
    772773 
    773774    count = MIN(count, FH->ino->st.st_size - FH->pos); 
    774775 
    775     if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1); 
     776    count = mc_read (fd, buffer, count); 
     777    if (count == -1)  
     778        ERRNOR (errno, -1); 
    776779 
    777780    FH->pos += count; 
    778781    return count; 
  • lib/vfs/mc-vfs/undelfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/undelfs.c mc-4.7.1_new/lib/vfs/mc-vfs/undelfs.c
    old new  
    206206        message (D_ERROR, undelfserr, _(" while allocating block buffer ")); 
    207207        goto free_delarray; 
    208208    } 
    209     if ((retval = ext2fs_open_inode_scan (fs, 0, &scan))) 
     209    retval = ext2fs_open_inode_scan (fs, 0, &scan); 
     210    if (retval) 
    210211    { 
    211212        message (D_ERROR, undelfserr, _(" open_inode_scan: %d "), retval); 
    212213        goto free_block_buf; 
    213214    } 
    214     if ((retval = ext2fs_get_next_inode (scan, &ino, &inode))) 
     215    retval = ext2fs_get_next_inode (scan, &ino, &inode); 
     216    if (retval) 
    215217    { 
    216218        message (D_ERROR, undelfserr, _(" while starting inode scan %d "), retval); 
    217219        goto error_out; 
    218220    } 
    219  
    220221    count = 0; 
    221222    while (ino) 
    222223    { 
     
    674675    /* We may use access because ext2 file systems are local */ 
    675676    /* this could be fixed by making an ext2fs io manager to use */ 
    676677    /* our vfs, but that is left as an excercise for the reader */ 
    677     if ((fd = open (file, O_RDONLY)) == -1) 
     678    fd = open (file, O_RDONLY); 
     679    if (fd == -1) 
    678680    { 
    679681        message (D_ERROR, undelfserr, _(" Cannot open file %s "), file); 
    680682        g_free (f); 
  • lib/vfs/mc-vfs/utilvfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/utilvfs.c mc-4.7.1_new/lib/vfs/mc-vfs/utilvfs.c
    old new  
    233233    if (!str) 
    234234        return 0; 
    235235 
    236     if ((pos = strstr (week, str)) != NULL) { 
     236    pos = strstr (week, str); 
     237    if (pos != NULL) { 
    237238        if (tim != NULL) 
    238239            tim->tm_wday = (pos - week) / 3; 
    239240        return 1; 
     
    250251    if (!str) 
    251252        return 0; 
    252253 
    253     if ((pos = strstr (month, str)) != NULL) { 
     254    pos = strstr (month, str); 
     255    if (pos != NULL) { 
    254256        if (tim != NULL) 
    255257            tim->tm_mon = (pos - month) / 3; 
    256258        return 1; 
     
    287289{ 
    288290    const char *p, *p2; 
    289291 
    290     if (!str) 
     292    if (str == NULL) 
    291293        return 0; 
    292294 
    293     if ((p = strchr (str, ':')) && (p2 = strrchr (str, ':'))) { 
     295    p = strchr (str, ':'); 
     296    p2 = strrchr (str, ':'); 
     297    if (p && p2) { 
    294298        if (p != p2) { 
    295299            if (sscanf 
    296300                (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, 
     
    619623 
    620624        tim.tm_year--; 
    621625 
    622     if (l10n || (*t = mktime (&tim)) < 0) 
     626    *t = mktime (&tim); 
     627    if (l10n || (*t < 0)) 
    623628        *t = 0; 
    624629    return idx; 
    625630} 
  • lib/vfs/mc-vfs/vfs.c

    diff -urN mc-4.7.1_old/lib/vfs/mc-vfs/vfs.c mc-4.7.1_new/lib/vfs/mc-vfs/vfs.c
    old new  
    237237        vfs_die ("vfs_strip_suffix_from_path got NULL: impossible"); 
    238238 
    239239    p = g_strdup (filename); 
    240     if (!(semi = strrchr (p, '#'))) 
     240    semi = strrchr (p, '#'); 
     241    if (semi == NULL) 
    241242        return p; 
    242243 
    243244    /* Avoid last class (localfs) that would accept any prefix */ 
     
    305306    if (slash) 
    306307        *slash = 0; 
    307308 
    308     if ((ret = vfs_prefix_to_class (semi+1))){ 
     309    ret = vfs_prefix_to_class (semi + 1); 
     310    if (ret != NULL) { 
    309311        if (op)  
    310312            *op = semi + 1; 
    311313        if (inpath) 
     
    474476                    errno = EINVAL; 
    475477                    return ESTR_FAILURE; 
    476478                } 
    477                 break; 
    478479            default: 
    479480                errno = EINVAL; 
    480481                return ESTR_FAILURE; 
  • src/background.c

    diff -urN mc-4.7.1_old/src/background.c mc-4.7.1_new/src/background.c
    old new  
    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]); 
     
    156157        (void) close (back_comm[1]); 
    157158        errno = saved_errno; 
    158159        return -1; 
    159     } 
    160  
    161     if (pid == 0) { 
     160    } else if (pid == 0) { 
    162161        int nullfd; 
    163162 
    164163        parent_fd = comm[1]; 
     
    172171        close (1); 
    173172        close (2); 
    174173 
    175         if ((nullfd = open ("/dev/null", O_RDWR)) != -1) { 
     174        nullfd = open ("/dev/null", O_RDWR); 
     175        if (nullfd != -1) { 
    176176            while (dup2 (nullfd, 0) == -1 && errno == EINTR); 
    177177            while (dup2 (nullfd, 1) == -1 && errno == EINTR); 
    178178            while (dup2 (nullfd, 2) == -1 && errno == EINTR); 
  • src/charsets.c

    diff -urN mc-4.7.1_old/src/charsets.c mc-4.7.1_new/src/charsets.c
    old new  
    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 == NULL) { 
    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 == NULL) { 
    6668            fprintf (stderr, _("Warning: file %s not found\n"), fname); 
    6769            g_free (fname); 
    6870 
  • src/complete.c

    diff -urN mc-4.7.1_old/src/complete.c mc-4.7.1_new/src/complete.c
    old new  
    114114        g_free (filename); 
    115115        g_free (users_dirname); 
    116116 
    117         if ((*text) && (temp = strrchr (text, PATH_SEP))){ 
     117        temp = strrchr (text, PATH_SEP); 
     118        if ((*text) && temp) { 
    118119            filename = g_strdup (++temp); 
    119120            dirname = g_strndup (text, temp - text); 
    120121        } else { 
     
    493494            words = bash_reserved; 
    494495            phase = 0; 
    495496            text_len = strlen (text); 
    496             if (!path && (path = g_strdup (getenv ("PATH"))) != NULL) { 
    497                 p = path; 
    498                 path_end = strchr (p, 0); 
    499                 while ((p = strchr (p, PATH_ENV_SEP))) { 
    500                     *p++ = 0; 
     497            if (path == NULL) { 
     498                path = g_strdup (getenv ("PATH")); 
     499                if (path != NULL) { 
     500                    p = path;  
     501                    path_end = strchr (p, 0); 
     502                    while ((p = strchr (p, PATH_ENV_SEP))) { 
     503                        *p++ = 0; 
     504                    } 
    501505                } 
    502506            } 
    503507        } 
     
    560564            } 
    561565        } 
    562566    } 
    563  
    564567    if (found == NULL) { 
    565568        g_free (path); 
    566569        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); 
     570    } else { 
     571        p = strrchr (found, PATH_SEP); 
     572        if (p != NULL) { 
     573            char *tmp = found; 
     574            found = strutils_shell_escape (p + 1); 
     575            g_free (tmp); 
     576        } 
    571577    } 
    572578 
    573579    g_free(text); 
     
    10741080            Dlg_head *query_dlg; 
    10751081            WListbox *query_list; 
    10761082 
    1077             for (p=in->completions + 1; *p; count++, p++) 
    1078                 if ((i = str_term_width1 (*p)) > maxlen) 
     1083            for (p=in->completions + 1; *p; count++, p++) { 
     1084                i = str_term_width1 (*p); 
     1085                if (i > maxlen) 
    10791086                    maxlen = i; 
     1087            } 
    10801088            start_x = in->widget.x; 
    10811089            start_y = in->widget.y; 
    10821090            if (start_y - 2 >= count) { 
  • src/editor/choosesyntax.c

    diff -urN mc-4.7.1_old/src/editor/choosesyntax.c mc-4.7.1_new/src/editor/choosesyntax.c
    old new  
    7878    while (names[count++] != NULL); 
    7979    qsort(names, count - 1, sizeof(char*), pstrcmp); 
    8080 
    81     if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) { 
     81    syntax = exec_edit_syntax_dialog ((const char**) names); 
     82    if (syntax < 0) { 
    8283        for (i = 0; names[i]; i++) { 
    8384            g_free (names[i]); 
    8485        } 
  • src/editor/edit.c

    diff -urN mc-4.7.1_old/src/editor/edit.c mc-4.7.1_new/src/editor/edit.c
    old new  
    295295    edit->curs2 = edit->last_byte; 
    296296    buf2 = edit->curs2 >> S_EDIT_BUF_SIZE; 
    297297    edit->utf8 = 0; 
    298     if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) { 
     298    file = mc_open (filename, O_RDONLY | O_BINARY); 
     299    if (file == -1) { 
    299300        GString *errmsg = g_string_new(NULL); 
    300301        g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename); 
    301302        edit_error_dialog (_("Error"), get_sys_error (errmsg->str)); 
     
    521522        long current = edit->curs1; 
    522523        int vertical_insertion = 0; 
    523524        char *buf; 
    524         if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) 
     525        file = mc_open (filename, O_RDONLY | O_BINARY); 
     526        if (file == -1) 
    525527            return 0; 
    526528        buf = g_malloc0 (TEMP_BUF_LEN); 
    527529        blocklen = mc_read (file, buf, sizeof(VERTICAL_MAGIC)); 
     
    11161118        return STACK_BOTTOM; 
    11171119    } 
    11181120    sp = (sp - 1) & edit->stack_size_mask; 
    1119     if ((c = edit->undo_stack[sp]) >= 0) { 
     1121    c = edit->undo_stack[sp]; 
     1122    if (c >= 0) { 
    11201123/*      edit->undo_stack[sp] = '@'; */ 
    11211124        edit->stack_pointer = (edit->stack_pointer - 1) & edit->stack_size_mask; 
    11221125        return c; 
  • src/editor/editcmd.c

    diff -urN mc-4.7.1_old/src/editor/editcmd.c mc-4.7.1_new/src/editor/editcmd.c
    old new  
    277277    mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid); 
    278278    mc_chmod (savename, edit->stat1.st_mode); 
    279279 
    280     if ((fd = 
    281          mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, edit->stat1.st_mode)) == -1) 
     280    fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, edit->stat1.st_mode); 
     281    if (fd == -1) 
    282282        goto error_save; 
    283283 
    284284    /* pipe save */ 
    285     if ((p = edit_get_write_filter (savename, real_filename))) 
     285    p = edit_get_write_filter (savename, real_filename); 
     286    if (p != NULL) 
    286287    { 
    287288        FILE *file; 
    288289 
     
    599600            { 
    600601                int file; 
    601602                different_filename = 1; 
    602                 if ((file = mc_open (exp, O_RDONLY | O_BINARY)) != -1) 
     603                file = mc_open (exp, O_RDONLY | O_BINARY); 
     604                if (file != -1) 
    603605                { 
    604606                    /* the file exists */ 
    605607                    mc_close (file); 
     
    691693    FILE *fd; 
    692694    int file; 
    693695    filename = concat_dir_and_file (home_dir, EDIT_MACRO_FILE); 
    694     if ((file = open (filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) 
     696    file = open (filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 
     697    if (file == -1) 
    695698    { 
    696699        g_free (filename); 
    697700        return 0; 
     
    732735    (void) edit; 
    733736 
    734737    if (saved_macros_loaded) 
    735         if ((j = macro_exists (k)) < 0) 
     738    { 
     739        j = macro_exists (k); 
     740        if (j < 0) 
    736741            return 0; 
     742    } 
    737743    tmp = concat_dir_and_file (home_dir, EDIT_TEMP_FILE); 
    738744    g = fopen (tmp, "w"); 
    739745    g_free (tmp); 
     
    844850        if (macro_exists (k) < 0) 
    845851            return 0; 
    846852 
    847     if ((f = edit_open_macro_file ("r"))) 
     853    f = edit_open_macro_file ("r"); 
     854    if (f != NULL) 
    848855    { 
    849856        struct macro dummy; 
    850857        do 
     
    20812088{ 
    20822089    int len, file; 
    20832090 
    2084     if ((file = 
    2085          mc_open (filename, O_CREAT | O_WRONLY | O_TRUNC, 
    2086                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY)) == -1) 
     2091    file = mc_open (filename, O_CREAT | O_WRONLY | O_TRUNC, 
     2092                    S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY); 
     2093    if (file == -1) 
    20872094        return 0; 
    20882095 
    20892096    if (column_highlighting) 
  • src/editor/editlock.c

    diff -urN mc-4.7.1_old/src/editor/editlock.c mc-4.7.1_new/src/editor/editlock.c
    old new  
    152152    int cnt; 
    153153    static char buf[BUF_SIZE]; 
    154154 
    155     if ((cnt = readlink (lockfname, buf, BUF_SIZE - 1)) == -1 || !*buf) 
     155    cnt = readlink (lockfname, buf, BUF_SIZE - 1); 
     156    if (cnt == -1 || !*buf) 
    156157        return NULL; 
    157158    buf[cnt] = '\0'; 
    158159    return buf; 
  • src/editor/syntax.c

    diff -urN mc-4.7.1_old/src/editor/syntax.c mc-4.7.1_new/src/editor/syntax.c
    old new  
    141141    int argc; 
    142142 
    143143    while (*argv && argv < argv_end) { 
    144         if ((t = g_tree_lookup (defines, *argv))) { 
     144        t = g_tree_lookup (defines, *argv); 
     145        if (t != NULL) { 
    145146            int count = 0; 
    146147 
    147148            /* Count argv array members */ 
     
    304305    long end = 0; 
    305306    struct syntax_rule _rule = rule; 
    306307 
    307     if (!(c = edit_get_byte (edit, i))) 
     308    c = edit_get_byte (edit, i); 
     309    if (!c) 
    308310        return rule; 
    309311    is_end = (rule.end == (unsigned char) i); 
    310312 
     
    322324    if (_rule.context && !_rule.keyword) { 
    323325        long e; 
    324326        r = edit->rules[_rule.context]; 
    325         if (r->first_right == c && !(rule.border & RULE_ON_RIGHT_BORDER) && (e = compare_word_to_right (edit, i, r->right, r->whole_word_chars_left, r->whole_word_chars_right, r->line_start_right)) > 0) { 
     327        e = compare_word_to_right (edit, i, r->right,  
     328                                   r->whole_word_chars_left,  
     329                                   r->whole_word_chars_right,  
     330                                   r->line_start_right); 
     331        if (r->first_right == c && !(rule.border & RULE_ON_RIGHT_BORDER) && e > 0) { 
    326332            _rule.end = e; 
    327333            found_right = 1; 
    328334            _rule.border = RULE_ON_RIGHT_BORDER; 
     
    383389                    _rule.context = _rule._context; 
    384390                    contextchanged = 1; 
    385391                    _rule.keyword = 0; 
    386                     if (r->first_right == c && (e = compare_word_to_right (edit, i, r->right, r->whole_word_chars_left, r->whole_word_chars_right, r->line_start_right)) >= end) { 
     392                    e = compare_word_to_right (edit, i, r->right,  
     393                                               r->whole_word_chars_left,  
     394                                               r->whole_word_chars_right,  
     395                                               r->line_start_right); 
     396                    if (r->first_right == c && e >= end) { 
    387397                        _rule.end = e; 
    388398                        found_right = 1; 
    389399                        _rule.border = RULE_ON_RIGHT_BORDER; 
     
    928938 
    929939            if (argc < 3) 
    930940                break_a; 
    931             if ((argv = g_tree_lookup (edit->defines, key))) { 
     941 
     942            argv = g_tree_lookup (edit->defines, key); 
     943            if (argv != NULL) 
    932944                mc_defines_destroy (NULL, argv, NULL); 
    933             } else { 
     945            else 
    934946                key = g_strdup (key); 
    935             } 
     947 
    936948            argv = g_new (char *, argc - 1); 
    937949            g_tree_insert (edit->defines, key, argv); 
    938950            while (*a) { 
     
    10671079        if (!found && !strcmp (args[0], "include")) { 
    10681080            if (g) 
    10691081                continue; 
    1070             if (!args[1] || !(g = open_include_file (args[1]))) { 
    1071                 result = line; 
    1072                 break; 
     1082            if (args[1] == NULL) { 
     1083                result = line; 
     1084                break; 
     1085            } else { 
     1086                g = open_include_file (args[1]); 
     1087                if (g == NULL) { 
     1088                    result = line; 
     1089                    break; 
     1090                } 
    10731091            } 
    10741092            goto found_type; 
    10751093        } 
  • src/ext.c

    diff -urN mc-4.7.1_old/src/ext.c mc-4.7.1_new/src/ext.c
    old new  
    155155            if (*lc_data == '{') 
    156156                parameter_found = 1; 
    157157            else { 
    158                 int i = check_format_view (lc_data); 
     158                int i1, i2, i3; 
    159159                char *v; 
     160                 
     161                i1 = check_format_view (lc_data); 
     162                i2 = check_format_cd (lc_data); 
     163                i3 = check_format_var (lc_data, &v); 
    160164 
    161                 if (i) { 
    162                     lc_data += i - 1; 
     165                if (i1) { 
     166                    lc_data += i1 - 1; 
    163167                    run_view = 1; 
    164                 } else if ((i = check_format_cd (lc_data)) > 0) { 
     168                } else if (i2 > 0) { 
    165169                    is_cd = 1; 
    166170                    quote_func = fake_name_quote; 
    167171                    do_local_copy = 0; 
    168172                    p = buffer; 
    169                     lc_data += i - 1; 
    170                 } else if ((i = check_format_var (lc_data, &v)) > 0 && v) { 
     173                    lc_data += i2 - 1; 
     174                } else if (i3 > 0 && v) { 
    171175                    fputs (v, cmd_file); 
    172176                    g_free (v); 
    173                     lc_data += i; 
     177                    lc_data += i3; 
    174178                } else { 
    175179                    char *text; 
    176180 
  • src/file.c

    diff -urN mc-4.7.1_old/src/file.c mc-4.7.1_new/src/file.c
    old new  
    10921092 
    10931093    if (!ctx->do_append) { 
    10941094        if (S_ISLNK (src_stats.st_mode) && ctx->stable_symlinks) { 
    1095             if ((return_status = make_symlink (ctx, s, d)) == FILE_CONT) { 
     1095            return_status = make_symlink (ctx, s, d); 
     1096            if (return_status == FILE_CONT) { 
    10961097                goto retry_src_remove; 
    10971098            } else 
    10981099                return return_status; 
  • src/filenot.c

    diff -urN mc-4.7.1_old/src/filenot.c mc-4.7.1_new/src/filenot.c
    old new  
    7676    q = vfs_canon (p); 
    7777    g_free (p); 
    7878 
    79     if (!(result = my_mkdir_rec (q, mode))) 
     79    result = my_mkdir_rec (q, mode); 
     80    if (result == 0) 
    8081        result = mc_mkdir (s, mode); 
    8182 
    8283    g_free (q); 
  • src/hotlist.c

    diff -urN mc-4.7.1_old/src/hotlist.c mc-4.7.1_new/src/hotlist.c
    old new  
    12721272        break; 
    12731273    case '"': 
    12741274        while ((c = getc (hotlist_file)) != EOF && c != '"') { 
    1275             if (c == '\\') 
    1276                 if ((c = getc (hotlist_file)) == EOF){ 
     1275            if (c == '\\') { 
     1276                c = getc (hotlist_file); 
     1277                if (c == EOF) { 
    12771278                    g_string_free (tkn_buf, TRUE); 
    12781279                    return TKN_EOF; 
    12791280                } 
     1281            } 
    12801282            g_string_append_c (tkn_buf, c == '\n' ? ' ' : c); 
    12811283        } 
    12821284        if (c == EOF) 
     
    12851287            ret = TKN_STRING; 
    12861288        break; 
    12871289    case '\\': 
    1288         if ((c = getc (hotlist_file)) == EOF){ 
     1290        c = getc (hotlist_file); 
     1291        if (c == EOF) { 
    12891292            g_string_free (tkn_buf, TRUE); 
    12901293            return TKN_EOF; 
    12911294        } 
     
    13231326} 
    13241327 
    13251328#define CHECK_TOKEN(_TKN_) \ 
    1326 if ((tkn = hot_next_token ()) != _TKN_) { \ 
     1329tkn = hot_next_token (); \ 
     1330if (tkn != _TKN_) { \ 
    13271331    hotlist_state.readonly = 1; \ 
    13281332    hotlist_state.file_error = 1; \ 
    13291333    while (tkn != TKN_EOL && tkn != TKN_EOF) \ 
     
    14731477     */ 
    14741478    hotlist->directory = g_strdup ("Hotlist"); 
    14751479 
    1476     if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0) { 
     1480    hotlist_file = fopen (hotlist_file_name, "r"); 
     1481    if (hotlist_file == NULL) { 
    14771482        int     result; 
    14781483 
    14791484        load_group (hotlist); 
     
    15751580    if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name) { 
    15761581        mc_util_make_backup_if_possible (hotlist_file_name, ".bak"); 
    15771582 
    1578         if ((hotlist_file = fopen (hotlist_file_name, "w")) != 0) { 
     1583        hotlist_file = fopen (hotlist_file_name, "w"); 
     1584        if (hotlist_file != NULL) { 
    15791585            hot_save_group (hotlist); 
    15801586            fclose (hotlist_file); 
    15811587            stat (hotlist_file_name, &stat_buf); 
  • src/main.c

    diff -urN mc-4.7.1_old/src/main.c mc-4.7.1_new/src/main.c
    old new  
    436436get_parent_dir_name (const char *cwd, const char *lwd) 
    437437{ 
    438438    const char *p; 
    439     if (strlen (lwd) > strlen (cwd)) 
    440         if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd) && 
    441          ((gsize)strlen (cwd) == (gsize) p - (gsize) lwd || (p == lwd && cwd[0] == PATH_SEP && 
    442           cwd[1] == '\0'))) { 
     439    if (strlen (lwd) > strlen (cwd)) { 
     440        p = strrchr (lwd, PATH_SEP); 
     441        if (p == NULL) 
     442            return NULL; 
     443         
     444        if (!strncmp (cwd, lwd, p - lwd)  
     445            && ((gsize) strlen (cwd) == ((gsize) p - (gsize) lwd) 
     446            || (p == lwd && cwd[0] == PATH_SEP && cwd[1] == '\0'))) { 
    443447            return (p + 1); 
    444448        } 
     449    } 
    445450    return NULL; 
    446451} 
    447452 
  • src/mountlist.c

    diff -urN mc-4.7.1_old/src/mountlist.c mc-4.7.1_new/src/mountlist.c
    old new  
    647647 
    648648        if (!getcwd(dir, _POSIX_PATH_MAX)) return (NULL); 
    649649 
    650         if ((fd = open(dir, O_RDONLY)) == -1) return (NULL); 
     650        fd = open (dir, O_RDONLY); 
     651        if (fd == -1)  
     652            return (NULL); 
    651653 
    652654        i = disk_get_entry(fd, &de); 
    653655 
     
    745747        struct mount_entry      *entry; 
    746748    struct fs_usage             fs_use; 
    747749 
    748         if ((entry = read_filesystem_list(0, 0)) != NULL) 
     750        entry = read_filesystem_list (0, 0); 
     751        if (entry != NULL) 
    749752        { 
    750753                get_fs_usage(entry->me_mountdir, &fs_use); 
    751754 
  • src/subshell.c

    diff -urN mc-4.7.1_old/src/subshell.c mc-4.7.1_new/src/subshell.c
    old new  
    436436 
    437437            /* Opening the FIFO as O_RDONLY or O_WRONLY causes deadlock */ 
    438438 
    439             if ((subshell_pipe[READ] = open (tcsh_fifo, O_RDWR)) == -1 
    440                 || (subshell_pipe[WRITE] = 
    441                     open (tcsh_fifo, O_RDWR)) == -1) { 
     439            subshell_pipe[READ] = open (tcsh_fifo, O_RDWR); 
     440            subshell_pipe[WRITE] = open (tcsh_fifo, O_RDWR); 
     441            if (subshell_pipe[READ] == -1 || subshell_pipe[WRITE] == -1) { 
    442442                fprintf (stderr, _("Cannot open named pipe %s\n"), tcsh_fifo); 
    443443                perror (__FILE__": open"); 
    444444                use_subshell = FALSE; 
     
    463463        /* We exit here because, if the process table is full, the */ 
    464464        /* other method of running user commands won't work either */ 
    465465        exit (1); 
    466     } 
    467  
    468     if (subshell_pid == 0) {    /* We are in the child process */ 
     466    } else if (subshell_pid == 0) {     /* We are in the child process */ 
    469467        init_subshell_child (pty_name); 
    470468    } 
    471469 
     
    11781176            pty_name [9] = *ptr2; 
    11791177 
    11801178            /* Try to open master */ 
    1181             if ((pty_master = open (pty_name, O_RDWR)) == -1) { 
     1179            pty_master = open (pty_name, O_RDWR); 
     1180            if (pty_master == -1) { 
    11821181                if (errno == ENOENT)  /* Different from EIO */ 
    11831182                    return -1;        /* Out of pty devices */ 
    11841183                else 
     
    12091208        /* chown (pty_name, getuid (), group_info->gr_gid);  FIXME */ 
    12101209        /* chmod (pty_name, S_IRUSR | S_IWUSR | S_IWGRP);   FIXME */ 
    12111210    } 
    1212     if ((pty_slave = open (pty_name, O_RDWR)) == -1) 
     1211    pty_slave = open (pty_name, O_RDWR); 
     1212    if (pty_slave == -1) 
    12131213        fprintf (stderr, "open (pty_name, O_RDWR): %s\r\n", pty_name); 
    12141214    fcntl(pty_slave, F_SETFD, FD_CLOEXEC); 
    12151215    return pty_slave; 
  • src/treestore.c

    diff -urN mc-4.7.1_old/src/treestore.c mc-4.7.1_new/src/treestore.c
    old new  
    375375    name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_TREESTORE_FILE, NULL); 
    376376    mc_util_make_backup_if_possible (name, ".tmp"); 
    377377 
    378     if ((retval = tree_store_save_to(name)) != 0) { 
     378    retval = tree_store_save_to (name); 
     379    if (retval != 0) { 
    379380        mc_util_restore_from_backup_if_possible (name, ".tmp"); 
    380381        g_free(name); 
    381382        return retval; 
  • src/user.c

    diff -urN mc-4.7.1_old/src/user.c mc-4.7.1_new/src/user.c
    old new  
    301301            *block = 0; 
    302302            for (i = 0; i < panel->count; i++) 
    303303                if (panel->dir.list[i].f.marked) { 
    304                     strcat (block, tmp = 
    305                             (*quote_func) (panel->dir.list[i].fname, 0)); 
     304                    tmp = (*quote_func) (panel->dir.list[i].fname, 0); 
     305                    strcat (block, tmp); 
    306306                    g_free (tmp); 
    307307                    strcat (block, " "); 
    308308                    if (c_lc == 'u') 
     
    784784        } 
    785785    } 
    786786 
    787     if ((data = load_file (menu)) == NULL){ 
     787    data = load_file (menu); 
     788    if (data == NULL) { 
    788789        message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), 
    789790                 menu, unix_error_string (errno)); 
    790791        g_free (menu); 
  • src/viewer/datasource.c

    diff -urN mc-4.7.1_old/src/viewer/datasource.c mc-4.7.1_new/src/viewer/datasource.c
    old new  
    373373    mcview_close_datasource (view); 
    374374 
    375375    open_error_pipe (); 
    376     if ((fp = popen (command, "r")) == NULL) 
     376    fp = popen (command, "r"); 
     377    if (fp == NULL) 
    377378    { 
    378379        /* Avoid two messages.  Message from stderr has priority.  */ 
    379380        mcview_display (view); 
  • src/viewer/mcviewer.c

    diff -urN mc-4.7.1_old/src/viewer/mcviewer.c mc-4.7.1_new/src/viewer/mcviewer.c
    old new  
    347347    else if (file != NULL && file[0] != '\0') 
    348348    { 
    349349        /* Open the file */ 
    350         if ((fd = mc_open (file, O_RDONLY | O_NONBLOCK)) == -1) 
     350        fd = mc_open (file, O_RDONLY | O_NONBLOCK); 
     351        if (fd == -1) 
    351352        { 
    352353            g_snprintf (tmp, sizeof (tmp), _(" Cannot open \"%s\"\n %s "), 
    353354                        file, unix_error_string (errno));