Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp835624pxb; Fri, 16 Apr 2021 21:25:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiKJ+Pqqtdh+CbmW34q+dExUZHbYYqf5Gs5iPLaaw+QQC+Lt3K8logBYz5eH+q7sCHl05b X-Received: by 2002:a62:2cc8:0:b029:23d:bd0d:2ac3 with SMTP id s191-20020a622cc80000b029023dbd0d2ac3mr10478787pfs.41.1618633556992; Fri, 16 Apr 2021 21:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618633556; cv=none; d=google.com; s=arc-20160816; b=Gbzze5dGjA/ZdvwisQeTvtC76NQAkM0VcMN6h9/Ne4VT/gPpppIjYozEpeOPEh8FDi sM1xeG8cI9ilCDDFOK92fpEKF0V2Z2hv4aNzWGa/5KzGo38aG0vAXgh2/n5pgK8XUfUo cRDs1TO4oxYu4tJ43mc0+xt5qZPJEBGfQooK1bXBw26rchGC3WB++I2+01iQNEAjbMuf l3nollsEgXt0ucTNqD7spCby4hwD2giurMbjp+LsIuwBuk/IyFdTX9s0uD0nZiMhrXsi NHKGV8g/MWCpjISa1GvdquWENMuSQCucTW/IrJLZcN+jplqKfTjvGlLPcMqtTlTLL/D7 pAXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7UMK47fCXcaTiYClcKDyFiFaKNuPNZagIhLbMd1w/aU=; b=qGJr/ivzwR8uSlfjg0Lkql2cQTs7c/bMhjU1e0iU77PQVhE6BkCei4Ji9NAHLHGHJl 9o8bXyqq5NUsrcXlvvjuoi6krJTaCE54ZwWtmuSrOylklizoTvwjiCFKj9HvwHUYIUe9 F9idRCllGb9oqE87BuVH6spi7mHvZNw+QLfWWGVAoNRCNTyphHiPcaKHZXtPNPazMwXi am3OCvDyXo50FTlRRVxnrfdGKlHJwy/U95fK3h89jST8PkRuQWtH+l1xvENW7QNXP9ZM 3umhMoePZLfxaUU1+ltdN5POjBvPZGiDLzWvpVCbObCfIhV05Zs3um76hwNAYBwFkAAj uvcA== ARC-Authentication-Results: i=1; mx.google.com; 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 y67si9159316pgy.484.2021.04.16.21.25.44; Fri, 16 Apr 2021 21:25:56 -0700 (PDT) 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; 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 S232972AbhDQEZN (ORCPT + 99 others); Sat, 17 Apr 2021 00:25:13 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:51778 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229465AbhDQEZK (ORCPT ); Sat, 17 Apr 2021 00:25:10 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 13H4O52o013478; Sat, 17 Apr 2021 06:24:05 +0200 Date: Sat, 17 Apr 2021 06:24:05 +0200 From: Willy Tarreau To: Miguel Ojeda Cc: Connor Kuehl , Al Viro , Linus Torvalds , Peter Zijlstra , Miguel Ojeda , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, Linux Kbuild mailing list , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho , Michael Ellerman Subject: Re: [PATCH 04/13] Kbuild: Rust support Message-ID: <20210417042405.GA13432@1wt.eu> References: <20210416220416.GA11872@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 17, 2021 at 01:46:35AM +0200, Miguel Ojeda wrote: > On Sat, Apr 17, 2021 at 12:04 AM Willy Tarreau wrote: > > > > But my point remains that the point of extreme care is at the interface > > with the rest of the kernel because there is a change of semantics > > there. > > > > Sure but as I said most often (due to API or ABI inheritance), both > > are already exclusive and stored as ranges. Returning 1..4095 for > > errno or a pointer including NULL for a success doesn't shock me at > > all. > > At the point of the interface we definitely need to take care of > converting properly, but for Rust-to-Rust code (i.e. the ones using > `Result` etc.), that would not be a concern. Sure. > Just to ensure I understood your concern, for instance, in this case > you mentioned: > > result.status = foo_alloc(); > if (!result.status) { > result.error = -ENOMEM; > return result; > } Yes I mentioned this when it was my understanding that the composite result returned was made both of a pointer and an error code, but Connor explained that it was in fact more of a selector and a union. > Is your concern is that the caller would mix up the `status` with the > `error`, basically bubbling up the `status` as an `int` and forgetting > about the `error`, and then someone else later understanding that > `int` as a non-error because it is non-negative? My concern was to know what field to look at to reliably detect an error from the C side after a sequence doing C -> Rust -> C when the inner C code uses NULL to mark an error and the upper C code uses NULL as a valid value and needs to look at an error code instead to rebuild a result. But if it's more: if (result.ok) return result.pointer; else return (void *)-result.error; then it shouldn't be an issue. Willy