From patchwork Mon Mar 9 18:22:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Jakubiak X-Patchwork-Id: 1552 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id C3ACE17859783 for ; Mon, 9 Mar 2020 18:23:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED=0.001, DKIM_INVALID=1,DKIM_SIGNED=0.1,FREEMAIL_FROM=0.5,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01, T_DMARC_SIMPLE_DKIM=0.01 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 9 Mar 2020 18:23:13 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id D429519DFAA6B3; Mon, 9 Mar 2020 18:23:12 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id 8D24319DFAA6AF; Mon, 9 Mar 2020 18:23:12 +0000 (UTC) Authentication-Results: orion.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X37Wf+ga Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 7A7362A8F3; Mon, 9 Mar 2020 18:23:12 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X37Wf+ga Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id AB4082A8F2 for ; Mon, 9 Mar 2020 18:23:08 +0000 (UTC) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 9 Mar 2020 18:23:08 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id m9so3493454wro.12 for ; Mon, 09 Mar 2020 11:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y8JUxBAz2lx4g7kGXfvElwdtNFwiR6kaMFMqj7nfUq8=; b=X37Wf+gaQxKd+MtMJ6lpx32oO5gkFtBPHVFfRUt02NG0Q1qYa0+U4GMnbayAFYCoDP XysHAPuyQPOwH6TQhME9wDbzDSPU0bHy31CqnSdAwNWXL+7wkUB1gJHLeM/WgQPMeZy8 Yvwz3pxZAPZ961tdAPKtpR+vLr3egARUUQNCgRaDjsVgvjCnqhmNVVZwHu2gl+56FLNY 0PjoGopiuYKMKK6MjmO4kuuEWMBWopwmW5iUjjfw6ZEBoh8JpFnqqmF0Vycot+gNibw8 Wfj/RSgistV7+cWqLRAzZez3DuHIPTmI0IcJrhblViuTvDW4pafzuQRgw0vgP1DexGxQ 8Rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y8JUxBAz2lx4g7kGXfvElwdtNFwiR6kaMFMqj7nfUq8=; b=qUN8d2HAr45TdNT7UKIKGSWzmEKQVNDXuZi/WNMInedmVijdfEnkS+LJiSZxmMwGwV m9WXb2jJETirN60szMk9RIlwLnAlx5EDi+IsEYfZoGejl0NzryYse0tIwYX8oXaIuGux YOBWZwG94FEVq3uagZsk0NpdllCqHy9VOcOd+k4ZkzPPxlcqN9bsbo0Tp61cceC3B6NX jrNGmIxC2gdNxylR6OqqCQJ/wGqKI6/MWVmIyUuz1HGLVcemiBR4j0XcEPTHfAkmoaGB SGRIgmi0okyAfDCJ43HsOjB5rMkJ3oR50CTQcydlXErLY/JyXEC4Jq9FdaY7PlOW/xeX 28hQ== X-Gm-Message-State: ANhLgQ3AIXSpnGejbiKEZFQhjO9mnGhugJiMa0FlsLZiMthzRDNZjDfF MHUBMl+bKqmAsKENPk/J6D86BSYBnd4= X-Google-Smtp-Source: ADFU+vvIlvKHxSm5g8PDXb98SxYYpn0pmGOrSROcWLb0APkaF3O8XsxQs7GIOrtUV4T6JvzqJ3eNUQ== X-Received: by 2002:a5d:5488:: with SMTP id h8mr12254471wrv.387.1583778187777; Mon, 09 Mar 2020 11:23:07 -0700 (PDT) Received: from localhost ([89.39.107.201]) by smtp.gmail.com with ESMTPSA id u1sm43626988wrt.78.2020.03.09.11.23.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Mar 2020 11:23:07 -0700 (PDT) From: Sebastian Jakubiak To: pacman-contrib@lists.archlinux.org Subject: [PATCH] pactree: Fix redundant arrows in Graphviz output Date: Mon, 9 Mar 2020 19:22:06 +0100 Message-Id: <20200309182205.17889-1-jakseb.dev@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Fix an issue where a dependency and a package providing it were connected more than once in --graph output. The code supposed to prevent that did not always work due to using dangling pointers. Signed-off-by: Sebastian Jakubiak --- This is how one can find a package to reproduce the bug: for pkg in `pacman -Qq`; do pactree -g $pkg | sort | uniq -c | awk '$1 != 1' | grep '' && { echo $pkg; break; } done Originally, I wanted to check if the value returned by strdup() is not null, but the existing code (line 217) does not do that, so I don't either. src/pactree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pactree.c b/src/pactree.c index 9f074fe..cf83326 100644 --- a/src/pactree.c +++ b/src/pactree.c @@ -232,7 +232,7 @@ static int register_syncs(void) static void cleanup(int ret) { alpm_list_free(walked); - alpm_list_free(provisions); + FREELIST(provisions); alpm_release(handle); exit(ret); @@ -412,7 +412,7 @@ static void print_graph(const char *parentname, const char *pkgname, const char printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, depname); if(pkgname && strcmp(depname, pkgname) != 0 && !alpm_list_find_str(provisions, depname)) { printf("\"%s\" -> \"%s\" [arrowhead=none, color=grey];\n", depname, pkgname); - provisions = alpm_list_add(provisions, (char *)depname); + provisions = alpm_list_add(provisions, strdup(depname)); } } else if(pkgname) { printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, pkgname);