Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Use KASSERT() instead of #ifdef(DIAGNOSTIC). Clearer.



details:   https://anonhg.NetBSD.org/src/rev/e156d549eb67
branches:  trunk
changeset: 330126:e156d549eb67
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Jun 23 18:06:32 2014 +0000

description:
Use KASSERT() instead of #ifdef(DIAGNOSTIC). Clearer.

diffstat:

 sys/kern/exec_script.c |  16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diffs (45 lines):

diff -r c51f9ffb9e0a -r e156d549eb67 sys/kern/exec_script.c
--- a/sys/kern/exec_script.c    Mon Jun 23 17:44:31 2014 +0000
+++ b/sys/kern/exec_script.c    Mon Jun 23 18:06:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_script.c,v 1.70 2014/03/07 01:34:29 christos Exp $        */
+/*     $NetBSD: exec_script.c,v 1.71 2014/06/23 18:06:32 maxv Exp $    */
 
 /*
  * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.70 2014/03/07 01:34:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.71 2014/06/23 18:06:32 maxv Exp $");
 
 #if defined(SETUIDSCRIPTS) && !defined(FDSCRIPTS)
 #define FDSCRIPTS              /* Need this for safe set-id scripts. */
@@ -222,10 +222,7 @@
            ) {
                struct file *fp;
 
-#if defined(DIAGNOSTIC) && defined(FDSCRIPTS)
-               if (epp->ep_flags & EXEC_HASFD)
-                       panic("exec_script_makecmds: epp already has a fd");
-#endif
+               KASSERT(!(epp->ep_flags & EXEC_HASFD));
 
                if ((error = fd_allocfile(&fp, &epp->ep_fd)) != 0) {
                        scriptvp = NULL;
@@ -262,12 +259,9 @@
 #endif
                /* normally can't fail, but check for it if diagnostic */
                error = copystr(epp->ep_kname, tmpsap->fa_arg, MAXPATHLEN,
-                   (size_t *)0);
+                   NULL);
+               KASSERT(error == 0);
                tmpsap++;
-#ifdef DIAGNOSTIC
-               if (error != 0)
-                       panic("exec_script: copystr couldn't fail");
-#endif
 #ifdef FDSCRIPTS
        } else {
                snprintf(tmpsap->fa_arg, MAXPATHLEN, "/dev/fd/%d", epp->ep_fd);



Home | Main Index | Thread Index | Old Index