Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 May 2010 01:38:37 GMT
From:      Garrett Cooper <gcooper@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 178993 for review
Message-ID:  <201005310138.o4V1cb5A055112@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@178993?ac=10

Change 178993 by gcooper@gcooper-bayonetta on 2010/05/31 01:38:26

	Chase @178992 by properly checking the return codes from add_plist*.

Affected files ...

.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/perform.c#16 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/perform.c#30 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/perform.c#10 edit

Differences ...

==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/perform.c#16 (text+ko) ====

@@ -236,7 +236,8 @@
      */
     if (Prefix) {
 	delete_plist(&Plist, FALSE, PLIST_CWD, NULL);
-	add_plist_top(&Plist, PLIST_CWD, Prefix);
+	if (add_plist_top(&Plist, PLIST_CWD, Prefix) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
     }
 
     setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : ".", 1);

==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/perform.c#30 (text+ko) ====

@@ -172,7 +172,7 @@
 	    deps = alloca(sizeof(*deps) * ndeps + 1);
 	    if (deps == NULL)
 		errx(2, "%s: alloca() failed", __func__);
-	    for (i = 0; Pkgdeps;) {
+	    for (i = 0; Pkgdeps; ) {
 		cp = strsep(&Pkgdeps, " \t\n");
 		if (*cp) {
 		    deps[i] = cp;
@@ -187,9 +187,12 @@
 		deporigin = strchr(deps[i], ':');
 		if (deporigin != NULL) {
 		    *deporigin = '\0';
-		    add_plist_top(&plist, PLIST_DEPORIGIN, ++deporigin);
+		    if (add_plist_top(&plist, PLIST_DEPORIGIN, ++deporigin) ==
+			-1)
+			err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
 		}
-		add_plist_top(&plist, PLIST_PKGDEP, deps[i]);
+		if (add_plist_top(&plist, PLIST_PKGDEP, deps[i]) == -1)
+		    err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
 		if (Verbose && !PlistOnly)
 		    printf(" %s", deps[i]);
 	    }
@@ -206,7 +209,8 @@
 	while (Conflicts) {
 	   cp = strsep(&Conflicts, " \t\n");
 	   if (*cp) {
-		add_plist(&plist, PLIST_CONFLICTS, cp);
+		if (add_plist(&plist, PLIST_CONFLICTS, cp) == -1)
+		    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 		if (Verbose && !PlistOnly)
 		    printf(" %s", cp);
 	   }
@@ -219,7 +223,8 @@
     if (SrcDir) {
 	if (Verbose && !PlistOnly)
 	    printf("Using SrcDir value of %s\n", SrcDir);
-	add_plist(&plist, PLIST_SRC, SrcDir);
+	if (add_plist(&plist, PLIST_SRC, SrcDir) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
     }
 
     /* Slurp in the packing list */
@@ -230,25 +235,28 @@
 
     /* Prefix should add an @cwd to the packing list */
     if (Prefix)
-	add_plist_top(&plist, PLIST_CWD, Prefix);
+	if (add_plist_top(&plist, PLIST_CWD, Prefix) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
 
-
     /* Add the origin if asked, at the top */
     if (Origin)
-	add_plist_top(&plist, PLIST_ORIGIN, Origin);
+	if (add_plist_top(&plist, PLIST_ORIGIN, Origin) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
 
     /*
      * Run down the list and see if we've named it, if not stick in a name
      * at the top.
      */
     if (find_plist(&plist, PLIST_NAME) == NULL)
-	add_plist_top(&plist, PLIST_NAME, basename(pkg));
+	if (add_plist_top(&plist, PLIST_NAME, basename(pkg)) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
 
     if (asprintf(&cp, "PKG_FORMAT_REVISION:%d.%d", PLIST_FMT_VER_MAJOR,
 		 PLIST_FMT_VER_MINOR) == -1) {
 	errx(2, "%s: asprintf() failed", __func__);
     }
-    add_plist_top(&plist, PLIST_COMMENT, cp);
+    if (add_plist_top(&plist, PLIST_COMMENT, cp) == -1)
+	err(EXIT_FAILURE, "%s: add_plist_top failed", __func__);
     free(cp);
 
     /*
@@ -275,57 +283,78 @@
 
     /* Now put the release specific items in */
     if (Prefix == NULL)
-	add_plist(&plist, PLIST_CWD, ".");
+	if (add_plist(&plist, PLIST_CWD, ".") == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 
     if (write_file(COMMENT_FNAME, Comment) == 0) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, COMMENT_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, COMMENT_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, COMMENT_FNAME);
     } else
 	err(EXIT_FAILURE, "failed to write comment file");
     if (write_file(DESC_FNAME, Desc) == 0) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, DESC_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, DESC_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, DESC_FNAME);
     } else
 	err(EXIT_FAILURE, "failed to write description file");
 
     if (Install != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, INSTALL_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, INSTALL_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, INSTALL_FNAME);
     }
     if (PostInstall != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, POST_INSTALL_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, POST_INSTALL_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, POST_INSTALL_FNAME);
     }
     if (DeInstall != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, DEINSTALL_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, DEINSTALL_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, DEINSTALL_FNAME);
     }
     if (PostDeInstall != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, POST_DEINSTALL_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, POST_DEINSTALL_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, POST_DEINSTALL_FNAME);
     }
     if (Require != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, REQUIRE_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, REQUIRE_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, REQUIRE_FNAME);
     }
     if (Display != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, DISPLAY_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, DISPLAY_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, DISPLAY_FNAME);
-	add_plist(&plist, PLIST_DISPLAY, DISPLAY_FNAME);
+	if (add_plist(&plist, PLIST_DISPLAY, DISPLAY_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
     }
     if (Mtree != NULL) {
-	add_plist(&plist, PLIST_IGNORE, NULL);
-	add_plist(&plist, PLIST_FILE, MTREE_FNAME);
+	if (add_plist(&plist, PLIST_IGNORE, NULL) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
+	if (add_plist(&plist, PLIST_FILE, MTREE_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
 	add_cksum(&plist, plist.tail, MTREE_FNAME);
-	add_plist(&plist, PLIST_MTREE, MTREE_FNAME);
+	if (add_plist(&plist, PLIST_MTREE, MTREE_FNAME) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
     }
 
     /* Finally, write out the packing list */

==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/perform.c#10 (text+ko) ====

@@ -213,7 +213,8 @@
 
     /* If we have a prefix, add it now */
     if (Prefix)
-	add_plist(&Plist, PLIST_CWD, Prefix);
+	if (add_plist(&Plist, PLIST_CWD, Prefix) == -1)
+	    err(EXIT_FAILURE, "%s: add_plist failed", __func__);
     rc = read_plist(&Plist, cfile);
     serrno = errno;
     (void) close(cfile);



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