From owner-p4-projects@FreeBSD.ORG Mon Jul 19 01:51:15 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A19E51065677; Mon, 19 Jul 2010 01:51:15 +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 62F891065670; Mon, 19 Jul 2010 01:51:15 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 14C698FC14; Mon, 19 Jul 2010 01:51:14 +0000 (UTC) Received: by iwn35 with SMTP id 35so5145844iwn.13 for ; Sun, 18 Jul 2010 18:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=uumzITBwiTlt+L1naHQby3QVGe4mo58zuzpm9s0yuZc=; b=NvfbK0KI+mZn/KKbSd6zrqy3+jBQV3FHxxtYM69u7ehwj8GUIwSXu1MT+BW1mf/GfD WTqoWKxsPp+uXoHxxpZMrAXdWnbvJA5X/OTT7+eP8/nQlgNMnGnRuwqqR1u4kqepKyIK h2G0JZRIUDMINA48cco7ly7hCWJAJjRf04JiU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=YMRzsx+eh6U0GCOwvl9qq5E4wnJNwaGY5nHbcqjbyHI6yMRWTgKCLMGeg0loXrd1eZ TsBSOZLjNVXrV0p8B42IX8a1SeBaeD59Bi0vIklFpkSsyGk+C+snlitq49MZEpJmt5Pf bRqr0mMFrvRMgL//FL4bSzAiMhEPMvdvCWlgU= MIME-Version: 1.0 Received: by 10.231.174.66 with SMTP id s2mr4367717ibz.11.1279504274158; Sun, 18 Jul 2010 18:51:14 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.169.18 with HTTP; Sun, 18 Jul 2010 18:51:14 -0700 (PDT) In-Reply-To: References: <201007182159.o6ILxBSq023260@repoman.freebsd.org> Date: Sun, 18 Jul 2010 18:51:14 -0700 X-Google-Sender-Auth: 12LAq8r8hZaA0JasRLSSYBHQ2GU Message-ID: From: Garrett Cooper To: Julien LAFFAYE Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Perforce Change Reviews Subject: Re: PERFORCE change 181154 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2010 01:51:16 -0000 On Sun, Jul 18, 2010 at 4:45 PM, Julien LAFFAYE wrot= e: > On Mon, Jul 19, 2010 at 1:34 AM, Garrett Cooper wro= te: >> >> 1. Some other things: >> >> In add/extract.c: >> >> =A0 =A0 =A0 =A0 =A0 =A0for (p =3D pkg.head; p !=3D NULL; p =3D p->next) = { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (p->type =3D=3D PLIST_CONFLICTS) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int i; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0conflict[0] =3D strdup(p->name); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0conflict[1] =3D NULL; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0matched =3D matchinstalled(MATCH_= GLOB, conflict, &errcode); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0free(conflict[0]); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (errcode =3D=3D 0 && matched != =3D NULL) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (i =3D 0; matched[i] = !=3D NULL; i++) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (isinstalledpk= g(matched[i]) > 0) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0warnx("pa= ckage '%s' conflicts with %s", >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0pkg.name, matched[i]); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0conflicts= found =3D 1; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> >> The continue is useless. >> >> 2. These sprintfs have negative value: >> >> =A0 =A0 =A0 =A0 =A0 =A0if (fexists(INSTALL_FNAME)) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sprintf(post_script, "%s", INSTALL_FNAME)= ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sprintf(pre_arg, "PRE-INSTALL"); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sprintf(post_arg, "POST-INSTALL"); >> =A0 =A0 =A0 =A0 =A0 =A0} >> >> The last two sprintfs could be implemented with strlcpy (and >> technically I thought that using sprintf without format strings was >> stylistically illegal). I don't see why the first one needs to be >> implemented as a sprintf as it's not user-provided (most of the time >> that's done to avoid security issues with buffer overruns in the >> str*cat family, IIRC). > > But, but, but! I'm not the original author of this code ;p > I'll fix that. I know... the majority of the code can be blamed on other folks :) (including your's truly). >> 3. style(9): >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!Fake && chdir(p->name) =3D=3D -1) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0warn("chdir(%s)", p->name); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return 1; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > You mean the lack of () for return ? Yup. >> 4. You're leaking the archive objects in many spots by not handling >> this at function exit: >> >> =A0 =A0 =A0 =A0archive_read_finish(a); >> =A0 =A0 =A0 =A0free_plist(&pkg); >> >> =A0 =A0Even though I don't like suggesting this (globals are nasty... >> ew), maybe the archive object itself should become a global *just in >> pkg_add* visible from only perform.c, essentially passed via pointer >> to extract.c, and be handled in the cleanup function in perform.c, so >> that it gets mopped up when atexit(3) is called. It's a thought I've >> briefly entertained right now... > > That is basically what is planned, except the global part. > When I'm done (the commit was basically a "snapshot" of the WIP, it's > not usable), extract_package will take a struct archive * and Package > * as arguments. > Both will be created/free'ed in pkg_do(). Ok, good to hear then. Just trying to help out with an extra pair of eyes. -Garrett