Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Cosmetic: remove unnecessary parenthesization in re...



details:   https://anonhg.NetBSD.org/src/rev/8b3574f64492
branches:  trunk
changeset: 757558:8b3574f64492
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Sun Sep 05 18:03:37 2010 +0000

description:
Cosmetic: remove unnecessary parenthesization in return statements.
Don't "test truth" of ints, but compare with 0, instead.

The generated assembly is the same before & after this change.

diffstat:

 sys/kern/tty_pty.c |  120 ++++++++++++++++++++++++++--------------------------
 1 files changed, 60 insertions(+), 60 deletions(-)

diffs (truncated from 430 to 300 lines):

diff -r 2b123541629a -r 8b3574f64492 sys/kern/tty_pty.c
--- a/sys/kern/tty_pty.c        Sun Sep 05 12:36:46 2010 +0000
+++ b/sys/kern/tty_pty.c        Sun Sep 05 18:03:37 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_pty.c,v 1.122 2010/06/13 03:32:47 yamt Exp $       */
+/*     $NetBSD: tty_pty.c,v 1.123 2010/09/05 18:03:37 dyoung Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.122 2010/06/13 03:32:47 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.123 2010/09/05 18:03:37 dyoung Exp $");
 
 #include "opt_ptm.h"
 
@@ -189,7 +189,7 @@
                if (ptn >= maxptys) {
            limit_reached:
                        tablefull("pty", "increase kern.maxptys");
-                       return (ENXIO);
+                       return ENXIO;
                }
 
                /* Allocate a larger pty array */
@@ -262,7 +262,7 @@
                        seldestroy(&pti->pt_selr);
                        seldestroy(&pti->pt_selw);
                        kmem_free(pti, sizeof(*pti));
-                       return (0);
+                       return 0;
                }
                tty_attach(pti->pt_tty);
                pt_softc[ptn] = pti;
@@ -270,7 +270,7 @@
                mutex_exit(&pt_softc_mutex);
        }
 
-       return (0);
+       return 0;
 }
 
 /*
@@ -281,7 +281,7 @@
 pty_maxptys(int newmax, int set)
 {
        if (!set)
-               return (maxptys);
+               return maxptys;
 
        /*
         * We have to grab the pt_softc lock, so that we would pick correct
@@ -332,7 +332,7 @@
        int ptn = minor(dev);
 
        if ((error = pty_check(ptn)) != 0)
-               return (error);
+               return error;
 
        mutex_spin_enter(&tty_lock);
        pti = pt_softc[ptn];
@@ -348,7 +348,7 @@
        } else if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN,
            tp) != 0) {
                mutex_spin_exit(&tty_lock);
-               return (EBUSY);
+               return EBUSY;
        }
        if (tp->t_oproc)                        /* Ctrlr still around. */
                SET(tp->t_state, TS_CARR_ON);
@@ -357,16 +357,16 @@
                        tp->t_wopen++;
                        error = ttysleep(tp, &tp->t_rawcv, true, 0);
                        tp->t_wopen--;
-                       if (error) {
+                       if (error != 0) {
                                mutex_spin_exit(&tty_lock);
-                               return (error);
+                               return error;
                        }
                }
        }
        mutex_spin_exit(&tty_lock);
        error = (*tp->t_linesw->l_open)(dev, tp);
        ptcwakeup(tp, FREAD|FWRITE);
-       return (error);
+       return error;
 }
 
 int
@@ -379,7 +379,7 @@
        error = (*tp->t_linesw->l_close)(tp, flag);
        error |= ttyclose(tp);
        ptcwakeup(tp, FREAD|FWRITE);
-       return (error);
+       return error;
 }
 
 int
@@ -399,24 +399,24 @@
                            p->p_pgrp->pg_jobc == 0 ||
                            p->p_lflag & PL_PPWAIT) {
                                mutex_spin_exit(&tty_lock);
-                               return (EIO);
+                               return EIO;
                        }
                        ttysig(tp, TTYSIG_PG1, SIGTTIN);
                        error = ttysleep(tp, &lbolt, true, 0);
-                       if (error) {
+                       if (error != 0) {
                                mutex_spin_exit(&tty_lock);
-                               return (error);
+                               return error;
                        }
                }
                if (tp->t_canq.c_cc == 0) {
                        if (flag & IO_NDELAY) {
                                mutex_spin_exit(&tty_lock);
-                               return (EWOULDBLOCK);
+                               return EWOULDBLOCK;
                        }
                        error = ttysleep(tp, &tp->t_cancv, true, 0);
                        mutex_spin_exit(&tty_lock);
-                       if (error)
-                               return (error);
+                       if (error != 0)
+                               return error;
                        goto again;
                }
                while(error == 0 && tp->t_canq.c_cc > 1 && uio->uio_resid > 0) {
@@ -431,11 +431,11 @@
                cc = tp->t_canq.c_cc;
                mutex_spin_exit(&tty_lock);
                if (cc)
-                       return (error);
+                       return error;
        } else if (tp->t_oproc)
                error = (*tp->t_linesw->l_read)(tp, uio, flag);
        ptcwakeup(tp, FWRITE);
-       return (error);
+       return error;
 }
 
 /*
@@ -450,8 +450,8 @@
        struct tty *tp = pti->pt_tty;
 
        if (tp->t_oproc == NULL)
-               return (EIO);
-       return ((*tp->t_linesw->l_write)(tp, uio, flag));
+               return EIO;
+       return (*tp->t_linesw->l_write)(tp, uio, flag);
 }
 
 /*
@@ -464,9 +464,9 @@
        struct tty *tp = pti->pt_tty;
 
        if (tp->t_oproc == NULL)
-               return (POLLHUP);
+               return POLLHUP;
 
-       return ((*tp->t_linesw->l_poll)(tp, events, l));
+       return (*tp->t_linesw->l_poll)(tp, events, l);
 }
 
 /*
@@ -547,7 +547,7 @@
        int ptn = minor(dev);
 
        if ((error = pty_check(ptn)) != 0)
-               return (error);
+               return error;
 
        pti = pt_softc[ptn];
        tp = pti->pt_tty;
@@ -555,7 +555,7 @@
        mutex_spin_enter(&tty_lock);
        if (tp->t_oproc) {
                mutex_spin_exit(&tty_lock);
-               return (EIO);
+               return EIO;
        }
        tp->t_oproc = ptsstart;
        mutex_spin_exit(&tty_lock);
@@ -564,7 +564,7 @@
        pti->pt_flags = 0;
        pti->pt_send = 0;
        pti->pt_ucntl = 0;
-       return (0);
+       return 0;
 }
 
 /*ARGSUSED*/
@@ -579,7 +579,7 @@
        CLR(tp->t_state, TS_CARR_ON);
        tp->t_oproc = NULL;             /* mark closed */
        mutex_spin_exit(&tty_lock);
-       return (0);
+       return 0;
 }
 
 int
@@ -607,8 +607,8 @@
                                pti->pt_send = 0;
                                mutex_spin_exit(&tty_lock);
                                error = ureadc(c, uio);
-                               if (error)
-                                       return (error);
+                               if (error != 0)
+                                       return error;
                                /*
                                 * Since we don't have the tty locked, there's
                                 * a risk of messing up `t_termios'. This is
@@ -621,15 +621,15 @@
                                        uiomove((void *) &tp->t_termios,
                                                cc, uio);
                                }
-                               return (0);
+                               return 0;
                        }
                        if (pti->pt_flags & PF_UCNTL && (c = pti->pt_ucntl)) {
                                pti->pt_ucntl = 0;
                                mutex_spin_exit(&tty_lock);
                                error = ureadc(c, uio);
-                               if (error)
-                                       return (error);
-                               return (0);
+                               if (error != 0)
+                                       return error;
+                               return 0;
                        }
                        if (tp->t_outq.c_cc && !ISSET(tp->t_state, TS_TTSTOP))
                                break;
@@ -643,7 +643,7 @@
                        goto out;
                }
                error = cv_wait_sig(&tp->t_outcvf, &tty_lock);
-               if (error)
+               if (error != 0)
                        goto out;
        }
 
@@ -667,7 +667,7 @@
        ttypull(tp);
 out:
        mutex_spin_exit(&tty_lock);
-       return (error);
+       return error;
 }
 
 
@@ -696,8 +696,8 @@
                                cp = locbuf;
                                mutex_spin_exit(&tty_lock);
                                error = uiomove((void *)cp, cc, uio);
-                               if (error)
-                                       return (error);
+                               if (error != 0)
+                                       return error;
                                mutex_spin_enter(&tty_lock);
                                /* check again for safety */
                                if (!ISSET(tp->t_state, TS_ISOPEN)) {
@@ -726,8 +726,8 @@
                        cp = locbuf;
                        mutex_spin_exit(&tty_lock);
                        error = uiomove((void *)cp, cc, uio);
-                       if (error)
-                               return (error);
+                       if (error != 0)
+                               return error;
                        mutex_spin_enter(&tty_lock);
                        /* check again for safety */
                        if (!ISSET(tp->t_state, TS_ISOPEN)) {
@@ -776,16 +776,16 @@
        }
        error = cv_wait_sig(&tp->t_rawcvf, &tty_lock);
        mutex_spin_exit(&tty_lock);
-       if (error) {
+       if (error != 0) {
                /* adjust for data copied in but not written */
                uio->uio_resid += cc;
-               return (error);
+               return error;
        }
        goto again;
 
 out:
        mutex_spin_exit(&tty_lock);
-       return (error);
+       return error;
 }
 
 int
@@ -826,7 +826,7 @@
 
        mutex_spin_exit(&tty_lock);
 



Home | Main Index | Thread Index | Old Index