Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Apr 2009 16:03:28 +0000 (UTC)
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r190694 - head/usr.sbin/jexec
Message-ID:  <200904041603.n34G3Sfp075321@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ru
Date: Sat Apr  4 16:03:28 2009
New Revision: 190694
URL: http://svn.freebsd.org/changeset/base/190694

Log:
  - Style: size_t can't be negative.
  
  - Don't exit with a zero status code when no jails are configured
    on a system.
  
  - Style: simplify some code constructs.
  
  - If a single jail cannot be found, let the caller print a nicer
    diagnostic message.
  
  Reviewed by:	bz
  MFC after:	3 days

Modified:
  head/usr.sbin/jexec/jexec.c

Modified: head/usr.sbin/jexec/jexec.c
==============================================================================
--- head/usr.sbin/jexec/jexec.c	Sat Apr  4 15:48:09 2009	(r190693)
+++ head/usr.sbin/jexec/jexec.c	Sat Apr  4 16:03:28 2009	(r190694)
@@ -119,8 +119,8 @@ lookup_jail(int jid, char *jailname)
 
 	j = len;
 	for (i = 0; i < 4; i++) {
-		if (len <= 0)
-			exit(0);	
+		if (len == 0)
+			return (-1);
 		p = q = malloc(len);
 		if (p == NULL)
 			err(1, "malloc()");
@@ -174,27 +174,21 @@ lookup_jail(int jid, char *jailname)
 			/* NOTREACHED */
 			break;
 		}
-		/* Possible match. */
-		if (id > 0) {
-			/* Do we have a jail ID to match as well? */
-			if (jid > 0) {
-				if (jid == id) {
-					xid = id;
-					count++;
-				}
-			} else {
-				xid = id;
-				count++;
-			}
+		/* Possible match; see if we have a jail ID to match as well.  */
+		if (id > 0 && (jid <= 0 || id == jid)) {
+			xid = id;
+			count++;
 		}
 	}
 
 	free(p);
 
-	if (count != 1)
+	if (count == 1)
+		return (xid);
+	else if (count > 1)
 		errx(1, "Could not uniquely identify the jail.");
-
-	return (xid);
+	else
+		return (-1);
 }
 
 #define GET_USER_INFO do {						\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904041603.n34G3Sfp075321>