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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 418B0C433FF for ; Tue, 13 Aug 2019 00:41:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09A602070C for ; Tue, 13 Aug 2019 00:41:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jtHRbV2j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbfHMAlS (ORCPT ); Mon, 12 Aug 2019 20:41:18 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44585 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbfHMAlS (ORCPT ); Mon, 12 Aug 2019 20:41:18 -0400 Received: by mail-pl1-f195.google.com with SMTP id t14so48508300plr.11 for ; Mon, 12 Aug 2019 17:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o2YhU7ZI7zRBNkSqHEOZBShLAkxc14NOfVdnGmm5fKU=; b=jtHRbV2jvCMOrug1VL8DlniNesFQqe4mwKTZ3VzgssQ3VQs6b5LtUaNMVZsc5CuJDp Iw8whkhdXJ7rcwjGwBhO6bOb4R9HDy3aGxnSkB24MJ9hY0F8GUX42o4R2L5RbO1mHvNQ fgfZIIuryuM6MsMlE2FCQsFy9Ko0MwXC35YX0zFHFknsYf9vPZZbgUGmBgAsRIvp4Uqd 60LKpvXh51SGPv9+hzg4POm9qQcvjpOv0jvCdTcXtAwCmnYW+REf4ctA9Xh3nN2C0Pk2 Dfg6a9VXk1PXwpLh/pQidSNRP79rt83WW1lNCqDZaP/t4ID/ZKf6fmlxyUwdKcQccRx2 iAHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o2YhU7ZI7zRBNkSqHEOZBShLAkxc14NOfVdnGmm5fKU=; b=lXp/953pM2VCKYwFw/T+YA4yz/9wR1egrfc6QsmP0wlUBWMxX3z6qisyTFC55so3te 3ODOjtfiKz0ExPPP5yzFuVyt9dI5/eAwp4F541l7W9Xc2/2Ip0M800JHk+sSr96lZv2H +a+LG40eHPPLF65UpEeYNyldpi9L/32qeNwC9asGxGQr2oZGJfVC3vfXgZdsdLqUwAw4 fvcV1Zy+fBuVn/V6hTgIgELLTM20TAkTt/cf59IGvLynP2UMCybd8BdXt+KAJuUZy90E Pxb9jX5Q4rttMhT9OngtGwqD8EzpcFEJuiiMb6r5X7EF+btfF/oJLELXcTTwIgJq/cXG MEFA== X-Gm-Message-State: APjAAAUpd5gc+1dyQF4ntij/8nhWVsrjXs0fdHmA9AdllzUit8zviQyv QfofNapyv0dnB85G1IijEXkNTZFeUMMvFggQFYFFdA== X-Google-Smtp-Source: APXvYqwMN7m1oxhncwRThnueyB+Cpwr7fkWXdNKhV0HMwJO6gvgJeykiY4kuCkE7DaZ3nG+H6w12tIuXT7ijhEgDApc= X-Received: by 2002:a17:902:5983:: with SMTP id p3mr25962931pli.232.1565656877406; Mon, 12 Aug 2019 17:41:17 -0700 (PDT) MIME-Version: 1.0 References: <20190812182421.141150-1-brendanhiggins@google.com> <20190812182421.141150-4-brendanhiggins@google.com> <20190812225520.5A67C206A2@mail.kernel.org> <20190812233336.GA224410@google.com> <20190812235940.100842063F@mail.kernel.org> In-Reply-To: <20190812235940.100842063F@mail.kernel.org> From: Brendan Higgins Date: Mon, 12 Aug 2019 17:41:05 -0700 Message-ID: Subject: Re: [PATCH v12 03/18] kunit: test: add string_stream a std::stream like string builder To: Stephen Boyd Cc: Frank Rowand , Greg KH , Josh Poimboeuf , Kees Cook , Kieran Bingham , Luis Chamberlain , Peter Zijlstra , Rob Herring , shuah , "Theodore Ts'o" , Masahiro Yamada , devicetree , dri-devel , kunit-dev@googlegroups.com, "open list:DOCUMENTATION" , linux-fsdevel@vger.kernel.org, linux-kbuild , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-nvdimm , linux-um@lists.infradead.org, Sasha Levin , "Bird, Timothy" , Amir Goldstein , Dan Carpenter , Daniel Vetter , Jeff Dike , Joel Stanley , Julia Lawall , Kevin Hilman , Knut Omang , Logan Gunthorpe , Michael Ellerman , Petr Mladek , Randy Dunlap , Richard Weinberger , David Rientjes , Steven Rostedt , wfg@linux.intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Aug 12, 2019 at 4:59 PM Stephen Boyd wrote: > > Quoting Brendan Higgins (2019-08-12 16:33:36) > > On Mon, Aug 12, 2019 at 03:55:19PM -0700, Stephen Boyd wrote: > > > Quoting Brendan Higgins (2019-08-12 11:24:06) > > > > +void string_stream_clear(struct string_stream *stream) > > > > +{ > > > > + struct string_stream_fragment *frag_container, *frag_container_safe; > > > > + > > > > + spin_lock(&stream->lock); > > > > + list_for_each_entry_safe(frag_container, > > > > + frag_container_safe, > > > > + &stream->fragments, > > > > + node) { > > > > + list_del(&frag_container->node); > > > > > > Shouldn't we free the allocation here? Otherwise, if some test is going > > > to add, add, clear, add, it's going to leak until the test is over? > > > > So basically this means I should add a kunit_kfree and > > kunit_resource_destroy (respective equivalents to devm_kfree, and > > devres_destroy) and use kunit_kfree here? > > > > Yes, or drop the API entirely? Does anything need this functionality? Drop the kunit_resource API? I would strongly prefer not to. string_stream uses it; the expectation stuff uses it via string stream; some of the tests in this patchset allocate memory as part of the test setup that uses it. The intention is that we would provide a kunit_res_* version of many (hopefully eventually most) common resources required by tests and it would be used in the same way that the devm_* stuff is. Nevertheless, I am fine adding the kunit_resource_destroy, etc. I just wanted to make sure I understood what you were asking.