Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2311649rdh; Sun, 26 Nov 2023 01:28:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIxRBmMAfbStj0ZL+LqybBT3dmJxCO/1SB4s3kratlCkOh35tzuzez690TD8T1/QZJFVPk X-Received: by 2002:a05:6a20:7493:b0:189:bde9:71aa with SMTP id p19-20020a056a20749300b00189bde971aamr10106177pzd.48.1700990933439; Sun, 26 Nov 2023 01:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700990933; cv=none; d=google.com; s=arc-20160816; b=bfDpxVCKOydh3wZbd+c4m5ss4iEHSaV6hyoPE4h6eAULORbIFuaGb4fIfg8cxOLGoZ +7kmxccPZA1TBfiV/xsO0QaYm6Zbu8zbkxxud64Rxbig3zPRQrnynuw/PPOXcjrfrVCm 2LMJLqRjBU3fxzA7aWxb69RBFN7DE2GRP21eeaSINPv8yb+FHX+zOiJ47QsK0GoYLc8v +7lMdWPQx//cHm+afaKtknrnf0eIGoVc0E6WGBqLUm6AGPCGjuTXdVy3dEJ7FjPwGUxP tOZtpGYBVWk79Ii9fSn1X2cuh2DQtwEx8VGLULvnHPogO/yq/zMov5PeS2pULLpGrOmv VO2A== 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=ATE5wSdHkij+WOQDOW9Ra9PDPbbdASzcmspMWuR+7dU=; fh=qYSE4JWoGuek8PPANgtObAomYOrd4iJoUXDlbhr3PnI=; b=aQIhYIdTo8+tpxcX2v3Xgkdlvtl5dBNjbd3IyWzewkp/LnvhybY6sKSrR9b9oCe2oq HB57cEj0nCw+xGT+p/IAJlr9LWB8BzJ+jGjX+Uq41iLIcgk0ub/4zna/fY3TDTozIKOv 8sCqTHsCYrfjrZTSC35Q1EDbWZjanv91S49YjmOlnM7ItKrUl759iQdMUR4ZM7HxniVa cuxp8ipfhvWxKeNAnmbT4oKGXJ3uKQ3J2CkziD/JYfhDUt3OkL41Kub3RRQ3yyTiFHDJ 9o1itw9PQk88CoghhxwWaPaVLpXXGbJ57mIWOz4AWOpHL6XKhlqWunmC7lHCgI6f3TEC h+Gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id by30-20020a056a02059e00b005bd3cf5fd1esi8188794pgb.389.2023.11.26.01.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 01:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1E4B1808ABA9; Sun, 26 Nov 2023 01:28:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjKZJ2f (ORCPT + 99 others); Sun, 26 Nov 2023 04:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjKZJ2d (ORCPT ); Sun, 26 Nov 2023 04:28:33 -0500 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 448B6D2; Sun, 26 Nov 2023 01:28:40 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3AQ9SSUZ007756; Sun, 26 Nov 2023 10:28:28 +0100 Date: Sun, 26 Nov 2023 10:28:28 +0100 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/3] tools/nolibc: add support for getrlimit/setrlimit Message-ID: <20231126092828.GB7407@1wt.eu> References: <20231123-nolibc-rlimit-v1-0-a428b131de2a@weissschuh.net> <20231123-nolibc-rlimit-v1-2-a428b131de2a@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231123-nolibc-rlimit-v1-2-a428b131de2a@weissschuh.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 26 Nov 2023 01:28:51 -0800 (PST) Hi Thomas, > +int test_rlimit(void) > +{ > + struct rlimit rlim = { > + .rlim_cur = 1 << 20, > + .rlim_max = 1 << 20, > + }; > + int ret; > + > + ret = setrlimit(RLIMIT_CORE, &rlim); > + if (ret) > + return -1; > + > + rlim.rlim_cur = 0; > + rlim.rlim_max = 0; > + > + ret = getrlimit(RLIMIT_CORE, &rlim); > + if (ret) > + return -1; > + > + if (rlim.rlim_cur != 1 << 20) > + return -1; > + if (rlim.rlim_max != 1 << 20) > + return -1; I think you should used two different values here for cur and max so that you can also detect stupid API bugs such as a union being used instead of a struct, or copy-pastes in the implementation etc. For example using 1<<20 and 1<<21 should do the trick. Otherwise Ack-by me for the whole series, of course. Thanks, Willy