From nobody Mon Feb 9 17:07:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668589929; cv=none; d=zohomail.com; s=zohoarc; b=Ki18ZYKmNYUcwbOXf+tlrzSj0rf8k3Iu6DH1mCtwNewlqFRtAruZofw4TkaBfyAkkIET+cM3bBJsAZjp0bywPXKTjkoE5KEZigonwULYpPf5nIqRdhl/R2CNNyEl95CE8WRBsvfIrd5o1PX7L7uaJtxW6cJ5pnxb+mr12PxWlZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589929; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ud5V28TkHnEP7q9G71KXK4BFYCIZuv5ug2ZiuvuI1iM=; b=BnPpfkDQUHyyDnztkv7goTSETfsgB82gpTsDSfYh4aG67EsAFn9NnLMUC4QKIJR0ULLdGKHQfY2GVJctTLDaxr9eUYR98TwaYWUQhRBaqjR/eN1Bppc06w1Woa8sicLhtjn8u3vcgukzbW8DWnMU5TWAiCdGqMyFB5qLEBPIE2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1668589929503383.83208247293715; Wed, 16 Nov 2022 01:12:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-8EY8T3WCNCu8nlmE8o1m8g-1; Wed, 16 Nov 2022 04:12:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FD5F3C0F45B; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79C972166B29; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5159919465BA; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19C9619465BA for ; Wed, 16 Nov 2022 09:11:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D703640C835A; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B5C040C83D9 for ; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589927; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ud5V28TkHnEP7q9G71KXK4BFYCIZuv5ug2ZiuvuI1iM=; b=bfzA4u/0Mo5mX9hmPS7t5wfRQ0/YOD/KxtdwVxRDBnR0Er4rr7/xFWOCw+1uX7LTOgCSE2 llt27yNMgCmHFF6ohRDqjHAFGFCShBvIa5lI25EjvTRpQqIYkC6lom+NsMd6Ir8MGJbXah EUI5Hb3lpcIQWfThIm5H+zhdAD8eAvY= X-MC-Unique: 8EY8T3WCNCu8nlmE8o1m8g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] internal: Introduce STRCASESKIP() Date: Wed, 16 Nov 2022 10:11:41 +0100 Message-Id: <9657bb469e0b265a5f6bd00b45b531662b001d62.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668589930805100002 Content-Type: text/plain; charset="utf-8"; x-default="true" There is so far one case where STRCASEPREFIX(a, b) && a + strlen(b) combo is used (in virVMXConfigScanResultsCollector()), but there will be more. Do what we do usually: introduce a macro. Signed-off-by: Michal Privoznik --- docs/coding-style.rst | 9 +++++++++ src/internal.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/docs/coding-style.rst b/docs/coding-style.rst index 1faaf681e4..02d99330bf 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -750,6 +750,15 @@ use one of the following semantically named macros * use: */ STRSKIP(a, b) =20 +- For skipping prefix case insensitively: + + :: + + /* Instead of: + * STRCASEPREFIX(a, b) ? a + strlen(b) : NULL + * use: */ + STRCASESKIP(a, b) + - To avoid having to check if a or b are NULL: =20 :: diff --git a/src/internal.h b/src/internal.h index 1e8e2908bf..35cc22ee3d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -87,6 +87,8 @@ #define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) =3D=3D 0) #define STRCASEPREFIX(a, b) (g_ascii_strncasecmp(a, b, strlen(b)) =3D=3D 0) #define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL) +#define STRCASESKIP(a, b) (STRCASEPREFIX(a, b) ? (a) + strlen(b) : NULL) + /** * STRLIM * @str: pointer to a string (evaluated once) --=20 2.37.4