From patchwork Wed Nov 17 14:40:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 460 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 637EE27BBE3; Wed, 17 Nov 2021 14:41:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2CDA727BBE1 for ; Wed, 17 Nov 2021 14:41:50 +0000 (GMT) Received: from localhost ([::1]:49934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnM8D-00078n-A6 for patchwork@mira.cbaines.net; Wed, 17 Nov 2021 09:41:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnM7S-0006tc-6M for guix-patches@gnu.org; Wed, 17 Nov 2021 09:41:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mnM7R-00089j-Tt for guix-patches@gnu.org; Wed, 17 Nov 2021 09:41:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mnM7R-0005PN-Rg for guix-patches@gnu.org; Wed, 17 Nov 2021 09:41:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51922] [PATCH 0/2] Improve the reported location of configuration warnings Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 17 Nov 2021 14:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51922 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51922@debbugs.gnu.org Cc: Josselin Poiret X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163716005920772 (code B ref -1); Wed, 17 Nov 2021 14:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 17 Nov 2021 14:40:59 +0000 Received: from localhost ([127.0.0.1]:60572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnM7G-0005Om-Qg for submit@debbugs.gnu.org; Wed, 17 Nov 2021 09:40:59 -0500 Received: from lists.gnu.org ([209.51.188.17]:50804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnM7D-0005OY-BJ for submit@debbugs.gnu.org; Wed, 17 Nov 2021 09:40:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnM7D-0006b6-2N for guix-patches@gnu.org; Wed, 17 Nov 2021 09:40:47 -0500 Received: from jpoiret.xyz ([206.189.101.64]:36850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnM7B-00085J-2f for guix-patches@gnu.org; Wed, 17 Nov 2021 09:40:46 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id E4FC9184C99; Wed, 17 Nov 2021 14:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1637160041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ui9ejPcUFxQ3fkf/AUBSxZV9RHC6ZpvgXAeSGomSKzo=; b=H3+2+OGgah7x/prmHbQhBClNHYkem4XYCU0iNIdczrPgU1KsiNLNyZdjQ3dm+7hLFhgKwj ib8azC+CTtjBq7VT2s89EtrqKHJqu/FRovDqzZBRHI34dXaszKfx62U5kDN2mSA5cUGjDY 5Iptbhbbxd9NI9yBItmgcbNG+oPyOVAyF/B1kCSYF+4rWMO45V6qyf+h3OYgvIRs+5cF+8 xq9Fi7wtjUfsACbMMTdBfYDSOWhYj+ypY5QfQ0f3aQ5qOmTQpCCft1+IUvWLerzSRxGqYV reLKVBU8/tRs5Du3tq3a6SgvGbkTa+RxmtMJ4jLLqpuV75h+/OfKqNx0DVSLiQ== Date: Wed, 17 Nov 2021 14:40:28 +0000 Message-Id: <20211117144028.16722-1-dev@jpoiret.xyz> MIME-Version: 1.0 X-Spamd-Bar: ++++ Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz Received-SPF: pass client-ip=206.189.101.64; envelope-from=dev@jpoiret.xyz; helo=jpoiret.xyz X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.001, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches Hello everyone, While working on the swap-space patch, I noticed that currently, warnings about deprecated fields in guix records use the location of the record definition macro, rather than of the invalid value. For some records such as 'operating-system', this makes it rather user unfriendly and confusing. This patchset first adds the syntax 'define-with-syntax-properties', which helps avoid boilerplate code to define sanitizers with proper location reporting. I put it in guix/diagnostics.scm as I thought this was the place that was most likely to be use-module'd for warning messages, as this is quite tied to that use. The second patch makes use of this new helper to update two warnings: the one about 'target' to 'targets' in bootloader.scm, and the one about setuid-programs. In both cases, a `guix system reconfigure` now reports the exact location of the incriminating values, rather than of the 'bootloader-configuration' or 'operating-system' lines respectively. The approach I've taken for the helper was to make something simple and general enough for most uses. It should correctly report syntax errors with custom errors messages rather than the generic "source expression failed to match any pattern ...". Note although that it isn't possible to do any defines in the body of the macro, as this doesn't use any lambda-like macros (see the second case for an example). I can see two drawbacks to this macro: 1) This macro will not help you write expand-time checkers. This would introduce too much complexity, and I'm not sure the end-user would notice a significant change. 2) It doesn't deconstruct values such as lists to get the individual list values's properties. This would also introduce too much complexity (eg. checking if the list is literal, deconstructing it, and falling back to a generic source location if the list is only available at eval-time). Best, Josselin Poiret Josselin Poiret (2): guix: Add syntax to capture arguments' syntax-properties. gnu: system: Improve location of some configuration warnings. gnu/bootloader.scm | 16 +++++++--------- gnu/system.scm | 11 ++++++----- guix/diagnostics.scm | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 15 deletions(-)