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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69931C77B73 for ; Tue, 30 May 2023 14:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233045AbjE3OOf (ORCPT ); Tue, 30 May 2023 10:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbjE3OOa (ORCPT ); Tue, 30 May 2023 10:14:30 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 203ACE44; Tue, 30 May 2023 07:14:03 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-568af2f6454so13351057b3.1; Tue, 30 May 2023 07:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685456039; x=1688048039; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PTwLalb60PTMu/jAkQpXrnGqb2wva++F9Sq3eW5kYQw=; b=qPUeDTcfr7OxXHtWHpcNb077XYd+nlwgobee3voPFCtgiNZZCdBM2G3Mhwr2tv/LRJ jHmRt9KmlO/RUNoiqFwZSzGXMZaBSGflQGfKo+G6DDH+ielIX7hxTdc3rHYBPgRLOYX7 h8GQHgoSGNJ+0lf1kj6aZ8S8zbAByKRnQBhxbFrgOcciMBi3CGF9Ey9JXPNtqraKpXgc Moy08rwTmdHh4+hZOS6DMcn5aohfMr+L/rSQcCnG2cCVx9nQ0hNv4qQNbCUcy0gB7FOi VMfhyusYx46sN3ZYS3Y2vxo5SkU+Kgx4hTm41bvGnkgAgk4P/fKBHtiMCJWWNcLAvwjN AIVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685456039; x=1688048039; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PTwLalb60PTMu/jAkQpXrnGqb2wva++F9Sq3eW5kYQw=; b=Q8j1gaqtJrci+p3jn5VzVgi/iEcmHhO/8pyolxASgUiSwWegt7uLpKU3NUi2byARg7 TKzzAWxsioeGofIWZMEeg4kjLN92yufhMUeUmT5+huL/AD2upUNCnUH5XSXlAJOnfXDI WiYYOYpWMRuvV53wkzXXjQRz+Pv37PI0uI4mbiUkg2YYfxs+6V1KJ+jN59EhGVo1H4et eKaChUvspFXCosyiaP5jm6goGCRLEdqxqCi+c5xVcIi4V5Q/6gKvRbnS2iiq3UblqNgT T7h7MJR9rziFfi3whddxRRLzeqO07dYGA//gmbQR6NNHS/dEdWu5jTLWv9PIrgy12pjQ kepw== X-Gm-Message-State: AC+VfDxyZvqL4GfoyjhdWus5UwSUAWRUYT/ksW8VP2V4NDyRtz+jAZ8h gRmKcSJ710i6jZ+MKbAN1TAQlexohAJ8R63Hjd8= X-Google-Smtp-Source: ACHHUZ6RCEc1+fd5Perd8QLWxHmkFspNj2sVjBhJt3SR1lXVmV9tboAd8bJTp6zA0EHcE71YBH9ngmMm6Ax3uTvHiJo= X-Received: by 2002:a81:a0d2:0:b0:565:6acc:2e56 with SMTP id x201-20020a81a0d2000000b005656acc2e56mr2589958ywg.15.1685456039055; Tue, 30 May 2023 07:13:59 -0700 (PDT) MIME-Version: 1.0 References: <20230523110709.4077557-1-aliceryhl@google.com> In-Reply-To: <20230523110709.4077557-1-aliceryhl@google.com> From: Miguel Ojeda Date: Tue, 30 May 2023 16:13:47 +0200 Message-ID: Subject: Re: [PATCH v1 6/7] rust: workqueue: add safe API to workqueue To: Alice Ryhl Cc: yakoyoku@gmail.com, alex.gaynor@gmail.com, benno.lossin@proton.me, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net, jiangshanlai@gmail.com, linux-kernel@vger.kernel.org, ojeda@kernel.org, patches@lists.linux.dev, rust-for-linux@vger.kernel.org, tj@kernel.org, wedsonaf@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 23, 2023 at 1:07=E2=80=AFPM Alice Ryhl w= rote: > > I think this is a question of style. For a comparison: > > match (queue_work_on)(work_ptr) { > true =3D> Ok(()), > // SAFETY: The work queue has not taken ownership of the pointer. > false =3D> Err(unsafe { Arc::from_raw(ptr) }), > } > > vs > > if (queue_work_on)(work_ptr) { > Ok(()) > } else { > // SAFETY: The work queue has not taken ownership of the pointer. > Err(unsafe { Arc::from_raw(ptr) }), > } There is also the possibility of using the early return style: if ... { return Err(...); } Ok(()) This one makes it consistent with other early exits (i.e. whether at the end of the function or not) and closer to the C side. It is particularly nice when we are talking about errors, instead of two "equal", non-error outcomes. Cheers, Miguel