Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp727545rwb; Wed, 28 Sep 2022 08:22:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nv8bNpXgtlavbKjLge0xTI823bfYdSyFxmOyPZc+ifUfvFsxq9m6ORH5cZ8V7SonOPkWj X-Received: by 2002:a17:902:c948:b0:178:ba92:97b5 with SMTP id i8-20020a170902c94800b00178ba9297b5mr340132pla.132.1664378522249; Wed, 28 Sep 2022 08:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664378522; cv=none; d=google.com; s=arc-20160816; b=i41uiFGsIZdkZ8u7fKx3Y4QlFcxV+rgeHI5spuy6wlB0lOI2+OjRub2uxHQTqBhUPe voA0NOshzJIakVs4yD4yAc5B/taYTKyxB7ZUunz56iUnka8mhL+MtJcbDSuR+CYYKuLl XZ59KAlOW0eUMBM6vfNhmf09Yebzk2SavbbE2uDUyku9gFt0eZwYTFXWo00R7w/04le4 4M/Po2dQjJtPfGLAV4H9bFhACuGCpi0FBMcSMi56pQurKZPCkPXYfWT6ZKwpbNEdpcJq Z7QGNK1hwFsDaIf1oD/2TBG2gshR4cGk9vUFRRocRzNtSbl7TGLvC5vOz1Ft/Kg9ERuj mk6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=a7vLBMT/E4442MupPoT+pHag9Mp/Q4EXWsrU1jJIFGw=; b=RD0v2wFazs8v0ZCyoYRFVNhdFuIyDAHBlo+qWkTWEwlSFTEp96rO7ywr2At6lC/0VL KfRaEPfT8huL9XhivihrNLFKj0CH0KXGpkofyY1r+P6y6QvWw4B0mb0QHqSS8K9UdMWs WmrQXD1Y9Gu7tp3GRxYJhWItbhEUWpwyGS2l6Wp80KmZ4tsMBgipmTzgvSZQ44FP0cHe snYg6fPu87uH7X9EmOUnHOgPM+MFb63XPtVnyKJnfUWt5KA9P4EM0RozTHFladIgWXA1 PwX3wHws53orK0B2fU0GYM2TVh+Ypv3AfNiXMSRJ+GKYhR+qpFv69CArY1oh9zo2N1fr NjyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj5-20020a17090b4f4500b00205de051777si2788164pjb.60.2022.09.28.08.21.50; Wed, 28 Sep 2022 08:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbiI1PLK (ORCPT + 99 others); Wed, 28 Sep 2022 11:11:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234671AbiI1PKz (ORCPT ); Wed, 28 Sep 2022 11:10:55 -0400 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08C219C17; Wed, 28 Sep 2022 08:10:54 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id v28so7451704wrd.3; Wed, 28 Sep 2022 08:10:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=a7vLBMT/E4442MupPoT+pHag9Mp/Q4EXWsrU1jJIFGw=; b=tAAMt2itvPRyxJJmUqv3YkESszzuv7uTdb2AuIijFAh3+XY5e94/6s90e8hqqGF54k xFxW7UpWTymbyDnJtStLY14GABtyNKkZBwn1VpvNWb9IsHfz9yQWMaEfLqzv9avXCflG L4N0ztZb4kHlpOnj26eXT/7Bp2IvSiITl97kgpLSG3D1ikaZFaxBmEq0iwdZFZQPjF9l yZlZ8NwIq8z6GSeTHJLEHkAzgtyvcZQDriShTQvB+R3dvADWvLgJK0eVD8S6eT0WokXX rQZ/gVtmjI3Rf+8FbqrFqqTbfYNKoDuuPH/sZQwCHyExsV3Wj8Cf/bwpRRijpUOsjGz8 pKYw== X-Gm-Message-State: ACrzQf0nwxYWCCk2GdCFKp8Q8tGR6ufdOR4blHRK4ux6ZhRPbbhMBdbe IBA/VChqtFmnbOZwp+U41KU= X-Received: by 2002:adf:f58a:0:b0:22c:be20:24e8 with SMTP id f10-20020adff58a000000b0022cbe2024e8mr5903192wro.245.1664377853246; Wed, 28 Sep 2022 08:10:53 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id y3-20020a5d4ac3000000b0022ac672654dsm4642497wrs.58.2022.09.28.08.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 08:10:52 -0700 (PDT) Date: Wed, 28 Sep 2022 15:10:51 +0000 From: Wei Liu To: Miguel Ojeda Cc: Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Matthew Bakhtiari , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Wei Liu Subject: Re: [PATCH v10 08/27] rust: adapt `alloc` crate to the kernel Message-ID: References: <20220927131518.30000-1-ojeda@kernel.org> <20220927131518.30000-9-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220927131518.30000-9-ojeda@kernel.org> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 27, 2022 at 03:14:39PM +0200, Miguel Ojeda wrote: > + /// Tries to append an element to the back of a collection. > + /// > + /// # Examples > + /// > + /// ``` > + /// let mut vec = vec![1, 2]; > + /// vec.try_push(3).unwrap(); > + /// assert_eq!(vec, [1, 2, 3]); > + /// ``` > + #[inline] > + #[stable(feature = "kernel", since = "1.0.0")] > + pub fn try_push(&mut self, value: T) -> Result<(), TryReserveError> { > + if self.len == self.buf.capacity() { > + self.buf.try_reserve_for_push(self.len)?; > + } > + unsafe { > + let end = self.as_mut_ptr().add(self.len); > + ptr::write(end, value); > + self.len += 1; > + } Missing safety comment here? With a safety comment added: Reviewed-by: Wei Liu > + Ok(()) > + }