From owner-p4-projects@FreeBSD.ORG Mon May 31 01:24:22 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 48C161065676; Mon, 31 May 2010 01:24:22 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D516106566B for ; Mon, 31 May 2010 01:24:22 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (unknown [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D451C8FC08 for ; Mon, 31 May 2010 01:24:21 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o4V1OLvY054017 for ; Mon, 31 May 2010 01:24:21 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o4V1OL6W054015 for perforce@freebsd.org; Mon, 31 May 2010 01:24:21 GMT (envelope-from gcooper@FreeBSD.org) Date: Mon, 31 May 2010 01:24:21 GMT Message-Id: <201005310124.o4V1OL6W054015@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 178992 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 May 2010 01:24:22 -0000 http://p4web.freebsd.org/@@178992?ac=10 Change 178992 by gcooper@gcooper-bayonetta on 2010/05/31 01:23:45 Actually, instead of just adding useless warnings, let's fix the add_plist* APIs to use proper return codes when new_plist_entry fails. Affected files ... .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#12 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/plist.c#10 edit Differences ... ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#12 (text+ko) ==== @@ -193,8 +193,8 @@ void free_plist(Package *); void mark_plist(Package *); void csum_plist_entry(char *, PackingList); -void add_plist(Package *, plist_t, const char *); -void add_plist_top(Package *, plist_t, const char *); +int add_plist(Package *, plist_t, const char *); +int add_plist_top(Package *, plist_t, const char *); void delete_plist(Package *pkg, Boolean all, plist_t type, const char *name); int write_plist(Package *, FILE *); ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/plist.c#10 (text+ko) ==== @@ -35,19 +35,22 @@ #include "pkg.h" /* - * Add an item to a packing list + * Add an item to the tail of a packing list. * - * FIXME: this will `silently fail' until the next point when p is - * dereferenced. + * Returns 0 on success, -1 on failure (errno will be set appropriate to + * errors with malloc(3)). */ -void +int add_plist(Package *p, plist_t type, const char *arg) { PackingList tmp; + int retcode = 0; tmp = new_plist_entry(); - if (tmp != NULL) { + if (tmp == NULL) + retcode = -1; + else tmp->name = copy_string(arg); tmp->type = type; @@ -74,20 +77,27 @@ } + return retcode; + } /* - * FIXME: this will `silently fail' until the next point when p is - * dereferenced. + * Add an element to the top of the plist. + * + * Returns 0 on success, -1 on failure (errno will be set appropriate to + * errors with malloc(3)). */ -void +int add_plist_top(Package *p, plist_t type, const char *arg) { PackingList tmp; + int retcode = 0; tmp = new_plist_entry(); - if (tmp != NULL) { + if (tmp == NULL) + retcode = -1; + else tmp->name = copy_string(arg); tmp->type = type; @@ -102,6 +112,8 @@ } + return retcode; + } /* Return the last (most recent) entry in a packing list */ @@ -436,11 +448,19 @@ */ if (retcode == 0) { - add_plist(pkg, cmd, cp); - start = end; - /* We aren't at the end of the line, yet.. */ - if (start != '\0') - start++; + if (add_plist(pkg, cmd, cp) == -1) + retcode = -1; + else { + + start = end; + /* + * We aren't at the end of the line, + * yet.. + */ + if (start != '\0') + start++; + + } }