From patchwork Fri Aug 4 22:17:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9882183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A6BF602B8 for ; Fri, 4 Aug 2017 22:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E01E288F6 for ; Fri, 4 Aug 2017 22:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42462289A8; Fri, 4 Aug 2017 22:18:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9AFF288F6 for ; Fri, 4 Aug 2017 22:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbdHDWSA (ORCPT ); Fri, 4 Aug 2017 18:18:00 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35751 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751930AbdHDWSA (ORCPT ); Fri, 4 Aug 2017 18:18:00 -0400 Received: by mail-wr0-f196.google.com with SMTP id c24so3788819wra.2 for ; Fri, 04 Aug 2017 15:17:59 -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:in-reply-to:references; bh=WBweLDbuG68/gxhJU4lDgh5psUFfdJW82SS8Hvv/7DI=; b=YGTVwDOect5HAkqxuljygqg33DlwL7YDpnQAX1mCKavQZ49U2MY9QcBvfP2GyQk/JB O45j0k6O4SoRRXEexu/ryeIJd5QQQR30XbOkw1vzQrgzADDqFq65MT++2plL0xly+L97 zhxqXFxBY6dpHyzgMXBWwGlrrmSWjV4p1hxXMp+gKDGWto1w55iuk/VBZXzFnxLVmMu6 aNU7lWf2FGvYXHdgfQYKNpzDWBap+idUpHXBOcgV6jlmGBAG1zuN98zfyQgWSJeZm2i+ cGVFFv+TCCqPLPs4yAya5weqhrDrrqwqg4JeAFb0uMg6Cytlg8PlCuV04F/GattthXmj Kcag== 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:in-reply-to :references; bh=WBweLDbuG68/gxhJU4lDgh5psUFfdJW82SS8Hvv/7DI=; b=E/qsAj/1ff0HcmgsgJjOtM+yRUy46mzlXk8ikmtytdEpWhk4g0yH6IRG8HzE7pfqqP /cKNhn8qUQlElUHodgd4G5HfBwgm0A2CmjOrdlT8mcQc414WSm4xKlSy9wn9dKfVMABM 507ZZYuK3O+WcmB5OjAtl08wM3egCcMWjNP5nyNG5g83X5IbBZMde/J6o5IhXYztowcF 4NodO133keA39Psj3Lk/m1+VKVScz2ITakNV/WTs7+3tOSLW6fwk9zcJfyyP46wQcPzw 7ogXpDQ6H/RA5JUhJJfDoWWk/vC68/6BvWAN2b07LR3WsmDK5szXBlODLukOsYTAOutw JGcQ== X-Gm-Message-State: AIVw110ZX1Gu8gdlcxfIGH8GHPyTuHzYv1/cIiNM4x1czXe6yRCsueI0 fa9O53PU+XuDAw== X-Received: by 10.223.157.4 with SMTP id k4mr3096906wre.270.1501885079015; Fri, 04 Aug 2017 15:17:59 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:40c4:ab00:b1b0:9c82:2611:1575]) by smtp.gmail.com with ESMTPSA id p68sm1987071wmf.0.2017.08.04.15.17.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 15:17:58 -0700 (PDT) From: Luc Van Oostenryck To: Christopher Li Cc: linux-sparse@vger.kernel.org, Luc Van Oostenryck Subject: [PATCH v4 5/5] mark pseudo users as deleted instead of removing them Date: Sat, 5 Aug 2017 00:17:42 +0200 Message-Id: <20170804221742.66665-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170804221742.66665-1-luc.vanoostenryck@gmail.com> References: <20170804221742.66665-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will fix the (rare) problems with deletion while doing nested ptrlist walking that occurs when doing recursive kill_instruction() - remove_usage() - kill_instruction() Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 4 ++-- simplify.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 1839b0f46..78625c8d8 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -162,7 +162,7 @@ static inline void *last_ptr_list(struct ptr_list *list) for (__nr = 0; __nr < __list->nr; __nr++) { \ do { \ ptr = PTR_ENTRY(__list,__nr); \ - if (list->rm && !ptr) \ + if (__list->rm && !ptr) \ continue; \ do { @@ -185,7 +185,7 @@ static inline void *last_ptr_list(struct ptr_list *list) while (--__nr >= 0) { \ do { \ ptr = PTR_ENTRY(__list,__nr); \ - if (list->rm && !ptr) \ + if (__list->rm && !ptr) \ continue; \ do { diff --git a/simplify.c b/simplify.c index 03ff9c942..2bc86f53e 100644 --- a/simplify.c +++ b/simplify.c @@ -172,14 +172,15 @@ static int delete_pseudo_user_list_entry(struct pseudo_user_list **list, pseudo_ FOR_EACH_PTR(*list, pu) { if (pu->userp == entry) { - DELETE_CURRENT_PTR(pu); + MARK_CURRENT_DELETED(pu); if (!--count) goto out; } } END_FOR_EACH_PTR(pu); assert(count <= 0); out: - pack_ptr_list((struct ptr_list **)list); + if (ptr_list_size((struct ptr_list *) *list) == 0) + *list = NULL; return count; }