From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75D58C433F5 for ; Wed, 22 Dec 2021 01:49:30 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JJbpw6rbNz2yw9 for ; Wed, 22 Dec 2021 12:49:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ozlabs.org; s=201707; t=1640137768; bh=DkT1DIxWSEK+IbPoO8EjD24RH82e5udaoLLtm83dCzE=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=esxQSXuB9+lWEK+PBrvQaSkogSjI+lQN8mS5MK+eIgfdzDEswJ/Yhc/u5SKoBhM3y kQxANNpOJJreRsjfivToi0DeOmTZWbYt7hakeF09WVajKD5U+T4R0uGEpXeCUgk8st JKoJ/GOfQqxKuI7TFRqnmkfyXXAawttZDm4gLsAl25X8LjR264WzEGnJxjTMzLrIj3 cRkZi8Ukt8MmqDxhevGetXxfCwgSQ++2jPGz/svHcQlVHElkayxXyZ/UeVKqJqFZy8 vV7rbKHDWOMd8X6jHDtekF++5I8l2B1Ei1aBgtNNCILcyrjf5Jk62QPSZ1wO2ypsdU 56JC7jwNuKlDw== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--zhangkelvin.bounces.google.com (client-ip=2607:f8b0:4864:20::949; helo=mail-ua1-x949.google.com; envelope-from=3iitcyqskc0c8qjwptnu4rwpxxpun.lxvurw36-n0xo1ur121.x8ujk1.x0p@flex--zhangkelvin.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Jc+tkjHH; dkim-atps=neutral Received: from mail-ua1-x949.google.com (mail-ua1-x949.google.com [IPv6:2607:f8b0:4864:20::949]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JJbps0ytNz2xrP for ; Wed, 22 Dec 2021 12:49:23 +1100 (AEDT) Received: by mail-ua1-x949.google.com with SMTP id y5-20020ab05b85000000b002fa1b6d2430so488395uae.0 for ; Tue, 21 Dec 2021 17:49:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DkT1DIxWSEK+IbPoO8EjD24RH82e5udaoLLtm83dCzE=; b=kCB8KlO+mQeURTbYzamlzaZ5dAvUcFI93d88fKrnoAfM/rAUW0WD4v/KI2AlB5tUTQ 7+cfRfF4NX0z/6Nt/wfATvshDAMix0SWnni+3yyDqV3nIz+Q/nEcMR5hQZt3O6lNUlhq EqiOrYNo4EhWFkgy+fuMmWGwpRH529eCY3AsDuuooSPsC2+CqKLPs8gIwYwrD4Y9KijS esmsiCnSoLXIInk73AQt/WNEfjA8bLto8sv+W2I8ifS0u4u8StvEp4zCs7FdKcW+e1Wz gcaKbemrfrj+ezOFbNexEYsZ4HR5B54ac67I+Jo5GKCtykJS/i/3uqwB0ZpHZakCN/TV xisQ== X-Gm-Message-State: AOAM5315EH+TqXOx/bkJNJlzhY90XLikY6YJOrr6aCjHH8PNg5OxtUeH q+GKXjbrcWzbXQpGniUwgxZW9N+NKRq1ap0VpvzL7irfxZFPGasUe0MX2SJVF7Bta7lH/OLLEZl XjGG0ODEmLKfG5MnmIhub5w0CeV2HTCrYqOUCyK8jIguZuAHSXVYULnCk3zUdAlYxr82FrVneyn EC0IQM4TQ= X-Google-Smtp-Source: ABdhPJwRuBuRFYXx4lcfUkmHrJV/GzikaO1KN54whaoLeS15Cb6sftiaCcjYCMXjZDN5avqS6aqJzqidj6pm2s1YIw== X-Received: from zhangkelvin-big.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:1f4a]) (user=zhangkelvin job=sendgmr) by 2002:ab0:2b96:: with SMTP id q22mr305590uar.87.1640137760193; Tue, 21 Dec 2021 17:49:20 -0800 (PST) Date: Tue, 21 Dec 2021 17:49:16 -0800 In-Reply-To: Message-Id: <20211222014917.265476-1-zhangkelvin@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH v2 1/3] erofs-utils: lib: Add some comments about const-ness around iterate API To: linux-erofs mailing list , Miao Xie , Fang Wei Content-Type: text/plain; charset="UTF-8" X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Kelvin Zhang via Linux-erofs Reply-To: Kelvin Zhang Cc: Kelvin Zhang Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" The new iterate dir API has non-trivial const correctness requirements. Document them in comment. Signed-off-by: Kelvin Zhang --- include/erofs/dir.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/erofs/dir.h b/include/erofs/dir.h index 77656ca..59bd40d 100644 --- a/include/erofs/dir.h +++ b/include/erofs/dir.h @@ -39,6 +39,14 @@ typedef int (*erofs_readdir_cb)(struct erofs_dir_context *); * the callback context. |de_namelen| is the exact dirent name length. */ struct erofs_dir_context { + /* During execution of |erofs_iterate_dir|, the function needs + * to read the values inside |erofs_inode* dir|. So it is important + * that the callback function does not modify stuct pointed by + * |dir|. It is OK to repoint |dir| to other objects. + * Unfortunately, it's not possible to enforce this restriction + * with const keyword, as |erofs_iterate_dir| needs to modify + * struct pointed by |dir|. + */ struct erofs_inode *dir; erofs_readdir_cb cb; erofs_nid_t pnid; /* optional */ -- 2.34.1.448.ga2b2bfdf31-goog