From patchwork Sat Mar 6 10:05:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A48BEC433E0 for ; Sat, 6 Mar 2021 10:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DFCC6501B for ; Sat, 6 Mar 2021 10:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbhCFKGA (ORCPT ); Sat, 6 Mar 2021 05:06:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbhCFKF7 (ORCPT ); Sat, 6 Mar 2021 05:05:59 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC359C061760 for ; Sat, 6 Mar 2021 02:05:58 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id r17so8697659ejy.13 for ; Sat, 06 Mar 2021 02:05:58 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=yJUErk6FrLpmdmFAUynssTvYnXkf3kxFQ/e396/koRU=; b=lHzLlsPVYc10GGnjdIw7nn9JHjIoOyFgt3M0mhXP7b/JMz0/EB1vgtlfoluy719jF6 eRjAw47tm6HrYv7vGqI9nYGr8dN9fj4FVvsdn1j0ZTS6Vv0KBHeVqMAhURI06XR+cg0y E0N63Qb+ePFCGSVeLJ8DouxvBobo4QzcB85aCRrjFHfXtgaXPHbKjCB8+bSMrSWzS6zC 5KE6Qs4OeHLAp/sOaEY3FxM1tx9gP4/SMXerQb5tqg/EOvUFZYWU968GpN23zT7Xp8hy /iAzfXERJHaClZKiwIKLOAD6npPVcSFqedwtJXa75BOEak6y4EhIHJyzs5MN1utXz4g9 MHUg== 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:mime-version:content-transfer-encoding; bh=yJUErk6FrLpmdmFAUynssTvYnXkf3kxFQ/e396/koRU=; b=nOVkTSjfZElaFPTI/nl/cjhkNLZqq0eFZ+j8g3Vryq/AsJ+kY8R5T3SNqEqjy3lS8W MCgMByi2v97FXpTHdseb6EmJbFSZjmYIpwxA1AcZIiLNDlr4n4lAbKuN0tL+rczcaql6 TGmtyoc5nXrCC+h1Qd1CAjdedrkevWVbsiEEEqvEin/is5xxWLQNnpjqNPpzq37z0NAF mrfm2wfvUGl5TNN92UZH8KTFL8s+Vq4l27Wc1oFZA5mEdhKCgHgYOjUnJkZzAizgjing vfEB0LyQOy9S9N3Pv+G/ik4hUnHc6Jmw+1ledGZ+B/v0rglw3bhH3yYy7Ed7uNAtu5aa isUQ== X-Gm-Message-State: AOAM531t91TISjR08f4KVRzlDVSu8TXESsfXSL9XZAMzhs3/vrrIDCp0 F/mXTBSgp0shi7JKygrz5Ad5C5SWyqM= X-Google-Smtp-Source: ABdhPJx6BYfB+JxUJz/S/TUnvCl2fHIFHVsaT0nAlDsKOfK62eDVLNaXC/FmKbFQ/VoOEh5CGbaSEg== X-Received: by 2002:a17:907:7692:: with SMTP id jv18mr6309989ejc.475.1615025157759; Sat, 06 Mar 2021 02:05:57 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:05:57 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/6] ptrlist: ~fix TYPEOF() Date: Sat, 6 Mar 2021 11:05:47 +0100 Message-Id: <20210306100552.33784-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The macro TYPEOF() return the type of the addresses of the pointers stored in the list. That's one level too much in general. Change it to simply return the type of the stored pointers. Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index c5fa4cdd94cb..41d9011c8716 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -12,7 +12,7 @@ /* Silly type-safety check ;) */ #define CHECK_TYPE(head,ptr) (void)(&(ptr) == &(head)->list[0]) -#define TYPEOF(head) __typeof__(&(head)->list[0]) +#define TYPEOF(head) __typeof__((head)->list[0]) #define VRFY_PTR_LIST(head) (void)(sizeof((head)->list[0])) #define LIST_NODE_NR (13) @@ -251,7 +251,7 @@ extern void __free_ptr_list(struct ptr_list **); extern void split_ptr_list_head(struct ptr_list *); #define DO_INSERT_CURRENT(new, __head, __list, __nr) do { \ - TYPEOF(__head) __this, __last; \ + TYPEOF(__head) *__this, *__last; \ if (__list->nr == LIST_NODE_NR) { \ split_ptr_list_head((struct ptr_list*)__list); \ if (__nr >= __list->nr) { \ @@ -270,8 +270,8 @@ extern void split_ptr_list_head(struct ptr_list *); } while (0) #define DO_DELETE_CURRENT(__head, __list, __nr) do { \ - TYPEOF(__head) __this = __list->list + __nr; \ - TYPEOF(__head) __last = __list->list + __list->nr - 1; \ + TYPEOF(__head) *__this = __list->list + __nr; \ + TYPEOF(__head) *__last = __list->list + __list->nr - 1; \ while (__this < __last) { \ __this[0] = __this[1]; \ __this++; \ From patchwork Sat Mar 6 10:05:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5BFEC433E9 for ; Sat, 6 Mar 2021 10:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D82A64E01 for ; Sat, 6 Mar 2021 10:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbhCFKGB (ORCPT ); Sat, 6 Mar 2021 05:06:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhCFKGA (ORCPT ); Sat, 6 Mar 2021 05:06:00 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB36BC06175F for ; Sat, 6 Mar 2021 02:05:59 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id r17so8697691ejy.13 for ; Sat, 06 Mar 2021 02:05:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=qX3SBZ21v82TcVuRdPFXeNxVl38j3X/+7mvmbmRuvxs=; b=hrRg7K6+cag4yc/vC5rTENt1wyP7dmZEzmMLjYltGeBZOKqF8il7El1lMJi2BCFEw0 s5x6wBnwq/QpMJ6lhSkV3oXNaAfmGbyyRYMHbNk92yoBgNwsm6X86i3iwDoSfRrNxPOV 8Wrq7d0tGPPIwsYBSQEa50TKY2q/gfNvOpaivZG7GHLq2CFCZTLSaqOfe6oc8ipvRZjD pVOitGGK4pjAe019YuUuo/LY1XBLq/jq3PzLMeA9Rh4xz+PoDZj1NqhhX6SEPHH3+aLH 4+61Pvy/BnRGkSYQP8Di/vtbrlle1ozH5DN0PkfLmz0nHaS54HtrYYCjXO47uV/UdPjm M0LQ== 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:mime-version:content-transfer-encoding; bh=qX3SBZ21v82TcVuRdPFXeNxVl38j3X/+7mvmbmRuvxs=; b=ERR0zgtqDxWOuhFNQ05phNPXsmlud+tCRtAwqeZgPkjDx/8Qwb6BUZRWNjBwlf0iUx d9qkAhFORnkILlHaPwTlHebYlJ0nIAdhBF7dfGllWo0g+aHeCwv2+UwPYDLDLIc2oplR /Dakt0HwW+5bLhfXZSscZ1BzOiVDV4GOQoRLlLbWZL9tRzWlCPahqcjOtOci+c7/Qre/ 0SzUYPKDD2XIYqTWJSzzOfa90kHI+3XVk9tEQQbrvo9RS7EUfaSddUktBsoLSzpU7j00 QhVY2wytT1OpE7kyitgXlMUoglqS2nqBkgLoT3fGm5ntVCS5bZXCVQGtqBMpJz2G6lkK RJQw== X-Gm-Message-State: AOAM5339LOTqh2dK1WIQ5wzhPkvjPubF/SrMrqs2Co8rn+nEAHpWaVPY MGHRkA39cayuFUunNSXsB/7UscOxE2E= X-Google-Smtp-Source: ABdhPJxLrzrnrtt0xwccZs8EfTRie2cMHok6I9kK1+FHKKJXDSMu6+vrYKWhR7F2FP6baafkAd3+SQ== X-Received: by 2002:a17:907:7637:: with SMTP id jy23mr5523630ejc.12.1615025158525; Sat, 06 Mar 2021 02:05:58 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:05:58 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/6] ptrlist: change TYPEOF() into PTRLIST_TYPE() Date: Sat, 6 Mar 2021 11:05:48 +0100 Message-Id: <20210306100552.33784-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The name of the macro TYPEOF() is too generic and doesn't explain that it only returns the type of the pointers stored in ptrlists. So, change he name to something more explicit: PTRLIST_TYPE(). Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 41d9011c8716..3b952097545f 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -12,7 +12,7 @@ /* Silly type-safety check ;) */ #define CHECK_TYPE(head,ptr) (void)(&(ptr) == &(head)->list[0]) -#define TYPEOF(head) __typeof__((head)->list[0]) +#define PTRLIST_TYPE(head) __typeof__((head)->list[0]) #define VRFY_PTR_LIST(head) (void)(sizeof((head)->list[0])) #define LIST_NODE_NR (13) @@ -75,7 +75,7 @@ extern void __free_ptr_list(struct ptr_list **); #define ptr_list_nth(lst, nth) ({ \ struct ptr_list* head = (struct ptr_list*)(lst); \ - (__typeof__((lst)->list[0])) ptr_list_nth_entry(head, nth);\ + (PTRLIST_TYPE(lst)) ptr_list_nth_entry(head, nth);\ }) //////////////////////////////////////////////////////////////////////// @@ -251,7 +251,7 @@ extern void __free_ptr_list(struct ptr_list **); extern void split_ptr_list_head(struct ptr_list *); #define DO_INSERT_CURRENT(new, __head, __list, __nr) do { \ - TYPEOF(__head) *__this, *__last; \ + PTRLIST_TYPE(__head) *__this, *__last; \ if (__list->nr == LIST_NODE_NR) { \ split_ptr_list_head((struct ptr_list*)__list); \ if (__nr >= __list->nr) { \ @@ -270,8 +270,8 @@ extern void split_ptr_list_head(struct ptr_list *); } while (0) #define DO_DELETE_CURRENT(__head, __list, __nr) do { \ - TYPEOF(__head) *__this = __list->list + __nr; \ - TYPEOF(__head) *__last = __list->list + __list->nr - 1; \ + PTRLIST_TYPE(__head) *__this = __list->list + __nr; \ + PTRLIST_TYPE(__head) *__last = __list->list + __list->nr - 1; \ while (__this < __last) { \ __this[0] = __this[1]; \ __this++; \ From patchwork Sat Mar 6 10:05:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8290DC433E0 for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5117D64E01 for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbhCFKGd (ORCPT ); Sat, 6 Mar 2021 05:06:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhCFKGA (ORCPT ); Sat, 6 Mar 2021 05:06:00 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC33C06175F for ; Sat, 6 Mar 2021 02:06:00 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id mj10so8744652ejb.5 for ; Sat, 06 Mar 2021 02:06:00 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Ge3vb5YfD0avE42hELPXbN0GITFSnH5aipvTP7ovtuM=; b=GvW+MO/NvPpq/QBobwTPmGgETY3+ahH5wbBGAzECn+bJSJJXO2y71OaKldUmVko0Nu AcEhKddfhuJJHtbrTTLyEkOXkkR2cO3eAPVYzpm/FSTSfHQrrxQs1Rwx0pdZDqtwxDvw We/3Zhfp2A2JnfRwXznAJwSWAw8ggWUs/onnqU4pVlhHVjpxp0XViRcu4L3Bn+ibcuy5 p2quwI1ThkxGY/Jbk5iYz6aWleqU0hCk0mEMB7+Pwh+3uqHJ+YYmzszW15IytvcTIwTy PaZ/zwtASAw3hl6III0fr7kE8WtW9QhOFuwjSVeU/AHxoNw58MVA6KIfY/Ec9XxGN4u0 AuEg== 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:mime-version:content-transfer-encoding; bh=Ge3vb5YfD0avE42hELPXbN0GITFSnH5aipvTP7ovtuM=; b=EehLjO78TCBIbGChHbtau4ublre1dwNDIPOSTg4+eTHmOPg9FlHZdPrhd6LAHgRzs9 TFM2TVY8PWQ5wAe2EWRLz50ge3Ycz9fpRXxy/Yc4do41kwvNn0JxIv8SMjWv09nBV9b9 bpz1GE2fZHX2QeIDSNJwdSqhBc6c3hlZZutnV57S60Oa7z9VdITeemwkjuY3ECiHGDbu fClC9addgJRSAUx5ehVTILD1y0Y1Lm3TcvQWLtg8xYUIsHfWEgHuVJCRBkFC9ULqxwgl JI4hwuKa4ILfahMHGTzZdcHa9/81vtdC24d45lIy+IbX8gL9uIY4lHhASLXf4COKeTg9 oNTw== X-Gm-Message-State: AOAM533B9eHbHtsr/v/vUJdw15jM8h+eovBD3E9ifp/9i+OGSX0fOBdh ztwDz0zINbctKeKLaWyEpfFP7f3pRMw= X-Google-Smtp-Source: ABdhPJygP3NeMmC2Mc/+uP9pRX8x7w1XaeEgs5zTAcwxeIYIsmKpVSMS/8V9g+X14rrJObJwU3RL3Q== X-Received: by 2002:a17:906:d8c6:: with SMTP id re6mr6018516ejb.311.1615025159100; Sat, 06 Mar 2021 02:05:59 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:05:58 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/6] ptrlist: add pop_ptr_list() Date: Sat, 6 Mar 2021 11:05:49 +0100 Message-Id: <20210306100552.33784-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Some algorithms need with a stack or a working list from which the last element can be removed. The ptrlist API has a function to do this but it's not typed and thus needs a wrapper for each type it's used for. Simplify this by adding a generic (but type-safe) macro for this while also giving it a nicer name: pop_ptr_list(). Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ptrlist.h b/ptrlist.h index 3b952097545f..0b06142252f5 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -67,6 +67,12 @@ extern void **__add_ptr_list_tag(struct ptr_list **, void *, unsigned long); (__typeof__(&(ptr))) __add_ptr_list_tag(head, ptr, tag);\ }) +#define pop_ptr_list(l) ({ \ + PTRLIST_TYPE(*(l)) ptr; \ + ptr = delete_ptr_list_last((struct ptr_list**)(l)); \ + ptr; \ + }) + extern void __free_ptr_list(struct ptr_list **); #define free_ptr_list(list) do { \ VRFY_PTR_LIST(*(list)); \ From patchwork Sat Mar 6 10:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 910F4C433E6 for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FD6C6501B for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbhCFKGd (ORCPT ); Sat, 6 Mar 2021 05:06:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhCFKGB (ORCPT ); Sat, 6 Mar 2021 05:06:01 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E66C061760 for ; Sat, 6 Mar 2021 02:06:00 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id lr13so8738889ejb.8 for ; Sat, 06 Mar 2021 02:06:00 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=6enWgGsW2bbhfDC2+kbh/15Shhx2XSxq3naZnv9GAL8=; b=BgdYFcWzmwjnrG06DZqS9/UWEINfNS5TnNmLxtQdA9pu5zjPRk7NhlP3KYPUzn2ZtS YLIcgwDvqW2wf5nG7Nsnz2N0JViYPcIUFbW7ry+y7zgCGqY+0Po/bE5MVInZqWTp5HzT uzxPM8Jwah7NvbMLtPO2tu59bXdDgJfL2fwe53rLeJ2UrDLA9Uxgy5KKLm56ZaLWR9J0 6e0TgKKdo2o7oddgZGv1wiqeY1K3/O9Y5PdvKSGIDnpxqmUXR+/edyeGq2dLELiyLs6y O57TK8HPtqmJScZ6V7uppXTMFO4HHMs7r7/kpCuFh325LT+ZmpBHVwF1/Yq8zkyOVQUV dN6A== 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:mime-version:content-transfer-encoding; bh=6enWgGsW2bbhfDC2+kbh/15Shhx2XSxq3naZnv9GAL8=; b=YUfw5Q3TluPwoFyo4LC1M8Cmh1go0wtee9CpiYTQu+N7DY990hUBp5Q8QvRrn6DKN4 UVukdr4TiPpzbgfYW6boGKG+F+GuVj/RvyJuLF7TBUtdGMbUVtDD4akXvrN+TFWfGHVh xnKoKjzASCASCOX6+gacs90gg/0ISgRzP/mqHrd+KfBQTqalW346nQGoOQtwhmiNItqx J1ECdzEUHajZiQhXNP1v+EJ7pmIfuM5Gt+4YlzawF+8tTRG629ynaK1v0hUb56VuK7T6 VSDuqJMuI3aYfAp0qabOzZyfhN4i7yPhNlXOgiZe03hpBnoWUnXomTyzby3wKODS6wTd Tiew== X-Gm-Message-State: AOAM533Hpdh2lmmGbnVQ497ND/XyeBD556OAcL6gsC6VobcuOp/uLWah LH3vh8TKYbIAUJMN4HxG+qusKXoVWSY= X-Google-Smtp-Source: ABdhPJyDu2ib/9/exMYUWt/ZjK3NA5YVULQSRl+uaPDaL/ktNTtUy1oT9sWyW+cmV1WnS3V5liBwTQ== X-Received: by 2002:a17:906:1155:: with SMTP id i21mr6258303eja.218.1615025159724; Sat, 06 Mar 2021 02:05:59 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:05:59 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/6] ptrlist: use ptr_list_nth() instead of linearize_ptr_list() Date: Sat, 6 Mar 2021 11:05:50 +0100 Message-Id: <20210306100552.33784-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Sparse has a few extra checkers for some functions. The one for memset has its own helper the retrieve its 3rd arguments. Remove this helper and use the generic ptr_list_nth() instead. Signed-off-by: Luc Van Oostenryck --- sparse.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sparse.c b/sparse.c index 151eaf4ef5ed..9d62d4fe4fc4 100644 --- a/sparse.c +++ b/sparse.c @@ -163,20 +163,9 @@ static void check_byte_count(struct instruction *insn, pseudo_t count) /* OK, we could try to do the range analysis here */ } -static pseudo_t argument(struct instruction *call, unsigned int argno) -{ - pseudo_t args[8]; - struct ptr_list *arg_list = (struct ptr_list *) call->arguments; - - argno--; - if (linearize_ptr_list(arg_list, (void *)args, 8) > argno) - return args[argno]; - return NULL; -} - static void check_memset(struct instruction *insn) { - check_byte_count(insn, argument(insn, 3)); + check_byte_count(insn, ptr_list_nth(insn->arguments, 3)); } #define check_memcpy check_memset From patchwork Sat Mar 6 10:05:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 028C0C43381 for ; Sat, 6 Mar 2021 10:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C72026501B for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbhCFKGe (ORCPT ); Sat, 6 Mar 2021 05:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhCFKGC (ORCPT ); Sat, 6 Mar 2021 05:06:02 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD89C06175F for ; Sat, 6 Mar 2021 02:06:01 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id w17so8742770ejc.6 for ; Sat, 06 Mar 2021 02:06:01 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=/LMBevJmSCgopHRMDM4i5KKOiTA64I50nZ8Hg+dL4cU=; b=fQZyqesVms9Y5nCqF2bsITvxgATNejYgpjIZ06wbywiHU9bzLx7Cj8zMnimwG1yrxc HA7AjVouqbdHt659XFUJjuOKnSXyltgyTsNHteRxJEXYr6FXKhdfttzycRJVEAROGVvZ ETM2hIA+QbBZ+IYNmjIByJpyTxO42g2Yy5Pi+VVEfXcLJZZ6EN/N1hhlvxDns8WBRlHM /tKv0XMqqr7K+oTGAAoKfGxmlpkQBTgwnear7d3NpIWi2qC0yS8sDkkHz/88DhChHQQX rY/t5klLHIRHoWgsvDve5M3jM+QTYNyd3E8J6n3IZtah0HztcEivfLKFq+EnLYXp9B6A +Cig== 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:mime-version:content-transfer-encoding; bh=/LMBevJmSCgopHRMDM4i5KKOiTA64I50nZ8Hg+dL4cU=; b=e9yJ56+ivjA0+rQjQce7CLuVUxFBToeEv0MFWYM2MIBz8uxzHrEVekPAL+05+5vWuM oiL3c7WrcDTa/EkgM0AVoqjtJK8F6n2JiCLhejMe+bykmwEiThEf7pQXlrikhc0/QDkV pZtLNTm+CNG3jD0Yq+tLAqfGXE9nMlh1NmbkyC8UpToQlvnA/kSLVfZLlmPz9cbRDz8W XHF+/Byaw4bgaz8WIw19knW08q5c6Z2h3pyKzY/n3YC7aeHFp/dUReMmGSiNy8HRZiRu A7wdXQk/KwCnrQR2hzWI9ZdVeJ1r7EuHk00biW2B2cSCArIOAspeVj0W5AuT51sUVHlK mxgA== X-Gm-Message-State: AOAM5320gN9Bzx2Wv25Kxx4coJB+WOwPvjVy+nlSi8bM69Bjg6FO3kWS DfFlyyGx3hERP6PVR2SnuXVlNBdLSQQ= X-Google-Smtp-Source: ABdhPJwLNtlD7t8gOLIunt2vL9FR2XRhcSynhFsO98rOYxqSM8ucLhHzgGTmeoEpl7S69P4mh9cRAg== X-Received: by 2002:a17:906:f02:: with SMTP id z2mr6344871eji.469.1615025160341; Sat, 06 Mar 2021 02:06:00 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:06:00 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/6] ptrlist: make linearize_ptr_list() generic Date: Sat, 6 Mar 2021 11:05:51 +0100 Message-Id: <20210306100552.33784-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The ptrlist API has a function to copy the elements of a ptrlist into an array but it's not typed and thus needs a wrapper (or casts) for each type it's used for. Also, 'linearize' is confusing since this is unrelated to Sparse's linearization. Simplify this by adding a generic (but type-safe) macro for this (and changing the name): ptr_list_to_array() Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 6 ++++++ simplify.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 0b06142252f5..5a3dcbeb97ae 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -84,6 +84,12 @@ extern void __free_ptr_list(struct ptr_list **); (PTRLIST_TYPE(lst)) ptr_list_nth_entry(head, nth);\ }) +#define ptr_list_to_array(list, array, size) ({ \ + struct ptr_list* head = (struct ptr_list*)(list); \ + CHECK_TYPE(list, *array); \ + linearize_ptr_list(head, (void**)array, size); \ + }) + //////////////////////////////////////////////////////////////////////// // API #define PREPARE_PTR_LIST(head, ptr) \ diff --git a/simplify.c b/simplify.c index 584078ddca89..cf5b3d748808 100644 --- a/simplify.c +++ b/simplify.c @@ -83,7 +83,7 @@ static struct basic_block *phi_parent(struct basic_block *source, pseudo_t pseud // number of element, a positive number if there was // more than expected and a negative one if less. // -// :note: we can't reuse a function like linearize_ptr_list() +// :note: we can't reuse ptr_list_to_array() for the phi-sources // because any VOIDs in the phi-list must be ignored here // as in this context they mean 'entry has been removed'. static int get_phisources(struct instruction *sources[], int nbr, struct instruction *insn) @@ -116,7 +116,7 @@ static int if_convert_phi(struct instruction *insn) bb = insn->bb; if (get_phisources(array, 2, insn)) return 0; - if (linearize_ptr_list((struct ptr_list *)bb->parents, (void **)parents, 3) != 2) + if (ptr_list_to_array(bb->parents, parents, 3) != 2) return 0; p1 = array[0]->phi_src; bb1 = array[0]->bb; From patchwork Sat Mar 6 10:05:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12119783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2CB8C433E9 for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A93A464E01 for ; Sat, 6 Mar 2021 10:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbhCFKGe (ORCPT ); Sat, 6 Mar 2021 05:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbhCFKGC (ORCPT ); Sat, 6 Mar 2021 05:06:02 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 373BAC061760 for ; Sat, 6 Mar 2021 02:06:02 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id mm21so8678740ejb.12 for ; Sat, 06 Mar 2021 02:06:02 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=x1YcUyJjabQEKrMRUFckmxH6727IAtukLJ8KrLaI8nM=; b=SPAHbHhjujiHipimr43waa8qYQN10iOCtUqI2IwaK2vUnkVcuUMWmRF0Xp/l71BDyD forWlmLfXdk8tTwZPHPyM89Z5iiyyDFijkvKM/3lXZ3VdobvDyr59cskkHT7AdVn8Vm9 IsT9pe3yViJJ5O4fPEd0AkZd2VonQoaDIJenF+7HLQ4so9cAJMOa6bPHDUgblVl8qeNF dYpKW9Jjjz2vImiOnfEuxWBj48fzBd4NY09jkjmdOgLXWtyQ0i+cjAl6bJwAlC/6UbgB CaTIq5OJ0v3BWvdQhoPgCVEtdbdg+8+FBuNJalFD1zC+VUcACZ8APbQkOUFPEU2i4f3k hlUA== 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:mime-version:content-transfer-encoding; bh=x1YcUyJjabQEKrMRUFckmxH6727IAtukLJ8KrLaI8nM=; b=A0q1K5ta+25KT8zCO4+1glWixfA8xtimp/D99eGJbS6Q3JExIbJbsJTjVxELplcgmE P/2JyOEpdz/Qbia28sYjV1a8zjVEA+Dld3s+p0Q79s+p7pGn98LLDIsjjUgyBXA4D9bp OM7WLENoyFBADl+tL8Xk3DXFvI4xxAxVZUkC3dfGlvlAVpkedj94g39BmHwwHe22Brpm 08gPmEFU4NihP+Jy6fMYtdU+6l5fnmW1zXkiQpCmPbBZ5ruvcmtoTW0Wm6le9JouD5iH SqaQ3vq4AZqQdVPTXsqNdlMToKSV4ME0v5vSX9LGLR3jq4CoLpcizMrPBFgytwYsx50L uONg== X-Gm-Message-State: AOAM532uRc6sj5eluC/hK6mrTYZdTWPkz4opbmovSZEEJX58yUm59+2I lYn42HjE1xK77yRZ7nyKzjwA+U+QXpA= X-Google-Smtp-Source: ABdhPJzkDavrVl/otsN0DyA5ubDCGkp+8y3sEJo7p4rSOz166KS9jAzgmVMt+BIr8WbUFxwsgfRuxA== X-Received: by 2002:a17:906:4e17:: with SMTP id z23mr6420538eju.439.1615025160962; Sat, 06 Mar 2021 02:06:00 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:c537:1c5b:9ed2:3808]) by smtp.gmail.com with ESMTPSA id i11sm2624020ejf.76.2021.03.06.02.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 02:06:00 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 6/6] ptrlist: change return value of linearize_ptr_list()/ptr_list_to_array() Date: Sat, 6 Mar 2021 11:05:52 +0100 Message-Id: <20210306100552.33784-7-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> References: <20210306100552.33784-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The function linearize_ptr_list() is annoying to use because it returns the number of elements put in the array. So, if you need to know if the list contained the expected number of entries, you need to allocate to array with one more entries and check that the return value is one less than the maximum size. Change this, so that this function returns the total number of entries in the list, much like it's done for snprintf(). Signed-off-by: Luc Van Oostenryck --- ptrlist.c | 10 +++++----- simplify.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ptrlist.c b/ptrlist.c index 0f0b3f6d818f..ecfbc07b2b6d 100644 --- a/ptrlist.c +++ b/ptrlist.c @@ -154,10 +154,10 @@ void *ptr_list_nth_entry(struct ptr_list *list, unsigned int idx) // @head: the list to be linearized // @arr: a ``void*`` array to fill with @head's entries // @max: the maximum number of entries to store into @arr -// @return: the number of entries linearized. +// @return: the number of entries in the list. // // Linearize the entries of a list up to a total of @max, -// and return the nr of entries linearized. +// and return the nunmber of entries in the list. // // The array to linearize into (@arr) should really // be ``void *x[]``, but we want to let people fill in any kind @@ -170,14 +170,14 @@ int linearize_ptr_list(struct ptr_list *head, void **arr, int max) do { int i = list->nr; + nr += i; + if (max == 0) + continue; if (i > max) i = max; memcpy(arr, list->list, i*sizeof(void *)); arr += i; - nr += i; max -= i; - if (!max) - break; } while ((list = list->next) != head); } return nr; diff --git a/simplify.c b/simplify.c index cf5b3d748808..207af8edf28f 100644 --- a/simplify.c +++ b/simplify.c @@ -108,7 +108,7 @@ static int get_phisources(struct instruction *sources[], int nbr, struct instruc static int if_convert_phi(struct instruction *insn) { struct instruction *array[2]; - struct basic_block *parents[3]; + struct basic_block *parents[2]; struct basic_block *bb, *bb1, *bb2, *source; struct instruction *br; pseudo_t p1, p2; @@ -116,7 +116,7 @@ static int if_convert_phi(struct instruction *insn) bb = insn->bb; if (get_phisources(array, 2, insn)) return 0; - if (ptr_list_to_array(bb->parents, parents, 3) != 2) + if (ptr_list_to_array(bb->parents, parents, 2) != 2) return 0; p1 = array[0]->phi_src; bb1 = array[0]->bb;