Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1578305pxb; Fri, 26 Feb 2021 14:52:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrM7pEnPUKFoJAHDYSgurJ6Cl/3i2bdtq6kQjnuhBVLzRT2XZ081UjryGAomVBC43n4gPf X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr5629184ejc.462.1614379958464; Fri, 26 Feb 2021 14:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614379958; cv=none; d=google.com; s=arc-20160816; b=mEaFaAEccwTaWhuPNJtxx4kmsUECj/7LWKEaBEdFEIte1ooew18XSYk5j7dwxeQaEL NFfyq5CZdWorbN6xdUT7fhBPOPQQwDD/AmG6e4pUIhLnFiyY9ChZP7pLWESZ9PtDJbpn TRB78AdIshnf8ifj/aN5fYDXxnmSFEv8KeDu0V8Ys8+Vkgz88Tkty+1TQjVxv08v8DMY HaD3y+Oxh3h9h0IcfdOWN3cnSV6It798uijXtcL6z0GuVrva1r9Fs2/RTGBuYEDw918r 1Qx05nooDnd7PVpHKg/C6t935j/1nzLqHCMqgVObVEIjm/HAQw0yznzb9MIbVvbzELiO jfEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ev7TwjRdwW/d0NpBv1ZVAqHMMudeYNkt2py5oSxq6hI=; b=cvtrGlVB7j330rGdFPa7y3QYpPaUEeCMpqj/diJdQG9n8CT77JnVGY6IXw4IrE/38T G6QfNIN6EXtKbcws+hS8f008b4rX5q7PDmsbNh7oZLWefVITKTZAvbPDNRkP0Q6tdESY ZAxcz/3kKVd889GyxJwUBpn7Lq17mXAErKCF51Sei6T+CE/sXk04XM6nyWf4qCybxdHT b78rOe/yWpBHU7d7mQWKXfMGpi8oKg66oTqMaHgR9itVdHBwkZ51NswSlr7WLDwAjfu4 dyMSpnBwPsCQsvSnZLWZidDYtVcOXbkGGAPnE3ycrTfvIQ4TjpyDHLUAX/d+qFSLAJYB 6vAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=EgSG0elk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si6696744ejz.43.2021.02.26.14.52.16; Fri, 26 Feb 2021 14:52:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=EgSG0elk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbhBZWux (ORCPT + 99 others); Fri, 26 Feb 2021 17:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhBZWuw (ORCPT ); Fri, 26 Feb 2021 17:50:52 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23ED1C061574; Fri, 26 Feb 2021 14:50:12 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C14F0580; Fri, 26 Feb 2021 23:50:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614379810; bh=9xbPoCselTfaNNlFq/iLq9ax7icwUScwxe77vp6/2sE=; h=From:To:Cc:Subject:Date:From; b=EgSG0elkYNBxRPWqVrss9X85CeI4D0IvYDkmaiVRjw55Exn3kCsdZJ42XbvBvOo2E vQhi0iYxnEXTN0P1KvZQYtBW9DRfAroJ4goAxmPkYuPpkvEZW8gZkVY+eYvjAE4l+K lss1SmybeDqocMBnZpA0K/+Prym5f8Kn4LGjiIGs= From: Laurent Pinchart To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , linux-renesas-soc@vger.kernel.org, Laurent Pinchart Subject: [PATCH 1/2] list: Add list_is_null() to check if a list_head has been initialized Date: Sat, 27 Feb 2021 00:49:37 +0200 Message-Id: <20210226224938.18166-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart The new function checks if the list_head prev and next pointers are NULL, in order to see if a list_head that has been zeroed when allocated has been initialized with INIT_LIST_HEAD() or added to a list. This can be used in cleanup functions that want to support being safely called when an object has not been initialized, to return immediately. In most cases other fields of the object can be checked for this purpose, but in some cases a list_head field is the only option. Signed-off-by: Laurent Pinchart --- include/linux/list.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 85c92555e31f..e4fc6954de3b 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -29,6 +29,19 @@ static inline void INIT_LIST_HEAD(struct list_head *list) list->prev = list; } +/** + * list_is_null - check if a list_head has been initialized + * @list: the list + * + * Check if the list_head prev and next pointers are NULL. This is useful to + * see if a list_head that has been zeroed when allocated has been initialized + * with INIT_LIST_HEAD() or added to a list. + */ +static inline bool list_is_null(struct list_head *list) +{ + return list->prev == NULL && list->next == NULL; +} + #ifdef CONFIG_DEBUG_LIST extern bool __list_add_valid(struct list_head *new, struct list_head *prev, -- Regards, Laurent Pinchart