Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jCpo4-0003vn-Ex for mharc-grub-devel@gnu.org; Fri, 13 Mar 2020 15:17:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43394) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCpnz-0003vf-Ex for grub-devel@gnu.org; Fri, 13 Mar 2020 15:17:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCpnx-0004zk-RH for grub-devel@gnu.org; Fri, 13 Mar 2020 15:17:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56152 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCpnw-0004wT-Fz for grub-devel@gnu.org; Fri, 13 Mar 2020 15:17:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584127027; h=from:from: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; bh=3sS408kC3K1AHP8LzXQUpeb7DBmnF2yZVot6ukwjnmo=; b=U3ybgz8YG77M2sUR0NPGNGS3Dd+vjmh35QHs3lG4hBkVmRmUXRYHoB3+WxOeYM2iWe/+GL QsC7/sLdXPKOhP6FplfmV/GHrrnGdcTx+wvS6pldcL5KrQhMdg8YolW0rq8Kpaa0K/kM1l c/xclZSP6ddSryoLLVur1Y1Qofz8uWc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-Df-AdTgtOi2n83keehjvfQ-1; Fri, 13 Mar 2020 15:17:05 -0400 X-MC-Unique: Df-AdTgtOi2n83keehjvfQ-1 Received: by mail-wr1-f72.google.com with SMTP id o9so4775818wrw.14 for ; Fri, 13 Mar 2020 12:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=J0oMZqM7/W/5CmeKFtDQrHGquUBYV3ie5RboksV40sI=; b=L0yFkOzTkY4RpEcwHpyDmlhg/PMEsoXtJ4cVPd2S9EOfssPPx/+4mGugrOgZRep3Pq WX8zPdjvUSsoL4Z3Bw3+IDWDleL9HlZwGML8p8IJVadbEvoOCLIiiCY0OVn3nRw/83V2 B8Z1Rb+ap/UG3oyoFks6KV8H94jrShADVjPyB9aIj94OFe4MSK/yb6LHN3Nc71GARQg7 2uLumPSory9C56mmtwTXSo7Y5j/SoSL+m1Uiy7eyXyu0tF2eL0wijMWm2NxRiZQJ62fH IZeMJwd0ZFsj2OtO0AqMltBqkTSVuJ37BfTdwAvzLAvxbWFJL77go4ctbZn2uDTa/IG9 VCtw== X-Gm-Message-State: ANhLgQ2hy6XDTDjBG3+MmV2epPOeOOgFpUtkq3Dn9oAkPWbi94mTxCZe IyoN9Wz9MFQi4p3gvdqY9A4M/poy7Ync+nVaFlQ1vCAeeYlqcin7rjsLmEZkebh21nhv/nyibD/ /OmacCkHtrMQ= X-Received: by 2002:a5d:4a49:: with SMTP id v9mr19427548wrs.343.1584127023950; Fri, 13 Mar 2020 12:17:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv+f0+0n99mNWMZbKTjQ/lMux9KTbbN1Q6LJhZctptcVA/6HUlFDZsOkNEHIl9OgmUeDiq3AA== X-Received: by 2002:a5d:4a49:: with SMTP id v9mr19427528wrs.343.1584127023724; Fri, 13 Mar 2020 12:17:03 -0700 (PDT) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id i14sm28237583wrp.82.2020.03.13.12.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 12:17:03 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Daniel Kiper , Peter Jones , Javier Martinez Canillas Subject: [PATCH 09/10] kern: Make it possible to subtract conditions from debug= Date: Fri, 13 Mar 2020 20:16:59 +0100 Message-Id: <20200313191659.829012-1-javierm@redhat.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:17:14 -0000 From: Peter Jones This makes it so you can do set debug to "all,-scripting,-lexer" and get th= e obvious outcome. Any negation present will take preference over that conditional, so "all,-scripting,scripting" is the same thing as "all,-scripting". Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas --- grub-core/kern/misc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index ce92ddd076d..e5fd8c1915f 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -162,12 +162,24 @@ int grub_debug_enabled (const char * condition) { const char *debug; + char *negcond; + int negated =3D 0; =20 debug =3D grub_env_get ("debug"); if (!debug) return 0; =20 - if (grub_strword (debug, "all") || grub_strword (debug, condition)) + negcond =3D grub_zalloc (grub_strlen (condition) + 2); + if (negcond) + { + grub_strcpy (negcond, "-"); + grub_strcpy (negcond+1, condition); + negated =3D grub_strword (debug, negcond); + grub_free (negcond); + } + + if (!negated && + (grub_strword (debug, "all") || grub_strword (debug, condition))) return 1; =20 return 0; --=20 2.24.1