From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KCY+AJ/GFGMY3QAAbAwnHQ (envelope-from ) for ; Sun, 04 Sep 2022 17:39:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id GBDoOp7GFGPuHAEAG6o9tA (envelope-from ) for ; Sun, 04 Sep 2022 17:39:10 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AF04A2F45F for ; Sun, 4 Sep 2022 17:39:10 +0200 (CEST) Received: from localhost ([::1]:34866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUriH-0004nl-Oy for larch@yhetil.org; Sun, 04 Sep 2022 11:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUriA-0004nP-59 for guix-patches@gnu.org; Sun, 04 Sep 2022 11:39:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUri9-0006CH-SE for guix-patches@gnu.org; Sun, 04 Sep 2022 11:39:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUri9-0004Kc-Jl for guix-patches@gnu.org; Sun, 04 Sep 2022 11:39:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v3 3/3] gnu: bootloader: Add a friendly error message of menu-entry. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 15:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57496 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: typ22@foxmail.com Cc: 57496@debbugs.gnu.org Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166230588816592 (code B ref 57496); Sun, 04 Sep 2022 15:39:01 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 15:38:08 +0000 Received: from localhost ([127.0.0.1]:45456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUrhI-0004JX-Cc for submit@debbugs.gnu.org; Sun, 04 Sep 2022 11:38:08 -0400 Received: from lepiller.eu ([89.234.186.109]:53566) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUrhF-0004JM-7i for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 11:38:07 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id d9ca9fc7; Sun, 4 Sep 2022 15:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:cc:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=dkim; bh=+rloTzOI2HIs nsky4H/WkrT96fNI5HSmPY8uG0DQOvA=; b=IfW33XPoDp2qwByllUY520IBeHI+ ECL4CcoA7Dr88pKTO/sHmQggu5ePVlPRS5n4054znt2DSEkiEp8EKCyHJc+35DUf diwBmsdp+TWAW9am1etYZF0Q2SycgH1p1fNquKMQdT0VXFsv1HbQcLYBGAAqgWvj DzdYk+tzP+PiAYkxwP+06OiKu3q5NzIIpVbw+0xL+0wTNtc5rKv4iVfetddu8bgQ GLk1K3clJjPsoDbXI2sEQMZvkuTuTvWtLIgVap8++3hqIJXoKC1WVh4dGddbZsJw VcXxjn7RKY0FHfcQy2rBofpVM4ihRa1i/U2b/626tMEoeePfXTdnouTDEg== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id e0eb83a0 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Sun, 4 Sep 2022 15:38:01 +0000 (UTC) Date: Sun, 4 Sep 2022 17:37:55 +0200 From: Julien Lepiller Message-ID: <20220904173755.5be9efa0@sybil.lepiller.eu> In-Reply-To: References: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.git.typ22@foxmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662305950; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=aA+xARRz04ZLFTz2N+cwQfibpCV8W1BXUDMoHanF/mM=; b=PkGIpLqILu4akKjn9AhZsAQZpqW3eYTKhkQi5Kl3SJu15cQAACEColDv2fyPxC5mxMJ6vC XkI4a9xgKj2ii6ECIhaVPjajd3axe/2c445/2KpDHGa+33U/9k+GWk0IwhbPFVrniIDxKb NbCqjJgrrYnN+PpnOT05QCgZDjo5UW5kiJiQgADfebpp1H7TOKacQbZnaCBuKsPg5p2/YG 6g9uX0P37lNPzPy8jTY47D97HZNnhEutNm4cGm6+H1PV3a/ns58jm01Eg9ScQAsq6bP8tH +JjujHGmjahNxxMqBBuU3JcsWvmNy4SsDoSdU71kwWNyLsQbeSHwiUgUzJDYJQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662305950; a=rsa-sha256; cv=none; b=kI49Fb1ycTV+RIEaX/a8eqF6eXZoDbXQyaxk3GyD6PoPgpcxglJdN2vJFh47ZjLY6Ghwg9 04w4e6IQKtp+9OUePIkx3MTQXlXd1l13J6M4OX5NL58k59AzV3vXulaVHyAw/JEkk5lL7W 8TzwKcl2Ou8DIWfZzSPqRPd2Yp+5Fn8PVzfs+UvhwVYm9VM0BNSTrJeyOPL1TfxNVQeGVU is+RHVAnTd1V1K507jNRRoMar+FjdadeRXv3PQXoSBxqPEDkdHMw0+qDeWe8njeGv7ng3v A+Heig8EDb3q4jIkXBUxxvsV0TBNmQ6fMHUY2sOu7FGxTcCbu0QYfHfSF4F/1w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=IfW33XPo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.22 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=IfW33XPo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: AF04A2F45F X-Spam-Score: 6.22 X-Migadu-Scanner: scn0.migadu.com X-TUID: o56s27SvqyM7 Hi tiantian, I think the first two patches are good now, so let me focus on this one :) Le Sun, 4 Sep 2022 22:04:31 +0800, typ22@foxmail.com a =C3=A9crit : > From: tiantian >=20 > + (define (set-field? field) > + "If the field is the default value, return #f." > + (and field ; not default value #f > + (not (null? field)))) ; not default value '() I don't think this set-field? is necessary. In the following, I don't think you need the null? case at all because I think all the lists may be empty without triggering an error. You don't necessarily want to load modules or have arguments on the linux command line. In any case, it should be called field-set? instead :) > (match entry > + ;; Modify the pattern to achieve more strict matching and prevent > + ;; wrong matching, which ensures the output of error information > + ;; when menu-entry is wrong. > + > + ;; The linux-arguments is optional and the test code for > boot-parameters > + ;; does not set it, so don't check it here. > (($ label device mount-point > - (? identity linux) linux-arguments initrd > + (? set-field? linux) > + linux-arguments > + (? set-field? initrd) The could still be identity > #f () () #f) > `(menu-entry (version 0) > (label ,label) > @@ -131,8 +162,10 @@ (define (menu-entry->sexp entry) > (linux-arguments ,linux-arguments) > (initrd ,initrd))) > (($ label device mount-point #f () #f > - (? identity multiboot-kernel) > multiboot-arguments > - multiboot-modules #f) > + (? set-field? multiboot-kernel) > + (? set-field? multiboot-arguments) > + (? set-field? multiboot-modules) Some users might want to not use any modules or arguments I think, so these fields should not be mandatory. For multiboot-kernel, identity is enough. > + #f) > `(menu-entry (version 0) > (label ,label) > (device ,(device->sexp device)) > @@ -141,12 +174,13 @@ (define (menu-entry->sexp entry) > (multiboot-arguments ,multiboot-arguments) > (multiboot-modules ,multiboot-modules))) > (($ label device mount-point #f () #f #f () () > - (? identity chain-loader)) > + (? set-field? chain-loader)) Same here, identity is fine. > `(menu-entry (version 0) > (label ,label) > (device ,(device->sexp device)) > (device-mount-point ,mount-point) > - (chain-loader ,chain-loader))))) > + (chain-loader ,chain-loader))) > + (else (report-menu-entry-error entry)))) Since this is a match, it is more common to use: (_ (report-menu-entry-error entry)) Also, it feels weird to patch the code you modified in a previous patch of the same series. If you're not happy with the code you wrote in a previous patch, you need to change it in the previous patch, not in a new one :) > =20 > (define (sexp->menu-entry sexp) > "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a >