From patchwork Mon Jun 11 01:51:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10456871 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 488006020F for ; Mon, 11 Jun 2018 01:51:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39C12274A3 for ; Mon, 11 Jun 2018 01:51:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E93627D0E; Mon, 11 Jun 2018 01:51:29 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, 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 B6DB7274A3 for ; Mon, 11 Jun 2018 01:51:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753780AbeFKBv2 (ORCPT ); Sun, 10 Jun 2018 21:51:28 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53505 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753746AbeFKBvZ (ORCPT ); Sun, 10 Jun 2018 21:51:25 -0400 Received: by mail-wm0-f66.google.com with SMTP id x6-v6so11838397wmc.3 for ; Sun, 10 Jun 2018 18:51:25 -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=AWftOv0nQysUfzpcwfLarV6Feej8eGhzf3+JgMocf/M=; b=G/CXCuW6sGIaqMvGOjlSOILFMWRirU3euAlCfJxJ3Avm2ZTehMsRmDhCZHkmSatl1W rgOc1qaDa4eeTRJIb6JYk964ys2YhuRMCJLJUNGj5X5OYk6ZPbmK3j/bM+Y/XJMekp4r 1mUQF1G9GqnOmQMLfQKEVVoAgLiO4XyQ6TAf3GDRILb/U6Vprx5qTKV95XtR4rOqliJf BL/wE8LRdosSpeUcAmT2Y64iXN4bedj4Xz1IsVrue3Ma+1InakWtST4PgYAYnXzFXjFb nMMB2GHJ/BnjScW0VdtRoqkLDfHsKJCu2fl1I6qVN5ChSjc0WabQzLzBTF+dXfmZf3SN Pgzg== 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=AWftOv0nQysUfzpcwfLarV6Feej8eGhzf3+JgMocf/M=; b=ATLbH9FJwk7HCpbtJnNqB9QfMumqxUiZI8bDfEF6/81hBFzExXRaWM1hWrZORPWQls +ElRySnhYMXBTJBb+MKYqfQoYwc2gJQx9cbMzAE1bjHULD/Ys57sWaPYXETGSvO7xtcW jwAL7UtgwtH1GKFIeRCD6PlmQkALez1yjG64+tVH3nAWUQhwZDPBAH9MdAA4xNGwU3SP LkXRUMgV2ct/4JiEQqe8DP2utUOaevkAUaMKcUKuTOHBs2K9AmA6tyEoW678NtiJcHcF OfiSlZ8m6fsK9uGQcmwVwxWIm6x5GbDZ6DXSWC9+jipjggb+0ZtbJNebDA5uGdSH3rVf Id6Q== X-Gm-Message-State: APt69E0y1jV3p14oKAfhGqXC20b3gynHfPsysVJuvm9LccoIyY/HwHc3 v4ZhUxkkJUnJ7DfhmlSA/j7Wa9cf X-Google-Smtp-Source: ADUXVKLCpQy0FwYihCjCh7gQZvHqeoPbHmPveVxFLVV9lETFODs4Wj8rq1JKHP0U6FEND4ATdIzGGw== X-Received: by 2002:a50:c101:: with SMTP id l1-v6mr8262172edf.188.1528681884196; Sun, 10 Jun 2018 18:51:24 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:40a0:8d00:592:7be4:f88c:fb12]) by smtp.gmail.com with ESMTPSA id m19-v6sm10919013edr.33.2018.06.10.18.51.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 18:51:23 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 02/13] ptrlist: when possible use the real type of the list Date: Mon, 11 Jun 2018 03:51:08 +0200 Message-Id: <20180611015119.94067-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180611015119.94067-1-luc.vanoostenryck@gmail.com> References: <20180611015119.94067-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 The macros doing the list walking used to be done, not on the declared list's type but on the concrete & generic type 'struct ptr_list'. This incurs casting between the real and the generic type. Now that the declared type matches ... these casts are not needed anymore and the real declared type can be used instead. Signed-off-by: Luc Van Oostenryck --- ptrlist.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 6cec720e0..4e985d45b 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -98,7 +98,7 @@ static inline void *last_ptr_list(struct ptr_list *list) } #define PTR_DEREF(__head, idx, PTR_ENTRY) ({ \ - struct ptr_list *__list = __head; \ + __typeof__(__head) __list = __head; \ while (__list && __list->nr == 0) { \ __list = __list->next; \ if (__list == __head) \ @@ -109,8 +109,8 @@ static inline void *last_ptr_list(struct ptr_list *list) #define DO_PREPARE(head, ptr, __head, __list, __nr, PTR_ENTRY) \ do { \ - struct ptr_list *__head = (struct ptr_list *) (head); \ - struct ptr_list *__list = __head; \ + __typeof__(head) __head = head; \ + __typeof__(head) __list = head; \ int __nr = 0; \ CHECK_TYPE(head,ptr); \ ptr = PTR_DEREF(__head, 0, PTR_ENTRY); \ @@ -155,8 +155,8 @@ static inline void *last_ptr_list(struct ptr_list *list) DO_FINISH(ptr, __head##ptr, __list##ptr, __nr##ptr) #define DO_FOR_EACH(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ - struct ptr_list *__head = (struct ptr_list *) (head); \ - struct ptr_list *__list = __head; \ + __typeof__(head) __head = head; \ + __typeof__(head) __list = head; \ CHECK_TYPE(head,ptr); \ if (__head) { \ do { int __nr; \ @@ -176,8 +176,8 @@ static inline void *last_ptr_list(struct ptr_list *list) } while (0) #define DO_FOR_EACH_REVERSE(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ - struct ptr_list *__head = (struct ptr_list *) (head); \ - struct ptr_list *__list = __head; \ + __typeof__(head) __head = head; \ + __typeof__(head) __list = head; \ CHECK_TYPE(head,ptr); \ if (__head) { \ do { int __nr; \ @@ -201,8 +201,8 @@ static inline void *last_ptr_list(struct ptr_list *list) #define DO_REVERSE(ptr, __head, __list, __nr, new, __newhead, \ __newlist, __newnr, PTR_ENTRY) do { \ - struct ptr_list *__newhead = __head; \ - struct ptr_list *__newlist = __list; \ + __typeof__(__head) __newhead = __head; \ + __typeof__(__head) __newlist = __list; \ int __newnr = __nr; \ new = ptr; \ goto __inside##new; \ @@ -247,7 +247,7 @@ static inline void *last_ptr_list(struct ptr_list *list) extern void split_ptr_list_head(struct ptr_list *); #define DO_SPLIT(ptr, __head, __list, __nr) do { \ - split_ptr_list_head(__list); \ + split_ptr_list_head((struct ptr_list*)__list); \ if (__nr >= __list->nr) { \ __nr -= __list->nr; \ __list = __list->next; \ @@ -255,7 +255,7 @@ extern void split_ptr_list_head(struct ptr_list *); } while (0) #define DO_INSERT_CURRENT(new, ptr, __head, __list, __nr) do { \ - void **__this, **__last; \ + TYPEOF(__head) __this, __last; \ if (__list->nr == LIST_NODE_NR) \ DO_SPLIT(ptr, __head, __list, __nr); \ __this = __list->list + __nr; \ @@ -272,8 +272,8 @@ extern void split_ptr_list_head(struct ptr_list *); DO_INSERT_CURRENT(new, ptr, __head##ptr, __list##ptr, __nr##ptr) #define DO_DELETE_CURRENT(ptr, __head, __list, __nr) do { \ - void **__this = __list->list + __nr; \ - void **__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++; \