Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25226796rwd; Sun, 2 Jul 2023 12:58:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ligT3CU8qHAMIxozoNMJ7NloZ1RLqUM6SwgZx8ROT55Jjv62D+mo0/t72y1MVFZ/1rUOU X-Received: by 2002:a05:6a20:72a7:b0:11e:7ced:3391 with SMTP id o39-20020a056a2072a700b0011e7ced3391mr9197808pzk.43.1688327900987; Sun, 02 Jul 2023 12:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688327900; cv=none; d=google.com; s=arc-20160816; b=xwWe3SVzpVkYaDATBlizkcicjZW6OO5xTE3eG91JuxCgwvTKEw/b10O4QZII/i67XT NH40k78gUHFjkAbDDG42bewmPLKACXFmGY/GPssAgQu1xB3DLO4Owx4RWkPtXN5gMZl1 Vs4+oKx9/E3fgph10SSZZv1PCKJFLkfrcrXy69LFEow+9JXbLH9MtIwA0gxhNsjGepIL fJ0z2hHuQ5Lf2Fhf7eS0pimwhN71/sBpUbE6O1mGZVCxm+pjXFp239MCOuzfwwGSZccg r5eL4qJwe0OHe5jxKLUQYE3xP9GX677mlFwyRcwj/Ab6KL65TBu3CdyoPEFaVwj6n6jE T0bA== 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=PCFMyhjabtDCW51TCwydBXUWU925bkZLJUxqU4KswY8=; fh=5Q8QI6WNR7p/0THTqj1PEFDsdN5oaVk4zWg9deckm6o=; b=PLhYj8bX/I9poeyMBUGhsAHpxZIZBhNZTfnK4EmexKuYW+hg9xow3OdCBwadbcWhNJ dGpN60kdY17XKKpO7hkT3IRnh94DNX8Xjhm0aG8m1gwLG3SXJjQv8uub4GkddFhvxMVV 4qQXKOpqW3wKMAu2jo4pBX/91l2V/EKMgM6nwW4af0IyXYvhyxsnRYn4bjy6BLaOJx23 4hEurkDiAT6YMQi8MXHzINO2JAzqsK/a1lyJ74aZp9nglkkcKGIIM8ylNsP8J1slClkQ MlQP83Q3RbwRCXSGCBmqsoEE31Fe49ZRcMqI2gsk6i9CZaTTJ1yrf6s5A9a3h/YFgMYW pUUQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a63f90a000000b00553a9801a56si17540211pgi.54.2023.07.02.12.58.09; Sun, 02 Jul 2023 12:58:20 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjGBTYB (ORCPT + 99 others); Sun, 2 Jul 2023 15:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjGBTYA (ORCPT ); Sun, 2 Jul 2023 15:24:00 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5EFF3A6; Sun, 2 Jul 2023 12:23:59 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 362JNlu1017530; Sun, 2 Jul 2023 21:23:47 +0200 Date: Sun, 2 Jul 2023 21:23:47 +0200 From: Willy Tarreau To: Zhangjin Wu Cc: thomas@t-8ch.de, arnd@arndb.de, david.laight@aculab.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v5 11/14] tools/nolibc: clean up mmap() support Message-ID: <20230702192347.GJ16233@1wt.eu> References: 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) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Wed, Jun 28, 2023 at 09:41:13PM +0800, Zhangjin Wu wrote: > static __attribute__((unused)) > void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) > { > - void *ret = sys_mmap(addr, length, prot, flags, fd, offset); > - > - if ((unsigned long)ret >= -4095UL) { > - SET_ERRNO(-(long)ret); > - ret = MAP_FAILED; > - } > - return ret; > + return (void *)__sysret((unsigned long)sys_mmap(addr, length, prot, flags, fd, offset)); > } One point regarding this one. By doing so, we're hard-coding the fact that we consider that MAP_FAILED is always -1. I'm not necessarily against it, but this implication can be confusing for those searching where it's being set. I would suggest putting a comment before the mmap() function saying: /* Note that on Linux MAP_FAILED is -1 so we can use the generic __sysret() * which returns -1 upon error and still satisfy user land that checks for * MAP_FAILED. */ Since it's an assumed choice that theoretically could affect portability, it should be reflected in the commit message as well (and we all know it does not have any impact). Thanks! Willy